diff --git a/application/adminapi/controller/RoomHourRanking.php b/application/adminapi/controller/RoomHourRanking.php new file mode 100644 index 0000000..2ea9f23 --- /dev/null +++ b/application/adminapi/controller/RoomHourRanking.php @@ -0,0 +1,371 @@ + '全时段'], + [0 => '00:00-01:00'], + [1 => '01:00-02:00'], + [2 => '02:00-03:00'], + [3 => '03:00-04:00'], + [4 => '04:00-05:00'], + [5 => '05:00-06:00'], + [6 => '06:00-07:00'], + [7 => '07:00-08:00'], + [8 => '08:00-09:00'], + [9 => '09:00-10:00'], + [10 => '10:00-11:00'], + [11 => '11:00-12:00'], + [12 => '12:00-13:00'], + [13 => '13:00-14:00'], + [14 => '14:00-15:00'], + [15 => '15:00-16:00'], + [16 => '16:00-17:00'], + [17 => '17:00-18:00'], + [18 => '18:00-19:00'], + [19 => '19:00-20:00'], + [20 => '20:00-21:00'], + [21 => '21:00-22:00'], + [22 => '22:00-23:00'], + [23 => '23:00-00:00'], + ]; + } + + + //房间小时榜列表 + public function room_hour_ranking() + { + $page = input('page', 1); + $page_limit = input('page_limit', 20); + $search_ranking = input('search_ranking', ''); + $search_stime = input('search_stime', ''); + $search_etime = input('search_etime', ''); + $where = []; + if ($search_ranking) { + $where[] = ['room_name', 'like', '%' . $search_ranking . '%']; + } + if ($search_stime) { + $where[] = ['stime', '>=', $search_stime]; + } + if ($search_etime) { + $where[] = ['etime', '<=', $search_etime]; + } + $count = db::name('vs_hour_ranking')->where($where)->count(); + $list = db::name('vs_hour_ranking')->where($where)->page($page, $page_limit)->order('id desc')->select(); + if($list){ + foreach ($list as &$v){ + $v['room_name'] = db::name('vs_room')->where(['id'=>$v['room_id']])->value('room_name'); + $v['user_id'] = db::name('vs_room')->where(['id'=>$v['room_id']])->value('user_id'); + if($v['user_id']){ + $v['nickname'] = db::name('user')->where(['id'=>$v['user_id']])->value('nickname'); + } + $v['stime'] = date('Y-m-d H:i', $v['stime']); + $v['etime'] = date('Y-m-d H:i', $v['etime']); + + } + } + $return_data = [ + 'page' =>$page, + 'page_limit' => $page_limit, + 'count' => $count, + 'lists' => $list + ]; + return V(1,"成功", $return_data); + } + + //房间小时榜配置 + public function room_hour_ranking_config() + { + $list = db::name('vs_hour_ranking_config')->where('id', '1')->find(); + if($list){ + //open_time 字段转化为2025-09-30 07:00 的格式 + $list['open_time'] = $list['open_time'] ? date('Y-m-d H:i', $list['open_time']) : 0; + } + return V(1,"成功", $list); + } + + //房间小时榜配置修改 + public function room_hour_ranking_config_edit() + { + $id = input('id'); + $data['is_open_red_pack'] = 0;//暂时不开启 + $data['is_public_server'] = input('is_public_server'); + $data['broadcast_times'] = input('broadcast_times'); + $data['is_open_xlh'] = input('is_open_xlh'); + $data['min_price'] = input('min_price'); + $open_time = input('open_time'); + $data['open_time'] = $open_time ? strtotime($open_time) : 0; + $data['createtime'] = time(); + $data['updatetime'] = time(); + + $timeSlots = json_decode(input('timeJson'), true); + + $timePeriods = $this->withdraw_status(); + + // 构建正确的时间映射关系 + $timeMap = []; + foreach($timePeriods as $period) { + foreach($period as $key => $value) { + $timeMap[$key] = $value; + } + } + + //$timeMap 里面 键值互换 + $timeMap = array_flip($timeMap); + //开启事务 + db::startTrans(); + if($timeSlots){ + $insertData = []; + foreach ($timeSlots as $timeSlot) { +// $timeRange = ; + $timeRange = $timeMap[$timeSlot['time']] ?? '99'; + + foreach ($timeSlot['reward'] as $rewardItem) { + $hasReward = !empty($rewardItem['content']); + + if ($hasReward) { + // 有奖励内容:为每个奖励内容创建一条记录 + foreach ($rewardItem['content'] as $rewardContent) { + if($rewardContent['type'] == 0){ + $coin = $rewardContent['value']; + $gift_id = 0; + $gift_name = ''; + }else{ + $coin = 0; + $gift_id = $rewardContent['value']; + $gift_name = $rewardContent['name']; + } + $insertData[] = [ + 'time_id' => $timeRange, + 'ranking' => $rewardItem['index'], +// 'rank_name' => $rewardItem['name'], + 'gift_type' => $rewardContent['type'], + 'gift_id' => $gift_id, + 'coin' => $coin, + 'name' => $gift_name, + 'createtime' => time() + ]; + } + } else { + // 无奖励内容:插入一条空奖励记录 + $insertData[] = [ + 'time_id' => $timeRange, + 'ranking' => $rewardItem['index'], +// 'rank_name' => $rewardItem['name'], + 'gift_type' => 0, + 'gift_id' => 0, + 'coin' => 0, + 'name' => '', + 'createtime' => time(), + ]; + } + } + } + + // 批量插入 + if (!empty($insertData)) { + $del = db::name('vs_hour_ranking_gift_config')->where('id','>',0)->delete(); + $ins = db::name('vs_hour_ranking_gift_config')->insertAll($insertData); + }else{ + $ins = false; + $del = false; + } + + }else{ + $del = true; + $ins = true; + } + +// $res = db::name('vs_hour_ranking_config')->where('id', $id)->update($data); + $res = db::name('vs_hour_ranking_config')->where('id', $id)->update($data); +// if ($del && $ins && $res) { + if ($ins) { + db::commit(); + return V(1, "成功"); + } else { + db::rollback(); + return V(0, "失败"); + } + } + + //时间段对应关系 + public function time_period_correspondence() + { + $list = $this->withdraw_status(); + $timePeriods = $this->withdraw_status(); + $timeMap = []; + foreach($timePeriods as $period) { + foreach($period as $key => $value) { + $timeMap[$key] = $value; + } + } + return V(1,"成功", $timeMap); + } + + + //添加核心配置 + public function add_core_config() + { + $data['is_public_server'] = input('is_public_server'); + $data['createtime'] = time(); + $data['updatetime'] = time(); + + + $res = db::name('vs_hour_ranking_config')->insert($data); + } + + //核心配置列表 + public function core_config_list() + { + $timePeriods = $this->withdraw_status(); + + // 构建正确的时间映射关系 + $timeMap = []; + foreach($timePeriods as $period) { + foreach($period as $key => $value) { + $timeMap[$key] = $value; + } + } + + // 先按时间段和排名索引分组查询 + $timeRanges = db::name('vs_hour_ranking_gift_config')->distinct(true) + ->order('time_id') + ->column('time_id'); + + $result = []; + foreach ($timeRanges as $timeRange) { + // 查询该时间段的所有数据 + $rewards = db::name('vs_hour_ranking_gift_config')->where('time_id', $timeRange) + ->field('ranking, gift_type, gift_id,coin,name') + ->order('ranking') + ->select(); + + $rewardMap = []; + foreach ($rewards as $reward) { + $rankIndex = $reward['ranking']; + + if (!isset($rewardMap[$rankIndex])) { + $rewardMap[$rankIndex] = [ + 'index' => $rankIndex, +// 'name' => $reward['rank_name'], + 'content' => [] + ]; + } + + // 添加奖励内容到content数组 + if ($reward['gift_id'] != 0 || $reward['coin'] != 0) { + if($reward['gift_id'] != 0){ + $rewardMap[$rankIndex]['content'][] = [ + 'type' => $reward['gift_type'], + 'value' => $reward['gift_id'], +// 'coin' => $reward['coin'], + 'name' => $reward['name'], + ]; + } + if($reward['coin'] != 0){ + $rewardMap[$rankIndex]['content'][] = [ + 'type' => $reward['gift_type'], + 'value' => $reward['coin'], + 'name' => $reward['name'], + ]; + } + + } + } + + // 按index排序 + ksort($rewardMap); + + $result[] = [ + 'time' => $timeMap[$timeRange], + 'reward' => array_values($rewardMap) + ]; + } + + return V(1, "成功", $result); + + } + +// public function core_config_lists() +// { +// $list = db::name('vs_hour_ranking_gift_config')->select(); +// $data = []; +// +// // 按 time_id 和 ranking 重组数据 +// $reorganizedData = []; +// $timePeriods = $this->withdraw_status(); +// +// // 构建正确的时间映射关系 +// $timeMap = []; +// foreach($timePeriods as $period) { +// foreach($period as $key => $value) { +// $timeMap[$key] = $value; +// } +// } +// +// foreach ($list as $item) { +//// $timeId = $item['time_id']; +// $timeId = $timeMap[$item['time_id']] ?? '未知时间段'; +// $ranking = $item['ranking']; +// +// $gift_name = ''; +// if (!isset($reorganizedData[$timeId])) { +// $reorganizedData[$timeId] = []; +// } +// if (!isset($reorganizedData[$timeId][$ranking])) { +// $reorganizedData[$timeId][$ranking] = []; +// } +// if($item['gift_id']){ +// if($item['gift_type'] == 2){ +// $gift_name = db::name('vs_gift')->where(['gid'=>$item['gift_id']])->value('gift_name'); +// } +// if($item['gift_type'] == 3 || $item['gift_type'] == 4){ +// $gift_name = db::name('vs_decorate')->where(['did'=>$item['gift_id']])->value('title'); +// } +// +// }else{ +// $gift_name = ''; +// } +// $reorganizedData[$timeId][$ranking][] = [ +// 'gift_type' => $item['gift_type'], +// 'gift_id' => $item['gift_id'], +// 'gift_name' => $gift_name, +// 'coin' => $item['coin'] +// ]; +// } +// +// // 输出重组后的数据 +// print_r($reorganizedData); +// return V(1, "成功", $data); +// } + +} + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/application/api/controller/BlindBoxTurntable.php b/application/api/controller/BlindBoxTurntable.php new file mode 100644 index 0000000..0ce4750 --- /dev/null +++ b/application/api/controller/BlindBoxTurntable.php @@ -0,0 +1,131 @@ +get_gift_list($gift_bag_id,$room_id); + return v($reslut['code'], $reslut['msg'], $reslut['data']); + } + /* + * 抽奖 + * + */ + public function draw_gift(){ + $gift_bag_id = input('gift_bag_id',0); + $user_id = $this->uid; + $room_id = input('room_id',0); + $gift_user_ids = input('gift_user_ids',0); + $num = input('num',1); + $heart_id = input('heart_id',0); + $auction_id = input('auction_id',0); + $reslut = model('BlindBoxTurntableGiftDrawWorld')->draw_gift($gift_bag_id, $user_id, $gift_user_ids,$num,$room_id,$heart_id,$auction_id); + return v($reslut['code'], $reslut['msg'], $reslut['data']); + } + /* + * 礼物发放 + */ + public function gift_send(){ +// $key_name = "api:blind_box_turntable:gift_send:" . $this->uid; +// redis_lock_exit($key_name); + $send_id = input('send_id',0); + $reslut = model('BlindBoxTurntableGift')->gift_send($send_id); +// redis_unlock($key_name); + return v($reslut['code'], $reslut['msg'], $reslut['data']); + } + + /* + * 获取我的抽奖记录 + */ + public function get_my_record(){ + $user_id = $this->uid; + $gift_bag_id = input('gift_bag_id',0); + $page = input('page',1); + $page_size = input('page_size',12); + $reslut = model('BlindBoxTurntableGift')->get_user_record($gift_bag_id,$user_id,$page,$page_size); + return v($reslut['code'], $reslut['msg'], $reslut['data']); + } + + /* + * 获取全服抽奖记录 + */ + public function get_all_record(){ + $gift_bag_id = input('gift_bag_id',0); + $page = input('page',1); + $page_size = input('page_size',12); + $reslut = model('BlindBoxTurntableGift')->get_all_record($gift_bag_id,$page,$page_size); + return v($reslut['code'], $reslut['msg'], $reslut['data']); + } + /* + * 巡乐会 + */ + public function xlh(){ + $room_id = input('room_id',0); + $reslut = model('BlindBoxTurntableGift')->xlh_gift_list($room_id); + return v($reslut['code'], $reslut['msg'], $reslut['data']); + } + + /* + * 巡乐会抽奖 + */ + public function xlh_draw_gift(){ + $user_id = $this->uid; + $room_id = input('room_id',0); + $num = input('num',1); + $reslut = model('BlindBoxTurntableGiftDrawWorld')->xlh_draw_gift($user_id,$num,$room_id); + return v($reslut['code'], $reslut['msg'], $reslut['data']); + } + /* + * 获取我的巡乐会记录 + */ + public function get_xlh_my_record(){ + $page = input('page',1); + $page_size = input('page_size',12); + $user_id = $this->uid; + $room_id = input('room_id',0); + $reslut = model('BlindBoxTurntableGift')->xlh_get_user_record($user_id,$room_id,$page,$page_size); + return v($reslut['code'], $reslut['msg'], $reslut['data']); + } + /* + * 获取全服巡乐会记录(榜单) + */ + public function get_xlh_all_record(){ + $page = input('page',1); + $page_size = input('page_size',12); + $room_id = input('room_id',0); + $reslut = model('BlindBoxTurntableGift')->xlh_ranking($room_id,$page,$page_size); + return v($reslut['code'], $reslut['msg'], $reslut['data']); + } + + /* + * 巡乐会榜单 (以期数显示) + */ + public function get_xlh_ranking(){ + $page = input('page',1); + $page_size = input('page_size',12); + $room_id = input('room_id',0); + $reslut = model('BlindBoxTurntableGift')->xlh_ranking_list($room_id,$page,$page_size); + return v($reslut['code'], $reslut['msg'], $reslut['data']); + } +} \ No newline at end of file diff --git a/application/api/controller/Friend.php b/application/api/controller/Friend.php new file mode 100644 index 0000000..df4973f --- /dev/null +++ b/application/api/controller/Friend.php @@ -0,0 +1,65 @@ +uid; + redis_lock_exits($key_name); + $room_id = input('room_id', ''); + $reslut = model('Friend')->start_friend($this->uid,$room_id); + redis_unlocks($key_name); + return V($reslut['code'], $reslut['msg'], $reslut['data']); + } + + //交友延时 + public function delay(){ + $friend_id = input('friend_id', ''); + $room_id = input('room_id', ''); + $delay_times = input('delay_times', '');//分钟 + + $reslut = model('Friend')->delay($this->uid,$room_id,$friend_id,$delay_times); + + return V($reslut['code'], $reslut['msg'], $reslut['data']); + } + + //交友结束 + public function end_friend(){ + + $friend_id = input('friend_id', ''); + $room_id = input('room_id', ''); + + $result = model('Friend')->end_friend($this->uid,$room_id,$friend_id); + + return V($result['code'], $result['msg'], $result['data']); + } + + //卡关系 创建关系 + public function create_relation() + { + $key_name = "api:friend:create_relation:" . $this->uid; + redis_lock_exits($key_name); + $room_id = input('room_id', ''); + $friend_id = input('friend_id', ''); + $user1_id = input('user1_id', ''); + $user2_id = input('user2_id', ''); + $relation_id = input('relation_id', ''); + $result = model('Friend')->createRelation($this->uid,$room_id,$friend_id,$user1_id,$user2_id,$relation_id); + redis_unlocks($key_name); + return V($result['code'], $result['msg'], $result['data']); + } + + //退出私密小屋 + public function out_room() + { + $room_id = input('room_id', ''); + + $result = model('Friend')->outRoom($this->uid,$room_id); + + return V($result['code'], $result['msg'], $result['data']); + } +} \ No newline at end of file diff --git a/application/api/controller/Redpacket.php b/application/api/controller/Redpacket.php new file mode 100644 index 0000000..9bc9074 --- /dev/null +++ b/application/api/controller/Redpacket.php @@ -0,0 +1,119 @@ +request->post(); + + $data['user_id'] = $this->uid; + + $service = new RedpacketService(); + $reslut = $service->create($data); + + return V($reslut['code'], $reslut['msg'], $reslut['data']); + } + + /** + * 抢红包 + */ + public function grab() + { + $redpacketId = input('redpacket_id', 0); + + if (empty($redpacketId)) { + return V(0, '红包ID不能为空'); + } + + $service = new RedpacketService(); + // 在抢红包前确保状态正确 + $service->checkAndUpdateRedpacketStatus($redpacketId); + $reslut = $service->grabWithResult($redpacketId, $this->uid); + + return V($reslut['code'], $reslut['msg'], $reslut['data']); + } + + /** + * 获取抢红包结果 + */ + public function grabResult() + { + $redpacketId = $this->request->get('redpacket_id'); + + if (empty($redpacketId)) { + return V(0, '红包ID不能为空'); + } + + $service = new RedpacketService(); + $result = $service->getGrabResult($redpacketId, $this->uid); + + if (!$result) { + return V(0, '红包不存在'); + } + + return V(1, '获取成功', $result); + } + + /** + * 红包详情 + */ + public function detail() + { + $redpacketId = input('redpacket_id', 0); + + if (empty($redpacketId)) { + return V(0, '红包ID不能为空'); + } + + $service = new RedpacketService(); + // 在获取详情前确保状态正确 + $service->checkAndUpdateRedpacketStatus($redpacketId); + $detail = $service->getDetail($redpacketId, $this->uid); + + if (!$detail) { + return V(0, '红包不存在'); + } + + return V(1, '获取成功', $detail); + } + + /** + * 获取倒计时选项 + */ + public function countdownOptions() + { + $options = \app\common\model\Redpacket::$countdownOptions; + $this->success('获取成功', $options); + } + + // 获取房间内红包列表 + public function roomRedPackets() + { + $roomId = $this->request->get('room_id'); + $result = Db::name('redpacket')->where(['room_id' => $roomId, 'status' => ['<=',1]])->select(); + if($result){ + foreach ($result as &$item) { + $item['redpacket_id'] = $item['id']; + $item['redpacket_time'] = get_system_config_value('red_packet_time');//展示时间 + $item['nickname'] = Db::name('user')->where('id', $item['user_id'])->value('nickname'); + $item['avatar'] = Db::name('user')->where('id', $item['user_id'])->value('avatar'); + $is_qiang = Db::name('redpacket_record')->where(['redpacket_id' => $item['id'], 'user_id' => $this->uid])->find(); + $item['is_qiang'] = $is_qiang ? 1 : 0; + } + } + return V(1, '获取成功', $result); + } +} \ No newline at end of file diff --git a/application/api/controller/RoomHourRanking.php b/application/api/controller/RoomHourRanking.php new file mode 100644 index 0000000..bf0e60b --- /dev/null +++ b/application/api/controller/RoomHourRanking.php @@ -0,0 +1,34 @@ +order('id', 'desc')->value('open_time'); + return V(1, '获取成功', ['open_time' => $open_time]); + } + + //房间小时榜玩法 + public function room_hour_ranking_play() + { + $introd = db::name('vs_hour_ranking_config')->order('id', 'desc')->value('introd'); + return V(1, '获取成功', ['introd' => $introd]); + } + + //房间小时榜 + public function room_hour_ranking() + { + $page = input('page', 1); + $page_limit = input('page_limit', 20); + + $reslut = model('RoomHourRanking')->room_hour_ranking($page, $page_limit); + return V($reslut['code'], $reslut['msg'], $reslut['data']); + } + +} \ No newline at end of file diff --git a/application/api/controller/Xintiao.php b/application/api/controller/Xintiao.php new file mode 100644 index 0000000..53e36ad --- /dev/null +++ b/application/api/controller/Xintiao.php @@ -0,0 +1,39 @@ +uid; + $is_xintiao = db::name('vs_xintiao')->where('user_id' , $user_id)->find(); + if($is_xintiao){ + db::name('vs_xintiao')->where('user_id' , $user_id)->update(['updatetime' => time()]); + }else{ + db::name('vs_xintiao')->insert([ + 'user_id' => $user_id, + 'createtime' => time(), + 'updatetime' => time() + ]); + } + return true; + } + + + + + + + + + +} \ No newline at end of file diff --git a/application/api/controller/Xxiaoshi.php b/application/api/controller/Xxiaoshi.php new file mode 100644 index 0000000..54dc121 --- /dev/null +++ b/application/api/controller/Xxiaoshi.php @@ -0,0 +1,434 @@ +where('id', 1)->value('open_time'); + if ($is_open_time == 0) { + echo "未开启时间段:" .$is_open_time."\n"; + return; + } + //是否全局飘瓶 + $is_public_server = db::name('vs_hour_ranking_config')->where('id', 1)->value('is_public_server'); + if ($is_public_server == 1) { + //全局飘瓶时间段 + $xlh_time_range = db::name('vs_hour_ranking_config')->where('id', 1)->value('broadcast_times'); + if($xlh_time_range){ + if($xlh_time_range == 25){ + $is_piao = 1; + }else{ + + //当前的前一个小时是否在 $xlh_time_range中 + if (in_array($pre_hour, explode(',', $xlh_time_range))) { + $is_piao = 1; + } else { + $is_piao = 0; + } + } + }else{ + $is_piao = 0; + } + }else{ + $is_piao = 0; + } + + //获取上一个时间段的配置 +// $gift_list = db::name('vs_hour_ranking_gift_config')->where('time_id',$pre_hour)->group('ranking')->order('id', 'desc')->select(); + $gift_list = $this->get_hour_ranking($pre_hour); +// echo "上个时间段的配置:" .json_encode($gift_list)."\n"; + // 提取所有有奖励的内容 + $allRewards = $this->extractAllRewards($gift_list); + // 按index分组 + $groupedRewards = $this->groupRewardsByIndex($allRewards); + // 按名次顺序分配奖励 + $distributionResult = $this->distributeByRank($groupedRewards); + + //获取上个数组的个数,从而获取配置了多少个名次 + $count = count($distributionResult); + echo "上个时间段的配置总数:" .$count."\n"; + //获取前一个小时的 前$count名房间排行 + $room_list = model('api/RoomHourRanking')->room_hour_ranking(1, $count, $start_time, $end_time); + $room_owner = []; + if ($room_list['code'] == 1) { + //获取房间排行奖励最低值 + $min_price = db::name('vs_hour_ranking_config')->where('id', 1)->value('min_price'); + if ($room_list['data']['lists']) { + echo "房间列表:" .json_encode($room_list['data']['lists'])."\n"; + foreach ($room_list['data']['lists'] as $v){ + if ($v['total_price'] >= $min_price) { + $room_owner[] = [ + 'user_id' => $v['user_id'], + 'room_name' => $v['room_name'], + 'room_id' => $v['room_id'], + 'total_price' => $v['total_price'] + ]; + } + } + } + } + + if ($distributionResult && $room_owner) { + $text_list_new = []; + echo "礼物数:" .json_encode($distributionResult)."\n"; + echo "房主:" .json_encode($room_owner)."\n"; + foreach ($distributionResult as $k => $value) { + //礼物全部给他偷偷放在装扮表及金额 中 + //有几个用户就发几个 + if(count($room_owner) > $k){ + // 为每个房间添加一个标志,表示是否已处理推送信息 + $hasProcessedPush = false; + + foreach ($value['rewards'] as $v){ + // if($v['type'] == 0){//1金币2礼物3头像4坐骑 + // echo "发金币:" .$v['value'].'==>'.$room_owner[$k]['user_id']."\n"; + // $res = $this->add_coin($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao); + // }elseif ($v['type'] == 1){ + // echo "发礼物:" .$v['value'].'==>'.$room_owner[$k]['user_id']."\n"; + // $res = $this->add_gift($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao); + // }elseif ($v['type'] == 2){ + // $res = $this->add_decorate($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao,3); + // }elseif ($v['type'] == 3){ + // $res = $this->add_decorate($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao,4); + // } + // 只有在第一次处理奖励时添加推送信息,避免重复推送 + if(!$hasProcessedPush && $is_piao == 1) { + $room_name = $room_owner[$k]['room_name']; + //推送礼物横幅 + if ($k == 0) { + $text = '新科状元!【' . $room_name . '】独占鳌头!'; + } elseif ($k == 1) { + $text = '金榜榜眼!【' . $room_name . '】才气逼人!'; + } elseif ($k == 2) { + $text = '风采探花!【' . $room_name . '】实力绽放!'; + } + + $text_list_new[] = [ + 'text' => $text ?? '恭喜【' . $room_name . '】获得礼物!', + 'room_id' => $room_owner[$k]['room_id'], + 'room_name' => $room_name, + 'rank_number' => $k + 1, + ]; + + $hasProcessedPush = true; // 标记已处理推送 + } + } + + } + } + if(!empty($text_list_new)){ + $push = new Push(); + $push->hourRankingcs($text_list_new); + Log::record("小时榜推送:".json_encode($text_list_new),"infos"); + } + } + echo "送礼-共" . count($room_owner) . "个房间房主获益\n"; + } + + //添加金币到钱包 +// public function add_coin($coin,$user_id,$ranking,$room_id,$total_price,$is_piao){ +// if($coin > 0){ +// $data = [ +// 'user_id' => $user_id, +// 'change_value' => $coin, +// // 'room_id' => $room_ids, +// 'money_type' => 1, +// 'change_type' => 27, +// 'from_id' => 0, +// 'remarks' => '小时榜获得', +// 'createtime' => time() +// ]; + +// //开启事务 +// Db::startTrans(); +// $res = Db::name('vs_user_money_log')->insert($data); +// if(!$res){ +// Db::rollback(); +// } + +// //增加用户金币 +// $res1 = Db::name('user_wallet')->where(['user_id'=>$user_id])->setInc('coin',$coin); +// if(!$res1){ +// Db::rollback(); +// } + +// //添加到排行表 +// $start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour'))); +// $end_time = strtotime(date('Y-m-d H:00:00')) - 1; +// $res2 = db::name('vs_hour_ranking')->insert([ +// 'ranking' => $ranking, +// 'room_id' => $room_id, +// 'flowing_water' => $total_price, +// 'coin' => $coin, +// 'time_id' => date('H', strtotime('-1 hour')), +// 'stime' => $start_time, +// 'etime' => $end_time, +// 'createtime' => time(), +// 'updatetime' => time(), +// 'is_public_server' => $is_piao +// ]); +// if(!$res2){ +// Db::rollback(); +// } +// Db::commit(); +// } + +// return true; +// } + +// //添加礼物到背包 +// public function add_gift($gift_id,$user_id,$ranking,$room_id,$total_price,$is_piao){ +// $res = model('api/UserGiftPack')->change_user_gift_pack($user_id,$gift_id,1,model('UserGiftPack')::HOUR_RANK_GET,"小时榜获得"); +// if($res['code'] == 0){ +// Log::record("小时榜获取礼物失败:".$res['msg'],"info"); +// } + +// //添加到排行表 +// $start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour'))); +// $end_time = strtotime(date('Y-m-d H:00:00')) - 1; +// $res2 = db::name('vs_hour_ranking')->insert([ +// 'ranking' => $ranking, +// 'room_id' => $room_id, +// 'flowing_water' => $total_price, +// 'gift_id' => $gift_id, +// 'gift_type' => 2, +// 'time_id' => date('H', strtotime('-1 hour')), +// 'stime' => $start_time, +// 'etime' => $end_time, +// 'createtime' => time(), +// 'updatetime' => time(), +// 'is_public_server' => $is_piao +// ]); +// if(!$res2){ +// Log::record("小时榜礼物锁定失败","info"); +// } +// return true; +// } + +// //添加装扮到背包 +// public function add_decorate($avatar_id,$user_id,$ranking,$room_id,$total_price,$is_piao,$type){ +// $decorate_price_info = db::name('vs_decorate_price')->where(['id'=>$avatar_id])->find(); +// if(empty($decorate_price_info)){ +// Log::record("小时榜获取装扮失败:没有找到装扮!".$avatar_id,"info"); +// } +// $res = model('api/Decorate')->pay_decorate($user_id,$decorate_price_info['did'],$decorate_price_info['day'],2); +// if($res['code'] == 0){ +// Log::record("小时榜获取装扮失败:".$res['msg']."-".$avatar_id,"info"); +// } +// //添加到排行表 +// $start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour'))); +// $end_time = strtotime(date('Y-m-d H:00:00')) - 1; +// $res2 = db::name('vs_hour_ranking')->insert([ +// 'ranking' => $ranking, +// 'room_id' => $room_id, +// 'flowing_water' => $total_price, +// 'gift_id' => $avatar_id, +// 'gift_type' => $type, +// 'time_id' => date('H', strtotime('-1 hour')), +// 'stime' => $start_time, +// 'etime' => $end_time, +// 'createtime' => time(), +// 'updatetime' => time(), +// 'is_public_server' => $is_piao, +// ]); +// if(!$res2){ +// Log::record("小时榜咋装扮锁定失败","info"); +// } +// return true; +// } + + + /** + * 提取所有有奖励的内容 + */ + private function extractAllRewards($responseData) + { + $allRewards = []; + + foreach ($responseData as $timeSlot) { + foreach ($timeSlot['reward'] as $rewardItem) { + $index = $rewardItem['index']; + $content = $rewardItem['content']; + + // 只处理有奖励内容的数据 + if (!empty($content)) { + foreach ($content as $rewardContent) { + $allRewards[] = [ + 'index' => $index, + 'type' => $rewardContent['type'], + 'value' => $rewardContent['value'], + 'name' => $rewardContent['name'] ?? '' + ]; + } + } + } + } + + return $allRewards; + } + + /** + * 按index分组奖励 + */ + private function groupRewardsByIndex($allRewards) + { + $grouped = []; + + foreach ($allRewards as $reward) { + $index = $reward['index']; + if (!isset($grouped[$index])) { + $grouped[$index] = []; + } + $grouped[$index][] = $reward; + } + + // 按index排序 + ksort($grouped); + + return $grouped; + } + + /** + * 按名次顺序分配奖励 + */ + private function distributeByRank($groupedRewards) + { + $distribution = []; + $currentRank = 0; // 从第1名开始 + + // 按index顺序分配(index 0 = 第1名,index 1 = 第2名,以此类推) + foreach ($groupedRewards as $index => $rewards) { + // 确保名次连续,如果有空缺则填充空名次 + while ($currentRank < $index) { + $distribution[] = [ + 'rank' => $currentRank + 1, + 'rewards' => [] + ]; + $currentRank++; + } + + // 分配当前名次的奖励 + $distribution[] = [ + 'rank' => $currentRank + 1, + 'rewards' => $rewards + ]; + $currentRank++; + } + + return $distribution; + } + + public function get_hour_ranking($time){ + // 先按时间段和排名索引分组查询 + $timeRanges = db::name('vs_hour_ranking_gift_config')->distinct(true) + ->where('time_id', '=', $time) + ->order('time_id') + ->column('time_id'); + + $result = []; + foreach ($timeRanges as $timeRange) { + // 查询该时间段的所有数据 + $rewards = db::name('vs_hour_ranking_gift_config')->where('time_id', $timeRange) + ->field('ranking, gift_type, gift_id,coin,name') + ->order('ranking') + ->select(); + + $rewardMap = []; + foreach ($rewards as $reward) { + $rankIndex = $reward['ranking']; + + if (!isset($rewardMap[$rankIndex])) { + $rewardMap[$rankIndex] = [ + 'index' => $rankIndex, +// 'name' => $reward['rank_name'], + 'content' => [] + ]; + } + + // 添加奖励内容到content数组 + if ($reward['gift_id'] != 0 || $reward['coin'] != 0) { + if($reward['gift_id'] != 0){ + $rewardMap[$rankIndex]['content'][] = [ + 'type' => $reward['gift_type'], + 'value' => $reward['gift_id'], +// 'coin' => $reward['coin'], + 'name' => $reward['name'], + ]; + } + if($reward['coin'] != 0){ + $rewardMap[$rankIndex]['content'][] = [ + 'type' => $reward['gift_type'], + 'value' => $reward['coin'], + 'name' => $reward['name'], + ]; + } + + } + } + + // 按index排序 + ksort($rewardMap); + + $result[] = [ + 'time' => $timeRange, + 'reward' => array_values($rewardMap) + ]; + } + return $result; + } + + + public function give_gifts(){ + $data = db::name('vs_give_gift')->where('from_id',5483)->select(); + $num = 0; + $i=0; + $j = 0; + foreach($data as $v){ + $j += $v['total_price']; + $nuu = db::name('vs_give_gift_ratio_log')->where('give_gift_id',$v['id'])->value('room_owner_earning'); + $id = db::name('vs_give_gift_ratio_log')->where('give_gift_id',$v['id'])->value('id'); + // echo $id."--".$nuu."\n"; + $num += $nuu; + $i++; + } + echo $num; + echo "==".$i."==".$j; + + // echo db::name()->where(['user_id' => 10857,'money_type' =>2,'change_type' =>18])-sum('change_value'); + } + + + public function room_liushui(){ + // $room = db::name('vs_give_gift')->where(['from_id' => ['<>',5418],'from' => 2])->group('from_id'); + $dd = db::name('vs_user_gift_pack')->alias('a')->join('vs_gift b','a.gid = b.gid')->field('a.gid,a.num,b.gift_price')->where(['a.num' =>['>',0]])->select(); + $count = 0; + foreach ($dd as $v){ + $count += $v['gift_price'] * $v['num']; + } + echo $count; + } + + + + + + +} \ No newline at end of file diff --git a/application/api/model/BlindBoxTurntableGift.php b/application/api/model/BlindBoxTurntableGift.php new file mode 100644 index 0000000..b4a0093 --- /dev/null +++ b/application/api/model/BlindBoxTurntableGift.php @@ -0,0 +1,416 @@ +where('id',$gift_bag_id)->find(); + $gifts = db::name('vs_gift_bag_detail')->where('gift_bag_id',$gift_bag_id)->order("id desc")->select(); + $gift_list = []; + foreach ($gifts as $key => $value) { + $gift_data = db::name('vs_gift')->where('gid',$value['foreign_id'])->where('delete_time',0)->find(); + if($gift_data){ + $gift_list[$key]['number'] = $key; + $gift_list[$key]['gift_id'] = $gift_data['gid']; + $gift_list[$key]['gift_name'] = $gift_data['gift_name']; + $gift_list[$key]['base_image'] = $gift_data['base_image']; + $gift_list[$key]['play_image'] = $gift_data['play_image']; + $gift_list[$key]['gift_price'] = $gift_data['gift_price']; + } + } + $ext = json_decode($box['ext'],true); + $box_gift = Db::name('vs_gift')->where('gid',$ext['gift_id'])->find(); + + //巡乐会 + $is_xlh = 0; + $xlh_box = db::name('vs_gift_bag')->where('id',13)->find(); + $xlh_ext = json_decode($xlh_box['ext'],true); + $xlh = []; + if($xlh_ext['inlet_bag_id'] == $box['id']){ + $is_xlh = 1; + $xlh['waiting_start_num'] = $xlh_ext['open_condition']['waiting_start_num'];//等待开奖次数 + $xlh['start_num'] = $xlh_ext['open_condition']['start_num'];//开始开奖次数 + //当前抽奖次数 + $xlh['current_num'] = Cache::get("xlh_periods_num") ?? 0; + //状态 + if($xlh['current_num'] >= $xlh_ext['open_condition']['start_num']){ + $xlh['status'] = 1;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始 + } elseif($xlh['current_num'] >= $xlh_ext['open_condition']['waiting_start_num'] && $xlh['current_num'] < $xlh_ext['open_condition']['start_num']){ + $xlh['status'] = 2;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始 + }else{ + $xlh['status'] = 0; + } + } + $result_data = [ + 'title' => $box['name'], + 'rule_url' => get_system_config_value('web_site')."/api/Page/get_gift_box_rule?box_id=".$box["id"], + 'box_price' => $box_gift['gift_price'], + 'is_xlh' => $is_xlh, + 'xlh_data' => $xlh, + 'gift_list' => $gift_list, + ]; + return ['code' => 1, 'msg' => '获取成功', 'data' => $result_data]; + } + + /* + * 礼物特效播放 + */ + public function gift_send($send_id){ + try{ + $blind_box_turntable = db('vs_blind_box_turntable_log')->where(['id'=>$send_id,'is_sued'=>0])->find(); + if(!$blind_box_turntable){ + return ['code' => 1, 'msg' => '成功', 'data' => null]; + } + $room_id = $blind_box_turntable['room_id']; + $blind_box_turntable_log = db('vs_blind_box_turntable_results_log')->where(['tid'=>$send_id])->select(); + if(!$blind_box_turntable_log){ + return ['code' => 0, 'msg' => '数据不存在','data' => null]; + } + $room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name'); + $FromUserInfo = Db::name('user')->where(['id'=>$blind_box_turntable['user_id']])->find(); + $FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($blind_box_turntable['user_id']);//财富图标 + $FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($blind_box_turntable['user_id']);//魅力图标 + $user_nickname = $FromUserInfo['nickname']; + $textMessage = $user_nickname; + $text_message = []; + foreach ($blind_box_turntable_log as $key => $value) { + $ToUserInfo = Db::name('user')->where(['id' => $value['gift_user_id']])->field('id as user_id,nickname,avatar,sex')->find(); + $draw_gift = Db::name('vs_gift')->where(['gid'=>$value['gift_id']])->find(); + $textMessage = $textMessage . ' 送给 ' . $ToUserInfo['nickname']. ' 盲盒转盘礼物 ' . $draw_gift['gift_name'].' x ' .$value['count']."\n"; + $play_image[] = $draw_gift['play_image']; + $gift_names[] = $draw_gift['gift_name']; + + $text_message = $user_nickname . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $draw_gift['gift_name'] . 'X' . $value['count']."\n"; + if($draw_gift['is_public_server'] == 1) { + $text_list_new[] = [ + 'text' => $text_message, + 'gift_picture' => $draw_gift['base_image'], + 'room_id' => $room_id, + 'fromUserName' => $FromUserInfo['nickname'], + 'toUserName' => $ToUserInfo['nickname'], + 'giftName' => $draw_gift['gift_name'], + 'roomId' => $room_id, + 'number' => $value['count'], + ]; + } + $ToUserInfosList[$value['gift_user_id']] = $ToUserInfo; + + } + foreach($ToUserInfosList as &$userInfo) { + $userInfo['icon'][0] = model('UserData')->user_wealth_icon($userInfo['user_id']);//财富图标 + $userInfo['icon'][1] = model('UserData')->user_charm_icon($userInfo['user_id']);//魅力图标 + $userInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $userInfo['user_id'],'room_id' => $room_id])->value('charm');//魅力 + $ToUserInfos[] = $userInfo; + } + $text = [ + 'FromUserInfo' => $FromUserInfo, + 'ToUserInfos' => $ToUserInfos, + 'GiftInfo' => [ + 'play_image' => implode(',',$play_image), + 'gift_name' => implode(',',$gift_names), + ], + 'text' => rtrim($textMessage, "\n") + ]; + //聊天室推送系统消息 + model('Chat')->sendMsg(1005,$room_id,$text); + $roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id'); + if($roomtype == 6){ + //推送消息 + $hot_value = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',6) + ->sum('total_price'); + $text1 = [ + 'room_id' => $room_id, + 'hot_value' => $hot_value * 10, + 'text' => '房间心动值变化' + ]; + //聊天室推送系统消息 + model('Chat')->sendMsg(1028,$room_id,$text1); + }else{ + if(!empty($text_list_new)){ + //推送礼物横幅 + $push = new Push($blind_box_turntable['user_id'], $room_id); + $push->giftBanner($text_list_new); + } + } + db::name('vs_blind_box_turntable_log')->where('id', $send_id)->update(['is_sued' => 1, 'updatetime' => time()]); + return ['code' => 1, 'msg' => '成功', 'data' => null]; + } catch (\Exception $e) { + return ['code' => 0, 'msg' => "网络请求错误,请重试!", 'data' => null]; + } + + } + + /* + * 获取用户抽奖记录 + */ + public function get_user_record($gift_bag_id,$user_id=0,$page=1,$page_size=12){ + $where = []; + $where['b.gift_bag_id'] = $gift_bag_id; + if($user_id > 0){ + $where['b.user_id'] = $user_id; + } + $list = db('vs_blind_box_turntable_results_log') + ->alias('a') + ->join('vs_blind_box_turntable_log b','b.id = a.tid','left') + ->join('user c','a.gift_user_id = c.id','left') + ->join('vs_gift d','d.gid = a.gift_id','left') + ->field('a.gift_id,a.count,a.gift_user_id,a.createtime,c.nickname,d.gift_name as gift_name,d.base_image') + ->where($where) + ->order('a.createtime desc') + ->page($page,$page_size) + ->select(); + foreach ($list as &$v){ + $v['createtime'] = date('Y-m-d H:i:s',$v['createtime']); + } + return ['code' => 1, 'msg' => '成功', 'data' => $list]; + } + /* + * 获取全服抽奖记录 + */ + public function get_all_record($gift_bag_id,$page=1,$page_size=12){ + $where = []; + $where['b.gift_bag_id'] = $gift_bag_id; + $where['d.gift_bag_id'] = $gift_bag_id; + $where['d.is_world_show'] = 1; + $list = db('vs_blind_box_turntable_results_log') + ->alias('a') + ->join('vs_blind_box_turntable_log b','b.id = a.tid','left') + ->join('user c','b.user_id = c.id','left') + ->join('vs_gift_bag_detail d','d.foreign_id = a.gift_id','left') + ->join('vs_gift e','e.gid = a.gift_id','left') + ->field('a.gift_id,a.count,b.user_id,a.createtime,c.nickname,d.name as gift_name,e.base_image') + ->where($where) + ->order('a.createtime desc') + ->page($page,$page_size) + ->select(); + foreach ($list as &$v){ + $v['createtime'] = date('Y-m-d H:i:s',$v['createtime']); + } + return ['code' => 1, 'msg' => '成功', 'data' => $list]; + } + /* + * 巡乐会 + */ + public function xlh_gift_list($room_id){ + $gift_bag_id = 13; + $xlh_box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find(); + $xlh_ext = json_decode($xlh_box['ext'],true); + $gifts = db::name('vs_gift_bag_detail')->where('gift_bag_id',$gift_bag_id)->order("id desc")->select(); + $gift_list = []; + foreach ($gifts as $key => $value) { + $gift_data = db::name('vs_gift')->where('gid',$value['foreign_id'])->where('delete_time',0)->find(); + if($gift_data){ + $gift_list[$key]['number'] = $key; + $gift_list[$key]['gift_id'] = $gift_data['gid']; + $gift_list[$key]['gift_name'] = $gift_data['gift_name']; + $gift_list[$key]['base_image'] = $gift_data['base_image']; + $gift_list[$key]['play_image'] = $gift_data['play_image']; + $gift_list[$key]['gift_price'] = $gift_data['gift_price']; + } + } + //房主信息 +// $room_user = db::name('user')->where('id',$room_data['user_id'])->find(); + //房主礼物 + $room_user_gift = db::name('vs_gift')->where('gid',$xlh_ext['locking_condition']['give_homeowner_gift_id'])->find(); + //巡乐会主礼物 + $xlh_main_gift = db::name('vs_gift')->where('gid',$xlh_ext['locking_condition']['locking_gift_id'])->find(); + //中奖用户 + $pan_xlh = db::name('vs_room_pan_xlh')->where(['send_time'=>0,'end_time'=>['>',time()]])->order('id desc')->find(); + $xlh_periods_num = Cache::get("xlh_periods_num") ?? 0; + if(empty($pan_xlh)){ + if($xlh_periods_num >= $xlh_ext['open_condition']['start_num']){ + $xlh_periods = Cache::get("this_xlh_periods") ?? 0; + $pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([ + 'room_id' => $room_id, + 'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'], + 'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'], + 'periods' => $xlh_periods+1, + 'num' => 0, + 'end_time' => time() + $xlh_ext['locking_time']['end_time'] * 60, + 'createtime' => time() + ]); + Cache::set("this_xlh_periods", $xlh_periods+1, 0);//修改巡乐会期数 + $pan_xlh = db::name('vs_room_pan_xlh')->where(['id'=>$pan_xlh_id])->find(); + }else{ + return ['code' => 0, 'msg' => '巡乐会已结束', 'data' => null]; + } + } + $xlh_user_data= null; + $room_user_data = null; + if($pan_xlh && $pan_xlh['user_id']){ + $xlh_user = db::name('user')->where('id',$pan_xlh['user_id'])->find(); + $xlh_user_data = [ + 'user_id' => $xlh_user['id'], + 'nickname' => $xlh_user['nickname'], + 'avatar' => $xlh_user['avatar'], + ]; + if($pan_xlh['room_id']){ + $room_data = db::name('vs_room')->field('xlh_periods,xlh_periods_num,user_id')-> where('id',$pan_xlh['room_id'])->find(); + $room_user = db::name('user')->where('id',$room_data['user_id'])->find(); + $room_user_data = [ + 'user_id' => $room_user['id'], + 'nickname' => $room_user['nickname'], + 'avatar' => $room_user['avatar'], + ]; + } + } + //$gift_list 按gift_price 升序排序 + usort($gift_list, function($a, $b) { + return $a['gift_price'] - $b['gift_price']; + }); + + $result_data = [ + 'title' => $xlh_box['name'], + 'rule_url' => get_system_config_value('web_site')."/api/Page/get_gift_box_rule?box_id=".$xlh_box["id"], + 'box_price' => $xlh_ext['xlh_box_price'], + 'xlh_end_time' =>$pan_xlh['end_time']??0, + 'give_homeowner_gift' => [ + 'gift_id' => $room_user_gift['gid'], + 'gift_name' => $room_user_gift['gift_name'], + 'gift_price' => $room_user_gift['gift_price'], + 'base_image' => $room_user_gift['base_image'], + ], + 'homeowner_user' => $room_user_data, + 'locking_gift' => [ + 'gift_id' => $xlh_main_gift['gid'], + 'gift_name' => $xlh_main_gift['gift_name'], + 'gift_price' => $xlh_main_gift['gift_price'], + 'base_image' => $xlh_main_gift['base_image'], + 'gift_num' => $pan_xlh['num']??0 + ], + 'xlh_user' => $xlh_user_data, + 'gift_list' => $gift_list, + ]; + return ['code' => 1, 'msg' => '获取成功', 'data' => $result_data]; + } + + /* + * 巡乐会抽奖记录 + */ + public function xlh_get_user_record($user_id,$room_id,$page=1,$page_size=12){ + $where = []; + $where['a.gift_bag_id'] = 13; + $where['a.user_id'] = $user_id; + $list = db('vs_gift_bag_receive_pan_log') + ->alias('a') + ->join('vs_room_pan_xlh b','b.id = a.parent_id','left') + ->join('vs_gift c','c.gid = a.gift_id','left') + ->field('a.gift_id,a.num as count,a.createtime,c.gift_name as gift_name,c.base_image') + ->where($where) + ->order('a.createtime desc') + ->page($page,$page_size) + ->select(); + foreach ($list as &$v){ + $v['createtime'] = date('Y-m-d H:i:s',$v['createtime']); + } + return ['code' => 1, 'msg' => '成功', 'data' => $list]; + } + + /* + * 巡乐会榜单 + */ + public function xlh_ranking($room_id,$page=1,$page_size=12){ + $where = []; + $where['a.gift_bag_id'] = 13; + $where['e.is_world_show'] = 1; + $list = db('vs_gift_bag_receive_pan_log') + ->alias('a') + ->join('vs_room_pan_xlh b','b.id = a.parent_id','left') + ->join('vs_gift c','c.gid = a.gift_id','left') + ->join('fa_user d','d.id = a.user_id','left') + ->join('vs_gift_bag_detail e','e.foreign_id = a.gift_id','left') + ->field('a.gift_id,a.num as count,a.createtime,c.gift_name,c.base_image,d.nickname') + ->where($where) + ->order('a.createtime desc') + ->page($page,$page_size) + ->select(); + foreach ($list as &$v){ + $v['createtime'] = date('Y-m-d H:i:s',$v['createtime']); + } + return ['code' => 1, 'msg' => '成功', 'data' => $list]; + } + + /* + * 获取用户当前房间的巡乐会信息 + */ + public function get_user_xlh_info($room_id){ + $gift_bag_id = 13; + $xlh_box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find(); + $xlh_ext = json_decode($xlh_box['ext'],true); + $xlh_data = db('vs_room_pan_xlh')->where(["send_time"=>0,"end_time"=>[">",time()]])->field('id,room_id,periods,end_time')->order('periods desc')->find(); + //寻乐会状态 + $xlh_status = 0; + // 状态 + $xlh_periods_num = Cache::get("xlh_periods_num") ?? 0; + if($xlh_periods_num >= $xlh_ext['open_condition']['start_num']){ + $xlh_status = 1;//状态 1:巡乐会开始 2:即将开始 0:等待开始 + } elseif($xlh_periods_num >= $xlh_ext['open_condition']['waiting_start_num'] && $xlh_periods_num < $xlh_ext['open_condition']['start_num']){ + $xlh_status = 2;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始 + }else{ + $xlh_status = 0;//未开始 + } + return [ + 'activities_name' => $xlh_box['name'], + 'icon' => null, + 'xlh_status'=>$xlh_status, + 'end_time'=>$xlh_data['end_time'] ?? 0, + ]; + } + + /* + * 巡乐会榜单 + * + */ + public function xlh_ranking_list($room_id,$page=1,$page_size=12){ + $gift_bag_id = 13; + $xlh_box = db::name('vs_gift_bag')->where('id',$gift_bag_id)->find(); + $xlh_ext = json_decode($xlh_box['ext'],true); + $pan_xlh = db::name('vs_room_pan_xlh') + ->order('id desc') + ->page($page,$page_size) + ->select(); + $list = []; + foreach ($pan_xlh as $key=>$value){ + $list[$key]['periods'] = "第".$value['periods']."期"; + if(!empty($value['user_id'])){ + $list[$key]['nickname'] = db::name('user')->where(['id'=>$value['user_id']])->value('nickname'); + }else{ + $list[$key]['nickname'] = "无"; + } + if(!empty($value['gift_id'])){ + $gift_data = db::name('vs_gift')->field('gift_name,base_image')->where(['gid'=>$value['gift_id']])->find(); + $list[$key]['gift_name'] = 'x '.$value['num'].' '.$gift_data['gift_name']; + $list[$key]['base_image'] = $gift_data['base_image']??""; + }else{ + $gift_data = db::name('vs_gift')->field('gift_name,base_image')->where(['gid'=>$xlh_ext['locking_condition']['locking_gift_id']])->find(); + $list[$key]['gift_name'] = 'x 0 '.$gift_data['gift_name']; + $list[$key]['base_image'] = $gift_data['base_image']??""; + } + $list[$key]['createtime'] = $value['send_time'] ? date('Y-m-d H:i:s',$value['send_time']) : '' ; + } + return [ + 'code' => 1, + 'msg' => '成功', + 'data' => $list + ]; + } + +} diff --git a/application/api/model/BlindBoxTurntableGiftDraw.php b/application/api/model/BlindBoxTurntableGiftDraw.php new file mode 100644 index 0000000..07bb322 --- /dev/null +++ b/application/api/model/BlindBoxTurntableGiftDraw.php @@ -0,0 +1,1603 @@ +redis = new Redis(); + // 连接到Redis服务器 + $this->redis->connect(config('redis.host'), config('redis.port')); // 根据实际配置调整主机和端口 + // 选择数据库1 + $this->redis->select(1); + } catch (\Exception $e) { + Log::record('Redis连接失败: ' . $e->getMessage(), 'error'); + $this->redis = null; + } + } + + /** + * 重构后的抽奖方法 - 优化响应速度 + */ + public function draw_gift($gift_bag_id, $user_id, $gift_user_ids, $num = 1, $room_id = 0, $heart_id = 0, $auction_id = 0) + { + try { + // 1. 验证参数并提前处理错误 + $validationResult = $this->validateDrawParameters($gift_bag_id, $user_id, $gift_user_ids, $room_id); + if ($validationResult !== true) { + return $validationResult; + } + + // 2. 预加载必要数据 + $loadResult = $this->loadDrawData($gift_bag_id, $user_id, $room_id,$num,$gift_user_ids); + if ($loadResult['code'] !== 1) { + return $loadResult; + } + ['bag_data' => $bag_data, 'room' => $room, 'xlh_ext' => $xlh_ext] = $loadResult['data']; + + // 3. 预计算抽奖结果 + $precomputeResult = $this->precomputeDrawResults( + $bag_data, + $room, + $gift_user_ids, + $num, + $room_id + ); + if ($precomputeResult['code'] !== 1) { + return $precomputeResult; + } + $precomputedResults = $precomputeResult['data']['results']; + $availableGiftss = $precomputeResult['data']['availableGifts']; + $currentXlhPeriodsNum = $precomputeResult['data']['current_xlh_periods_num']; + $xlhIsPiaoPing = $precomputeResult['data']['xlh_is_piao_ping']; + $expectedCount = count(explode(',', $gift_user_ids)) * $num; + if(count($precomputedResults) != $expectedCount){ + // 记录错误到Redis + $this->recordDrawErrorToRedis($expectedCount, count($precomputedResults), $room_id, $user_id, $gift_bag_id, $num, $gift_user_ids, $precomputedResults); + return ['code' => 0, 'msg' => '网络加载失败,请重试!', 'data' => null]; + } + // 4. 执行抽奖事务(核心操作) + $transactionResult = $this->executeDrawTransaction( + $bag_data, + $user_id, + $room_id, + $num, + $precomputedResults, + $availableGiftss, + $gift_user_ids, + $heart_id, + $auction_id + ); + if ($transactionResult['code'] !== 1) { + return $transactionResult; + } + $boxTurntableLog = $transactionResult['data']['log_id']; + $giftCounts = $transactionResult['data']['gift_counts']; + + // 5. 处理后续操作(非事务性操作) + $this->handlePostDrawOperations( + $precomputedResults, + $boxTurntableLog, + $room_id, + $xlh_ext, + $xlhIsPiaoPing, + $currentXlhPeriodsNum, + $room, + $user_id + ); + + // 6. 构建并返回结果 + return $this->buildDrawResult($boxTurntableLog, $giftCounts); + + } catch (\Exception $e) { + $key = 'blind_box_draw_errors_' . date('Y-m-d-H-i-s'); + $this->redis->setex($key, 86400 * 7, $e->getMessage()); + return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null]; + } + + } + /** + * 验证抽奖参数 + */ + private function validateDrawParameters($gift_bag_id, $user_id, $gift_user_ids, $room_id) + { + // 提前验证收礼人 + $toarray = explode(',', $gift_user_ids); + if (in_array($user_id, $toarray)) { + return ['code' => 0, 'msg' => "收礼人不能包含自己", 'data' => null]; + } + + // 验证房间ID + if (empty($room_id)) { + return ['code' => 0, 'msg' => '房间ID不能为空', 'data' => null]; + } + + // 验证用户ID + if (empty($user_id)) { + return ['code' => 0, 'msg' => '用户ID不能为空', 'data' => null]; + } + + // 验证盲盒ID + if (empty($gift_bag_id)) { + return ['code' => 0, 'msg' => '盲盒ID不能为空', 'data' => null]; + } + + return true; + } + /** + * 预加载必要数据 + */ + private function loadDrawData($gift_bag_id, $user_id, $room_id,$num,$gift_user_ids) + { + // 1. 合并查询盲盒配置和礼物信息 + $bag_data = db::name("vs_gift_bag") + ->alias('bag') + ->join('vs_gift gift', 'gift.gid = JSON_UNQUOTE(JSON_EXTRACT(bag.ext, "$.gift_id"))', 'LEFT') + ->field('bag.id,bag.name,bag.ext,gift.gid as gift_id,gift.gift_price') + ->where('bag.id', $gift_bag_id) + ->find(); + + if (!$bag_data || !$bag_data['gift_price']) { + return ['code' => 0, 'msg' => '盲盒配置不存在或盲盒礼物不存在', 'data' => null]; + } + + // 2. 获取房间信息 + $room = db::name('vs_room') + ->field('id,room_name,xlh_periods,xlh_periods_num,is_open_blind_box_turntable') + ->where(['id' => $room_id]) + ->find(); + + if (!$room) { + return ['code' => 0, 'msg' => '房间不存在', 'data' => null]; + } + + if ($room['is_open_blind_box_turntable'] != 1) { + return ['code' => 0, 'msg' => '该房间未开启盲盒转盘', 'data' => null]; + } + + // 3. 检查用户金币 + $user_waller = db::name('user_wallet') + ->where(['user_id' => $user_id]) + ->find(); + + if (!$user_waller) { + return ['code' => 0, 'msg' => '用户钱包不存在', 'data' => null]; + } + if ($user_waller['coin'] < $bag_data['gift_price'] * $num * count(explode(',', $gift_user_ids))) { + return ['code' => 0, 'msg' => '用户金币不足', 'data' => null]; + } + // 4. 获取巡乐会配置(使用缓存) + $xlh_ext = $this->getCachedXlhConfig(); + + return [ + 'code' => 1, + 'msg' => '数据加载成功', + 'data' => [ + 'bag_data' => $bag_data, + 'room' => $room, + 'xlh_ext' => $xlh_ext, + 'user_waller' => $user_waller + ] + ]; + } + /** + * 预计算抽奖结果 + */ + private function precomputeDrawResults($bag_data, $room, $gift_user_ids, $num, $room_id) + { + $toarray = explode(',', $gift_user_ids); + $ext = json_decode($bag_data['ext'], true); + $xlh_ext = $this->getCachedXlhConfig(); + $xlh_is_piao_ping = 0; + $current_xlh_periods_num = $room['xlh_periods_num']; + + // 1. 计算奖池信息 + $poolInfo = $this->calculatePoolInfo($bag_data['id'], $room_id); + if ($poolInfo['code'] !== 1) { + return $poolInfo; + } + $totalQuantity = $poolInfo['data']['total_quantity']; + $totalRemaining = $poolInfo['data']['total_remaining']; + $periods = $poolInfo['data']['periods']; + $totalDrawTimes = $poolInfo['data']['total_draw_times']; + + // 2. 获取可用礼物 + $availableGifts = $this->getAvailableGifts($bag_data['id'], $room_id, $totalDrawTimes); + if (empty($availableGifts)) { + $availableGifts = $this->resetPoolAndReload($bag_data['id'], $room_id, $periods + 1, 0); + if (empty($availableGifts)) { + throw new \Exception('重置奖池后仍无可用礼物'); + } + } + + // 3. 预加载礼物信息(减少后续查询) + $giftInfoMap = $this->preloadGiftInfo($availableGifts); + + // 4. 处理奖池重置逻辑 + $needGiftNum = count($toarray) * $num; + $remaining_available_gifts=[]; + if ($totalRemaining - $needGiftNum <= 0) { + $remaining_available_gifts = $availableGifts; + $availableGifts = $this->resetPoolAndReload($bag_data['id'], $room_id, $periods + 1, 0); + if (empty($availableGifts)) { + throw new \Exception('重置奖池后仍无可用礼物'); + } + $totalDrawTimes = 0; + $num = abs($totalRemaining - $num); + } + + // 5. 使用Alias Method预计算抽奖结果(O(1)复杂度) + $precomputedResults = $this->precomputeResultsWithAliasMethod( + $toarray, + $num, + $availableGifts, + $giftInfoMap, + $totalDrawTimes, + $periods, + $current_xlh_periods_num, + $xlh_ext, + $bag_data['id'], + $room_id, + $remaining_available_gifts + ); + if (empty($precomputedResults['precomputedResults'])) { + throw new \Exception('预计算抽奖结果失败'); + } + + return [ + 'code' => 1, + 'msg' => '预计算成功', + 'data' => [ + 'results' => $precomputedResults['precomputedResults'], + 'current_xlh_periods_num' => $current_xlh_periods_num, + 'xlh_is_piao_ping' => $xlh_is_piao_ping, + 'availableGifts' => $precomputedResults['precomputedResultss'], + ] + ]; + } + + /** + * 使用Alias Method预计算抽奖结果(O(1)复杂度) + */ + private function precomputeResultsWithAliasMethod( + $toarray, + $num, + $availableGifts, + $giftInfoMap, + &$totalDrawTimes, + &$periods, + &$currentXlhPeriodsNum, + $xlhExt, + $giftBagId, + $roomId, + $remaining_available_gifts + ) { + //计算$remaining_available_gifts 里面 remaining_number 的累加 + $remaining_num = 0; + foreach ($remaining_available_gifts as $key=>$value) { + $remaining_num += $value['remaining_number']; + } + if($remaining_num > $num){ + $availableGifts = $remaining_available_gifts; + $remaining_available_gifts = []; + } + $precomputedResults = []; + $precomputedResultss = []; + $giftBagIdToGift = []; + + // 构建Alias表 + $aliasTable = $this->buildAliasTable($availableGifts); + $remaining_num = 0; + foreach ($toarray as $giftUserId) { + if (!empty($remaining_available_gifts)) { + foreach ($remaining_available_gifts as $key=>$value) { + $remaining_num += $value['remaining_number']; + $gift = $giftInfoMap[$value['foreign_id']] ?? null; + for ($j = 0; $j < $value['remaining_number']; $j++) { + $precomputedResults[] = [ + 'gift_user_id' => $giftUserId, + 'gift_bag_detail' => $value, + 'gift' => $gift, + 'draw_times' => $totalDrawTimes, + 'periods' => $periods, + 'j' => $j, + ]; + $totalDrawTimes++; + $currentXlhPeriodsNum++; + + } + unset($remaining_available_gifts[$key]); + } + $numm = $num; + }else{ + $numm = $num+$remaining_num; + } + for ($i = 0; $i < $numm; $i++) { + // 使用Alias Method选择礼物(O(1)复杂度) + $selectedGift = $this->selectGiftWithAliasMethod($aliasTable); + if (!$selectedGift) { + return []; + } + + // 获取礼物信息(从预加载的map中获取,避免查询) + $giftId = $selectedGift['foreign_id']; + $gift = $giftInfoMap[$giftId] ?? null; +// if (!$gift) { +// continue; +// } + + $precomputedResults[] = [ + 'gift_user_id' => $giftUserId, + 'gift_bag_detail' => $selectedGift, + 'gift' => $gift, + 'draw_times' => $totalDrawTimes, + 'periods' => $periods, + 'i' => $i, + ]; + $precomputedResultss[] = [ + 'gift_user_id' => $giftUserId, + 'gift_bag_detail' => $selectedGift, + 'gift' => $gift, + 'draw_times' => $totalDrawTimes, + 'periods' => $periods, + 'i' => $i, + ]; + + $totalDrawTimes++; + $currentXlhPeriodsNum++; + + // 更新Alias表(模拟库存减少) + $this->updateAliasTable($aliasTable, $selectedGift['id']); + + // 检查巡乐会状态 + if (!empty($xlhExt) && $xlhExt['inlet_bag_id'] == $giftBagId) { + if ($currentXlhPeriodsNum == $xlhExt['open_condition']['waiting_start_num']) { + $xlh_is_piao_ping = 1; + } + if ($currentXlhPeriodsNum == $xlhExt['open_condition']['start_num']) { + $xlh_is_piao_ping = 2; + } + } + } + } + + return ['precomputedResults' => $precomputedResults, 'precomputedResultss' => $precomputedResultss]; + } + + /** + * 构建Alias表(O(n)复杂度,只执行一次) + */ + private function buildAliasTable($gifts) + { + $n = count($gifts); + if ($n === 0) return null; + + $totalRemaining = array_sum(array_column($gifts, 'remaining_number')); + if ($totalRemaining <= 0) return null; + + // 初始化Alias表 + $small = []; + $large = []; + $prob = []; + $alias = []; + $indexMap = []; + + // 归一化概率并填充索引映射 + foreach ($gifts as $i => $gift) { + $indexMap[$i] = $gift; + $prob[$i] = $gift['remaining_number'] * $n / $totalRemaining; + if ($prob[$i] < 1.0) { + $small[] = $i; + } else { + $large[] = $i; + } + } + + // 构建Alias表 + while (!empty($small) && !empty($large)) { + $s = array_pop($small); + $l = array_pop($large); + $alias[$s] = $l; + $prob[$l] = ($prob[$l] + $prob[$s]) - 1.0; + + if ($prob[$l] < 1.0) { + $small[] = $l; + } else { + $large[] = $l; + } + } + + return [ + 'n' => $n, + 'prob' => $prob, + 'alias' => $alias, + 'index_map' => $indexMap, + 'gifts' => $gifts + ]; + } + + /** + * 使用Alias Method选择礼物(O(1)复杂度) + */ + private function selectGiftWithAliasMethod($aliasTable) + { + if (!$aliasTable) return null; + + $n = $aliasTable['n']; + $k = mt_rand(0, $n - 1); + + // 随机选择 + if (mt_rand() / mt_getrandmax() < $aliasTable['prob'][$k]) { + return $aliasTable['index_map'][$k]; + } else { + return $aliasTable['index_map'][$aliasTable['alias'][$k]] ?? null; + } + } + + /** + * 更新Alias表(模拟库存减少) + */ + private function updateAliasTable(&$aliasTable, $giftId) + { + // 查找礼物在Alias表中的位置 + $gifts = &$aliasTable['gifts']; + $indexMap = &$aliasTable['index_map']; + + foreach ($gifts as &$gift) { + if ($gift['id'] == $giftId) { + $gift['remaining_number']--; + break; + } + } + + // 重新构建Alias表(当剩余数量变化较大时) + // 这里可以根据实际情况调整重建频率 + $totalRemaining = array_sum(array_column($gifts, 'remaining_number')); + if ($totalRemaining <= 0) { + $aliasTable = null; + } + } + /** + * 执行抽奖事务(核心操作) + */ + private function executeDrawTransaction($bag_data, $user_id, $room_id, $num, $precomputedResults,$availableGiftss,$gift_user_ids,$heart_id,$auction_id) + { + $gift_user_num = count(explode(',', $gift_user_ids)); //人数 + $bagGiftPrice = $bag_data['gift_price'] * $num * $gift_user_num; + + db::startTrans(); + try { + // 1. 创建抽奖记录 + $boxTurntableLog = db::name('vs_blind_box_turntable_log')->insertGetId([ + 'user_id' => $user_id, + 'gift_bag_id' => $bag_data['id'], + 'num' => $num, + 'room_id' => $room_id, + 'bag_price' => $bag_data['gift_price'], + 'createtime' => time() + ]); + + if (!$boxTurntableLog) { + throw new \Exception('添加盲盒转盘记录失败'); + } + + // 2. 批量更新库存 + $this->batchUpdateGiftInventory($availableGiftss, $room_id); + + // 3. 批量插入礼包发放记录 + $this->batchInsertGiftBagReceiveLog($user_id, $boxTurntableLog, $bag_data, $room_id, $precomputedResults); + + // 4. 扣除用户金币 + $this->deductUserCoins($user_id, $bagGiftPrice, $room_id); + + //发送礼物 + $result = $this->sendGiftsToRecipients($precomputedResults, $room_id,$user_id,$heart_id,$auction_id); + if (isset($result['code']) && $result['code'] !== 1) { + throw new \Exception($result['msg']); + } + + db::commit(); + + // 5. 统计礼物数量 + $giftCounts = $this->countGifts($precomputedResults); + + return [ + 'code' => 1, + 'msg' => '事务执行成功', + 'data' => [ + 'log_id' => $boxTurntableLog, + 'gift_counts' => $giftCounts + ] + ]; + } catch (\Exception $e) { + db::rollback(); + return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null]; + } + } + + /** + * 批量更新礼物库存 + */ + private function batchUpdateGiftInventory($precomputedResults, $room_id) + { + // 按礼物ID分组统计需要减少的数量 + $inventoryUpdates = []; + foreach ($precomputedResults as $result) { + $giftId = $result['gift_bag_detail']['gift_bag_detail_id']; + $inventoryUpdates[$giftId] = ($inventoryUpdates[$giftId] ?? 0) + 1; + } + + // 批量更新 + foreach ($inventoryUpdates as $giftId => $count) { + $ret = db::name("vs_room_pan") + ->where([ + 'room_id' => $room_id, + 'gift_bag_detail_id' => $giftId, +// 'remaining_number' => ['>=', $count] + ]) + ->setDec('remaining_number', $count); + + if (!$ret) { + Log::record('巡乐会更新礼物剩余数量: ' . $room_id."【数据】".var_export($precomputedResults, true),"info"); + throw new \Exception('更新礼物剩余数量失败'); + } + } + } + + /** + * 批量插入礼包发放记录 + */ + private function batchInsertGiftBagReceiveLog($user_id, $boxTurntableLog, $bag_data, $room_id, $precomputedResults) + { + $batchInsertData = []; + + foreach ($precomputedResults as $result) { + $batchInsertData[] = [ + 'user_id' => $user_id, + 'gift_user_id' => $result['gift_user_id'], + 'parent_id' => $boxTurntableLog, + 'gift_bag_id' => $bag_data['id'], + 'gift_id' => $result['gift_bag_detail']['foreign_id'], + 'periods' => $result['periods'], + 'room_id' => $room_id, + 'gift_price' => $result['gift']['gift_price'], + 'bag_price' => $bag_data['gift_price'], + 'createtime' => time() + ]; + } + + if (!empty($batchInsertData)) { + $insertResult = db::name("vs_gift_bag_receive_log")->insertAll($batchInsertData); + if (!$insertResult) { + throw new \Exception('插入礼包发放记录失败'); + } + } + } + + /** + * 扣除用户金币 + */ + private function deductUserCoins($user_id, $bagGiftPrice, $room_id) + { + $walletUpdate = model('GiveGift')->change_user_cion_or_earnings_log( + $user_id, + $bagGiftPrice, + $room_id, + 1, + 10, + '盲盒转盘抽奖消耗' + ); + + if (!$walletUpdate) { + throw new \Exception('扣除用户金币失败'); + } + + $userLevel = model('Level')->user_level_data_update( + $user_id, + $bagGiftPrice, + 1, + $room_id + ); + + if (!$userLevel) { + throw new \Exception('用户等级更新失败'); + } + } + /** + * 处理抽奖后的后续操作(非事务性) + */ + private function handlePostDrawOperations( + $precomputedResults, + $boxTurntableLog, + $room_id, + $xlh_ext, + $xlhIsPiaoPing, + $currentXlhPeriodsNum, + $room, + $user_id + ) { + // 1. 批量插入盲盒转盘结果记录 + $this->batchInsertBlindBoxResults($precomputedResults, $boxTurntableLog, $room_id); + + // 2. 发送礼物给接收者 (已前置) +// $this->sendGiftsToRecipients($precomputedResults, $room_id,$user_id); + + // 3. 处理巡乐会相关操作 + if (!empty($xlh_ext) && $xlh_ext['inlet_bag_id'] == $precomputedResults[0]['gift_bag_detail']['gift_bag_id']) { + $this->handleXlhOperations($room_id, $xlh_ext, $xlhIsPiaoPing, $currentXlhPeriodsNum,$room); + } + } + + /** + * 批量插入盲盒转盘结果记录 + */ + private function batchInsertBlindBoxResults($precomputedResults, $boxTurntableLog, $room_id) + { + // 统计每个用户每个礼物的数量 + $giftUserCounts = []; + foreach ($precomputedResults as $result) { + $key = $result['gift_user_id'] . '_' . $result['gift_bag_detail']['foreign_id']; + if (!isset($giftUserCounts[$key])) { + $giftUserCounts[$key] = [ + 'gift_user_id' => $result['gift_user_id'], + 'gift_id' => $result['gift_bag_detail']['foreign_id'], + 'count' => 0, + 'gift_price' => $result['gift']['gift_price'] + ]; + } + $giftUserCounts[$key]['count']++; + } + + // 批量插入 + $batchInsertData = []; + foreach ($giftUserCounts as $userGift) { + $batchInsertData[] = [ + 'tid' => $boxTurntableLog, + 'gift_user_id' => $userGift['gift_user_id'], + 'gift_id' => $userGift['gift_id'], + 'count' => $userGift['count'], + 'gift_price' => $userGift['gift_price'], + 'all_gift_price' => $userGift['gift_price'] * $userGift['count'], + 'createtime' => time(), + 'heart_id' => 0 + ]; + } + + if (!empty($batchInsertData)) { + db::name('vs_blind_box_turntable_results_log')->insertAll($batchInsertData); + } + } + + /** + * 发送礼物给接收者 + */ + private function sendGiftsToRecipients($precomputedResults, $room_id,$user_id,$heart_id,$auction_id) + { + // 统计每个用户每个礼物的数量 + $giftUserCounts = []; + foreach ($precomputedResults as $result) { + $key = $result['gift_user_id'] . '_' . $result['gift_bag_detail']['foreign_id']; + if (!isset($giftUserCounts[$key])) { + $giftUserCounts[$key] = [ + 'gift_user_id' => $result['gift_user_id'], + 'gift_id' => $result['gift_bag_detail']['foreign_id'], + 'count' => 0, + 'gift_price' => $result['gift']['gift_price'] + ]; + } + $giftUserCounts[$key]['count']++; + } + + // 批量发送礼物 + foreach ($giftUserCounts as $userGift) { + if($userGift['count'] > 9){ //防止礼物超发,礼物超10个则不发送 + continue; + } + $giveGiftExt = [ + 'gift_id' => $userGift['gift_id'], + 'count' => $userGift['count'], + 'gift_price' => $userGift['gift_price'], + 'all_gift_price' => $userGift['gift_price'] * $userGift['count'], + 'is_draw_gift' => 1 + ]; + if(!empty($auction_id)){ + model('RoomAuction')->room_auction_join($auction_id,$user_id,$userGift['gift_id'],$userGift['count'],2,$giveGiftExt); + }else{ + $res = model('Room')->room_gift( + $user_id, + $userGift['gift_user_id'], + $userGift['gift_id'], + $userGift['count'], + 1, + $room_id, + 0, + $heart_id, + $giveGiftExt + ); + } + + if (isset($res) && $res['code'] != 1) { + Log::record('发送礼物失败: ' . $res['msg'] . $userGift['gift_user_id'], "info"); + return ['code' => 0, 'msg' => $res['msg'], 'data' => null]; + } + } + return ['code' => 1, 'msg' => '发送礼物成功', 'data' => null]; + } + + /** + * 处理巡乐会相关操作 + */ + private function handleXlhOperations($room_id, $xlh_ext, $xlhIsPiaoPing, $currentXlhPeriodsNum,$room) + { + if($room['xlh_periods_num'] < $xlh_ext['open_condition']['waiting_start_num'] && $currentXlhPeriodsNum >= $xlh_ext['open_condition']['waiting_start_num']){ + $xlhIsPiaoPing = 1; + } + if($room['xlh_periods_num'] < $xlh_ext['open_condition']['start_num'] && $currentXlhPeriodsNum >= $xlh_ext['open_condition']['start_num']){ + $xlhIsPiaoPing = 2; + } + + // 更新房间巡乐会次数 + db::name("vs_room")->where('id', $room_id)->update([ + 'xlh_periods_num' => $currentXlhPeriodsNum + ]); + + // 处理飘屏 + if ($xlhIsPiaoPing == 1 || $xlhIsPiaoPing == 2) { + $this->handleXlhPiaoPing($room_id, $xlh_ext, $xlhIsPiaoPing,$room); + } + + // 更新巡乐会状态并推送 + $this->updateAndPushXlhStatus($room_id, $xlh_ext, $currentXlhPeriodsNum); + } + private function handleXlhPiaoPing($room_id, $xlh_ext, $xlhIsPiaoPing,$room){ + if($xlhIsPiaoPing == 1){ + // 即将开始推送飘屏 + $text = $room['room_name']."的巡乐会即将开始..."; + // 推送礼物横幅 + $push = new Push(UID, $room_id); + $text_list_new = [ + 'text' => $text, + 'room_id' => $room_id, + 'from_type' => 1 + ]; + $push->xunlehui($text_list_new); + } + if($xlhIsPiaoPing == 2){ + // 正式开始推送飘屏 + $text = $room['room_name']."已正式开启巡乐会游戏..."; + // 推送礼物横幅 + $push = new Push(UID, $room_id); + $text_list_new = [ + 'text' => $text, + 'room_id' => $room_id, + 'from_type' => 2 + ]; + $push->xunlehui($text_list_new); + // 巡乐会正式开始 + $this_xlh_periods = db::name('vs_room')->where('id',$room_id)->value('xlh_periods'); + $pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([ + 'room_id' => $room_id, + 'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'], + 'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'], + 'periods' => $this_xlh_periods+1, + 'num' => 0, + 'end_time' => time() + $xlh_ext['locking_time']['end_time'] * 60, + 'createtime' => time() + ]); + if(!$pan_xlh_id){ + return ['code' => 0, 'msg' => '创建巡乐会失败!', 'data' => []]; + } + db::name("vs_room")->where('id',$room_id)->setInc('xlh_periods');//修改巡乐会期数 + } + } + private function updateAndPushXlhStatus($room_id, $xlh_ext, $currentXlhPeriodsNum){ + $xlh['waiting_start_num'] = $xlh_ext['open_condition']['waiting_start_num'];//等待开奖次数 + $xlh['start_num'] = $xlh_ext['open_condition']['start_num'];//开始开奖次数 + // 当前抽奖次数 + $xlh['current_num'] = $currentXlhPeriodsNum; + $xlh['end_time'] = 0; + // 状态 + if($xlh['current_num'] >= $xlh_ext['open_condition']['start_num']){ + $xlh['status'] = 1;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始 + //查询巡乐会信息 + $pan_xlh = db::name('vs_room_pan_xlh')->where('room_id',$room_id)->order('id desc')->find(); + $xlh['end_time'] = $pan_xlh['end_time'] ?? 0; + } elseif($xlh['current_num'] >= $xlh_ext['open_condition']['waiting_start_num'] && $xlh['current_num'] < $xlh_ext['open_condition']['start_num']){ + $xlh['status'] = 2;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始 + + }else{ + $xlh['status'] = 0; + } + // 推送 + $text = [ + 'xlh_data' => $xlh, + 'text' => "" + ]; + // 聊天室推送系统消息 + model('Chat')->sendMsg(1056,$room_id,$text); + } + /** + * 统计礼物数量 + */ + private function countGifts($precomputedResults) + { + $giftCounts = []; + foreach ($precomputedResults as $result) { + $giftId = $result['gift_bag_detail']['foreign_id']; + if (!isset($giftCounts[$giftId])) { + $giftCounts[$giftId] = [ + 'gift_id' => $giftId, + 'count' => 0, + 'gift_price' => $result['gift']['gift_price'] + ]; + } + $giftCounts[$giftId]['count']++; + } + return $giftCounts; + } + + /** + * 构建抽奖结果 + */ + private function buildDrawResult($boxTurntableLog, $giftCounts) + { + $resultList = []; + foreach ($giftCounts as $gift) { + $resultList[] = [ + 'gift_id' => $gift['gift_id'], + 'count' => $gift['count'] + ]; + } + + return [ + 'code' => 1, + 'msg' => '成功', + 'data' => [ + 'blind_box_turntable_id' => $boxTurntableLog, + 'reslut_list' => $resultList + ] + ]; + } + /** + * 计算奖池信息 + */ + private function calculatePoolInfo($gift_bag_id, $room_id) + { + $roomPanInfo = db::name("vs_gift_bag_detail") + ->alias('a') + ->join('vs_room_pan b', 'b.gift_bag_detail_id = a.id AND b.room_id = ' . $room_id) + ->where(['a.gift_bag_id' => $gift_bag_id]) + ->field('SUM(a.quantity) as total_quantity, SUM(b.remaining_number) as total_remaining, MAX(b.periods) as periods') + ->find(); + + $totalQuantity = $roomPanInfo['total_quantity'] ?: 0; + $totalRemaining = $roomPanInfo['total_remaining'] ?: 0; + $periods = $roomPanInfo['periods'] ?: 0; + $totalDrawTimes = max(0, $totalQuantity - $totalRemaining); + + return [ + 'code' => 1, + 'msg' => '计算成功', + 'data' => [ + 'total_quantity' => $totalQuantity, + 'total_remaining' => $totalRemaining, + 'periods' => $periods, + 'total_draw_times' => $totalDrawTimes + ] + ]; + } + + /** + * 获取可用礼物 + */ + private function getAvailableGifts($gift_bag_id, $room_id, $total_draw_times) + { + $where = [ + 'a.gift_bag_id' => $gift_bag_id, + 'a.quantity' => ['>', 0], + 'b.remaining_number' => ['>', 0], + 'b.room_id' => $room_id, + 'a.weight' => ['<=', $total_draw_times], + ]; + + return db::name("vs_gift_bag_detail") + ->field('b.id,a.quantity,b.remaining_number,a.weight,a.foreign_id,a.gift_bag_id,b.gift_bag_detail_id') + ->alias('a') + ->join('vs_room_pan b', 'b.gift_bag_detail_id = a.id', 'left') + ->where($where) + ->select(); + } + + /** + * 预加载礼物信息 + */ + private function preloadGiftInfo($available_gifts) + { + $giftIds = array_unique(array_column($available_gifts, 'foreign_id')); + if (empty($giftIds)) return []; + + $gifts = db::name('vs_gift') + ->where('gid', 'in', $giftIds) + ->select(); + + return array_column($gifts, null, 'gid'); + } + + /** + * 重置奖池并重新加载 + */ + private function resetPoolAndReload($gift_bag_id, $room_id, $periods, $total_draw_times) + { + $this->reset_gift_pool($room_id, $gift_bag_id, $periods); + return $this->getAvailableGifts($gift_bag_id, $room_id, $total_draw_times); + } + + /** + * 获取缓存的巡乐会配置 + */ + private function getCachedXlhConfig() { + $cacheKey = "xlh_config_13"; + $ext = Cache::get($cacheKey); + if (!$ext) { + $bag_data = db::name("vs_gift_bag") + ->field('id,name,ext,periods') + ->where('id', 13) + ->find(); + if (!$bag_data) { + return []; + } + $ext = json_decode($bag_data['ext'], true); + $ext['gift_bag_name'] = $bag_data['name']; + Cache::set($cacheKey, $ext, 3600); // 缓存1小时 + } + return $ext; + } + + /** + * 重置奖池 + * @param int $room_id 房间ID + * @param int $gift_bag_id 礼物包ID + * @param int $periods 期数 + */ + private function reset_gift_pool($room_id, $gift_bag_id, $periods,$remaining_available_gifts=[]) { + $room_pan = db::name("vs_room_pan") + ->where(['room_id'=>$room_id,'gift_bag_id'=>$gift_bag_id]) + ->select(); + // 重置奖池中所有礼物数量 + db::name("vs_room_pan") + ->where(['room_id'=>$room_id,'gift_bag_id'=>$gift_bag_id]) + ->update([ + 'remaining_number' => db::raw('(SELECT quantity FROM fa_vs_gift_bag_detail WHERE id = fa_vs_room_pan.gift_bag_detail_id)'), + 'periods' => $periods + ]); + //防止并发,上把如果件数小于0,则加上 + foreach ($room_pan as $pan) { + if($pan['remaining_number']<0){ + db::name("vs_room_pan")->where('id', $pan['id'])->setInc('remaining_number', $pan['remaining_number']); + } + } + //补充上把礼物有剩余 + if(!empty($remaining_available_gifts)){ + foreach ($remaining_available_gifts as $gift) { + db::name("vs_room_pan")->where('id', $gift['id'])->setInc('remaining_number',$gift['remaining_number']); + } + } + + // 更新总期数 + db::name("vs_gift_bag") + ->where('id', $gift_bag_id) + ->setInc('periods'); + } + + /* + * 获取可用礼物用于预计算 + */ + private function get_available_gifts_for_precompute($gift_bag_id, $room_id, $total_draw_times) { + $where = [ + 'a.gift_bag_id' => $gift_bag_id, + 'a.quantity' => ['>',0], + 'b.remaining_number' => ['>',0], + 'b.room_id' => $room_id, + 'a.weight' => ['<=', $total_draw_times], + ]; + + return db::name("vs_gift_bag_detail") + ->field('a.id,a.quantity,b.remaining_number,a.weight,a.foreign_id') + ->alias('a') + ->join('vs_room_pan b','b.gift_bag_detail_id = a.id','left') + ->where($where) + ->select(); + } + + /* + * 预计算单次抽奖结果 + */ + private function precompute_single_draw($gift_bag_id, $room_id, $available_gifts, $last_periods_remaining = []) { + // 生成缓存键 + $available_cache_key = 'blindbox_available_gifts_' . $gift_bag_id . '_' . $room_id; + $last_remaining_cache_key = 'blindbox_last_remaining_' . $gift_bag_id . '_' . $room_id; + + // 保证有可用礼物 + if (empty($available_gifts)) { + return false; + } + + $last_remaining_all = array_sum(array_column($last_periods_remaining, 'remaining_number')); + if ($last_remaining_all == 0) { + $last_periods_remaining = []; + cache($last_remaining_cache_key, null); + } + + $last_periods_remaining_flag = 0; + if (!empty($last_periods_remaining)) { + $available_gifts = $last_periods_remaining; + $last_periods_remaining_flag = 1; + } + + // 循环尝试直到抽中有效礼物 + $max_attempts = 5; // 最大尝试次数,防止无限循环 + $attempt = 0; + $selected_gift = null; + + while ($attempt < $max_attempts && !$selected_gift) { + // 实现加权随机算法:剩余数量越多,被抽中的概率越大 + $remaining = 0; + foreach ($available_gifts as $gift) { + $remaining += $gift['remaining_number']; + } + + if ($remaining <= 0) { + break; // 如果没有剩余数量,跳出循环 + } + + $rand_value = mt_rand(1, $remaining); + $current_sum = 0; + + foreach ($available_gifts as $gift) { + if ($gift['remaining_number'] <= 0) { + continue; + } + $current_sum += $gift['remaining_number']; + if ($rand_value <= $current_sum) { + $selected_gift = $gift; + break; + } + } + $attempt++; + } + if (!$selected_gift) { + return false; + } + + // 获取开出礼物的信息 + $gift = db::name("vs_gift") + ->where(['gid' => $selected_gift['foreign_id']]) + ->find(); + + if (!$gift) { + return false; + } + + // 操作缓存,减去缓存中对应数据数量 + foreach ($available_gifts as &$available_gifts_gift) { + if ($selected_gift['id'] == $available_gifts_gift['id']) { + $available_gifts_gift['remaining_number'] -= 1; + } + } + if ($available_gifts_gift['remaining_number'] == 0) { + unset($available_gifts_gift); + } + + if ($last_periods_remaining_flag == 1) { + // 操作上一轮奖池 + cache($last_remaining_cache_key, $available_gifts); + } else { + cache($available_cache_key, $available_gifts); + } + + return [ + 'gift_bag_detail' => $selected_gift, + 'gift' => $gift + ]; + } + + /* + * 寻乐会抽奖----------------------------------------------------------------------------------------- + */ + /* + * 巡乐会抽奖 + */ + /* + * 巡乐会抽奖(优化版) + */ + public function xlh_draw_gift($user_id, $num, $room_id) + { + $gift_bag_id = 13; + + // 1. 获取并缓存盲盒配置 + $cacheKey = "xlh_config_{$gift_bag_id}"; + $ext = $this->getCachedXlhConfig(); + + // 2. 检查用户金币和房间状态 + $bag_gift_price = $ext['xlh_box_price'] * $num; + $user_waller = db::name('user_wallet')->where(['user_id' => $user_id])->find(); + if (!$user_waller || $user_waller['coin'] < $bag_gift_price) { + return ['code' => 0, 'msg' => '用户金币不足', 'data' => null]; + } + + $room = db::name('vs_room') + ->field('id,room_name,is_open_blind_box_turntable,xlh_periods') + ->where(['id' => $room_id]) + ->find(); + if (!$room || $room['is_open_blind_box_turntable'] != 1) { + return ['code' => 0, 'msg' => '该房间未开启盲盒转盘', 'data' => null]; + } + + // 3. 检查巡乐会状态 + $pan_xlh = db::name('vs_room_pan_xlh') + ->where(['room_id' => $room_id, 'periods' => $room['xlh_periods']]) + ->find(); + if (empty($pan_xlh)) { + return ['code' => 0, 'msg' => '未开始', 'data' => null]; + } + if ($pan_xlh['end_time'] <= time()) { + return ['code' => 0, 'msg' => '本轮已结束', 'data' => null]; + } + if ($pan_xlh['send_time'] != 0) { + return ['code' => 0, 'msg' => '本轮已结束,礼物已发放', 'data' => null]; + } + + // 4. 预加载必要数据 + $room_pan_data = db::name("vs_room_pan")->alias('a') + ->join('vs_gift_bag_detail b', 'a.gift_bag_detail_id = b.id') + ->where(['a.room_id' => $room_id, 'a.gift_bag_id' => $gift_bag_id]) + ->field('a.id, a.gift_bag_detail_id, a.remaining_number, a.periods,b.weight,b.foreign_id') + ->select(); + + if (empty($room_pan_data)) { + return ['code' => 0, 'msg' => '当前房间未配置抽奖礼物,请联系管理员', 'data' => []]; + } + + // 计算总数量和剩余数量 + $total_quantity = db::name("vs_gift_bag_detail") + ->where(['gift_bag_id' => $gift_bag_id]) + ->sum('quantity'); + + $total_remaining = array_sum(array_column($room_pan_data, 'remaining_number')); + $total_draw_times = $total_quantity - $total_remaining; + + if ($total_draw_times < 0) $total_draw_times = 0; + + // 5. 获取可用礼物(提前过滤无效礼物) + $available_gifts = []; + foreach ($room_pan_data as $pan) { + if ($pan['remaining_number'] > 0 && $pan['weight'] <= $total_draw_times) { + $available_gifts[] = $pan; + } + } + if (empty($available_gifts)) { + // 移除已无剩余数量的礼物 + $remaining_available_gifts = array_filter($room_pan_data, function($gift) { + return $gift['remaining_number'] > 0; + }); + $this->reset_gift_pool($room_id, $gift_bag_id, $room_pan_data[0]['periods'] + 1,$remaining_available_gifts); +// return ['code' => 0, 'msg' => '当前盲盒无可用礼物', 'data' => []]; + } + + // 6. 预计算抽奖结果 + $drawn_gifts = []; // 用于统计抽中结果 + $main_prize_updates = []; // 用于记录主奖品更新 + $is_zhong_jiang = 0; + $pan_xlh_num = $pan_xlh['num']; + + // 批量处理配置 + $batch_size = min(10, $num); // 每批次处理10次 + $total_processed = 0; + $all_results = []; // 存储所有抽奖结果 + + while ($total_processed < $num) { + $current_batch = min($batch_size, $num - $total_processed); + db::startTrans(); + try { + // 批量扣除金币(只在第一次事务中处理) + if ($total_processed == 0) { + $wallet_update = model('GiveGift')->change_user_cion_or_earnings_log( + $user_id, + $bag_gift_price, + $room_id, + 1, + 10, + $ext['gift_bag_name'].'抽奖消耗' + ); + if (!$wallet_update) { + throw new \Exception('扣除用户金币失败'); + } + + $user_level = model('Level')->user_level_data_update( + $user_id, + $bag_gift_price, + 1, + $room_id + ); + if (!$user_level) { + throw new \Exception('用户等级更新失败'); + } + } + + // 处理当前批次的抽奖 + $inventory_updates = []; // 用于记录库存变化 + $gift_details_map = []; // 礼物详情映射 + $remaining_available_gifts = $available_gifts; + for ($i = 0; $i < $current_batch; $i++) { + // 从可用礼物中选择 + $selected_gift = $this->selectGiftFromAvailable($available_gifts); + if (!$selected_gift) { + throw new \Exception('预计算抽奖失败'); + } + + // 记录库存变化 + $inventory_updates[$selected_gift['id']] = + ($inventory_updates[$selected_gift['id']] ?? 0) + 1; + + // 记录抽中结果 + $gift_id = $selected_gift['foreign_id']; + $drawn_gifts[$gift_id] = ($drawn_gifts[$gift_id] ?? 0) + 1; + + // 处理主奖品 + if ($gift_id == $ext['locking_condition']['selected_gift_id']) { + $pan_xlh_num++; + $main_prize_updates[] = [ + 'num' => $pan_xlh_num, + 'user_id' => $user_id, + 'gift_id' => $gift_id + ]; + + // 计算延长时间 + $add_end_time = $this->calculateEndTime($pan_xlh_num, $ext, $room_id); + $end_time = time() + $add_end_time; + + // 记录主奖品更新 + $main_prize_updates[count($main_prize_updates) - 1]['end_time'] = $end_time; + } + + // 记录完整结果 + $all_results[] = [ + 'gift_id' => $gift_id, + 'gift_detail_id' => $selected_gift['id'], + 'gift_bag_detail' => $selected_gift + ]; + + // 更新可用礼物缓存 + foreach ($available_gifts as &$gift) { + if ($gift['id'] == $selected_gift['id']) { + $gift['remaining_number']--; + break; + } + } + unset($gift); + + // 移除已无剩余数量的礼物 + $available_gifts = array_filter($available_gifts, function($gift) { + return $gift['remaining_number'] > 0; + }); + + // 检查是否需要重置奖池 + $total_remaining = array_sum(array_column($available_gifts, 'remaining_number')); + if ($total_remaining <= 0 && $total_processed + $i + 1 < $num) { + $this->reset_gift_pool($room_id, $gift_bag_id, $room_pan_data[0]['periods'] + 1,$remaining_available_gifts); + $available_gifts = $this->reloadGiftPool($room_id, $gift_bag_id); + if (empty($available_gifts)) { + throw new \Exception('重置奖池后仍无可用礼物'); + } + } + } + + // 批量更新库存 + foreach ($inventory_updates as $detail_id => $count) { + db::name("vs_room_pan") + ->where(['id' => $detail_id]) + ->setDec('remaining_number', $count); + } + + // 处理主奖品更新 + if (!empty($main_prize_updates)) { + $last_update = end($main_prize_updates); + db::name('vs_room_pan_xlh')->where('id', $pan_xlh['id'])->update([ + 'user_id' => $last_update['user_id'], + 'pay_price' => $ext['xlh_box_price'], + 'locking_gift_id' => $last_update['gift_id'], + 'num' => $last_update['num'], + 'end_time' => $last_update['end_time'], + 'updatetime' => time() + ]); + + db::name('vs_room_pan_xlh_log')->insert([ + 'xlh_id' => $pan_xlh['id'], + 'user_id' => $last_update['user_id'], + 'num' => $last_update['num'], + 'locking_end_time' => $last_update['end_time'], + 'createtime' => time() + ]); + $is_zhong_jiang = 1; + } + + db::commit(); + $total_processed += $current_batch; + } catch (\Exception $e) { + db::rollback(); + Log::record('巡乐会抽奖失败: ' . $e->getMessage(),"infos"); + return ['code' => 0, 'msg' => "抽奖中,请稍等...", 'data' => null]; + } + } + + // 7. 批量处理结果记录 + try { + db::startTrans(); + if(count($drawn_gifts) > $num){ + Log::record('巡乐会抽奖失败-数量超限: ' . count($drawn_gifts),"infos"); + return ['code' => 0, 'msg' => "抽奖中,请稍等...", 'data' => null]; + } + // 批量插入礼包发放记录 + $gift_records = []; + $periods = $room_pan_data[0]['periods'] ?? 0; + foreach ($drawn_gifts as $gift_id => $count) { + $gift_records[] = [ + 'user_id' => $user_id, + 'parent_id' => $pan_xlh['id'], + 'gift_bag_id' => $gift_bag_id, + 'gift_id' => $gift_id, + 'periods' => $periods, + 'room_id' => $room_id, + 'num' => $count, + 'gift_price' => $this->getGiftPrice($gift_id), + 'bag_price' => $ext['xlh_box_price'], + 'createtime' => time() + ]; + } + + if (!empty($gift_records)) { + db::name("vs_gift_bag_receive_log")->insertAll($gift_records); + } + + // 批量处理用户礼物包 + foreach ($drawn_gifts as $gift_id => $count) { + $res = model('UserGiftPack')->change_user_gift_pack( + $user_id, + $gift_id, + $count, + model('UserGiftPack')::XLH_DRAW_GIFT_GET, + "巡乐会抽奖所得" + ); + if ($res['code'] != 1) { + throw new \Exception($res['msg']); + } + } + + // 添加活动记录 + Db::name('vs_activities_receive')->insert([ + 'user_id' => $user_id, + 'activities_id' => 6, + 'room_id' => $room_id, + 'createtime' => time(), + 'updatetime' => time() + ]); + + db::commit(); + } catch (\Exception $e) { + db::rollback(); + return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null]; + } + + // 8. 处理推送消息 + if ($is_zhong_jiang == 1) { + $this->handlePrizeNotification($user_id,$gift_id, $room_id, $pan_xlh_num, $end_time, $room['room_name'],$ext['locking_condition']['locking_gift_id']); + } + + // 9. 构建返回结果 + return $this->buildResult($drawn_gifts); + } + + /** + * 巡乐会抽奖-从可用礼物中选择一个 + */ + private function selectGiftFromAvailable(array &$available_gifts) + { + $remaining = array_sum(array_column($available_gifts, 'remaining_number')); + if ($remaining <= 0) { + return null; + } + // 循环尝试直到抽中有效礼物 + $max_attempts = 5; // 最大尝试次数,防止无限循环 + $attempt = 0; + $selected_gift = null; + while ($attempt < $max_attempts && !$selected_gift) { + $rand_value = mt_rand(1, $remaining); + $current_sum = 0; + + foreach ($available_gifts as $gift) { + if ($gift['remaining_number'] <= 0) { + continue; + } + $current_sum += $gift['remaining_number']; + if ($rand_value <= $current_sum) { + $selected_gift = $gift; + break; + } + } + $attempt++; + } + + return $selected_gift; + } + + /** + * 巡乐会抽奖-计算结束时间 + */ + private function calculateEndTime($pan_xlh_num, $ext, $room_id) + { + $cache_key = 'selected_gift_id_' . $room_id . $ext['locking_condition']['selected_gift_id']; + + if ($pan_xlh_num <= 1) { + $add_end_time = $ext['locking_time']['tow_no_locking_time'] * 60; + Cache::set($cache_key, $add_end_time, $add_end_time); + return $add_end_time; + } + + if (Cache::get($cache_key)) { + $erci_xlh_num = Cache::get($cache_key); + $add_end_time = $erci_xlh_num - $ext['locking_time']['next_time'] * 60; + Cache::set($cache_key, $add_end_time, $add_end_time); + } else { + $add_end_time = ($ext['locking_time']['tow_no_locking_time'] - $ext['locking_time']['next_time']) * 60; + } + + if ($add_end_time <= 30) { + Cache::set($cache_key, 30, 30); + return 30; + } + + return $add_end_time; + } + + /** + * 巡乐会抽奖-重新加载奖池 + */ + private function reloadGiftPool($room_id, $gift_bag_id) + { + return db::name("vs_room_pan")->alias('a') + ->join('vs_gift_bag_detail b', 'a.gift_bag_detail_id = b.id') + ->where(['a.room_id' => $room_id, 'a.gift_bag_id' => $gift_bag_id]) + ->field('a.id, a.gift_bag_detail_id, a.remaining_number, a.periods,b.weight,b.foreign_id') + ->select(); + } + + /** + * 巡乐会抽奖-获取礼物价格 + */ + private function getGiftPrice($gift_id) + { + static $gift_prices = []; + + if (!isset($gift_prices[$gift_id])) { + $gift_prices[$gift_id] = db::name("vs_gift") + ->where(['gid' => $gift_id]) + ->value('gift_price'); + } + + return $gift_prices[$gift_id]; + } + + /** + * 巡乐会抽奖-处理中奖通知 + */ + private function handlePrizeNotification($user_id,$gift_id, $room_id, $pan_xlh_num, $end_time, $room_name,$locking_gift_id) + { + $FromUserInfo = db::name('user')->field('nickname,avatar')->where(['id' => $user_id])->find(); + $gift_info = db::name('vs_gift')->field('gift_name')->where(['gid' => $gift_id])->find(); + $locking_gift = db::name('vs_gift')->field('gift_name')->where(['gid' => $locking_gift_id])->find(); + //锁定礼物 + + $text = [ + 'gift_num' => $pan_xlh_num, + 'FromUserInfo' => $FromUserInfo, + 'end_time' => $end_time, + 'text' => $FromUserInfo['nickname'] . ' 在 ' . $room_name . ' 房间巡乐会中 获得' . $gift_info['gift_name'] . '礼物 x 1' + ]; + + model('Chat')->sendMsg(1057, $room_id, $text); + + //推送礼物横幅 + $text = $FromUserInfo['nickname'] . ' 在 ' . $room_name.' 房间巡乐会锁定礼物'.$locking_gift['gift_name'].' x ' .$pan_xlh_num ; + $push = new Push(0, $room_id); + $text_list_new = [ + 'text' => $text, + 'room_id' => $room_id, + 'from_type' => 1 + ]; + $push->xunlehui($text_list_new); + } + + /** + * 巡乐会抽奖-构建返回结果 + */ + private function buildResult($drawn_gifts) + { + $result_list = []; + $gift_info_cache = []; + + foreach ($drawn_gifts as $gift_id => $count) { + if (!isset($gift_info_cache[$gift_id])) { + $gift_info = db::name('vs_gift') + ->where(['gid' => $gift_id]) + ->find(); + $gift_info_cache[$gift_id] = $gift_info; + } else { + $gift_info = $gift_info_cache[$gift_id]; + } + + $result_list[] = [ + 'gift_id' => $gift_id, + 'gift_name' => $gift_info['gift_name'], + 'base_image' => $gift_info['base_image'], + 'gift_price' => $gift_info['gift_price'], + 'count' => $count, + ]; + } + + // 按价格降序排序 + usort($result_list, function($a, $b) { + return $b['gift_price'] <=> $a['gift_price']; + }); + + return ['code' => 1, 'msg' => '成功', 'data' => $result_list]; + } + //错误日志记录------------------------------------------------------- + /** + * 记录抽奖错误日志到Redis + */ + private function recordDrawErrorToRedis($expectedCount, $actualCount, $room_id, $user_id, $gift_bag_id, $num, $gift_user_ids, $precomputedResults) + { + // 检查Redis连接是否可用 + if (!$this->redis) { + Log::record('Redis连接不可用,无法记录错误日志', 'error'); + return; + } + + try { + $errorData = [ + 'timestamp' => time(), + 'expected_count' => $expectedCount, + 'actual_count' => $actualCount, + 'room_id' => $room_id, + 'user_id' => $user_id, + 'gift_bag_id' => $gift_bag_id, + 'num' => $num, + 'gift_user_ids' => $gift_user_ids, + 'precomputed_results_count' => count($precomputedResults), + 'precomputed_results' => $precomputedResults, + 'error_type' => 'draw_count_mismatch' + ]; + + // 使用正确的Redis方法存储数据 + $key = 'blind_box_draw_errors_' . date('Y-m-d-H-i-s'); + $this->redis->setex($key, 86400 * 7, json_encode($errorData)); + } catch (\Exception $e) { + Log::record('Redis操作失败: ' . $e->getMessage(), 'error'); + } + } +} diff --git a/application/api/model/BlindBoxTurntableGiftDrawWorld.php b/application/api/model/BlindBoxTurntableGiftDrawWorld.php new file mode 100644 index 0000000..87c42c2 --- /dev/null +++ b/application/api/model/BlindBoxTurntableGiftDrawWorld.php @@ -0,0 +1,1528 @@ +redis = new Redis(); + // 连接到Redis服务器 + $this->redis->connect(config('redis.host'), config('redis.port')); // 根据实际配置调整主机和端口 + // 选择数据库1 + $this->redis->select(1); + } catch (\Exception $e) { + Log::record('Redis连接失败: ' . $e->getMessage(), 'error'); + $this->redis = null; + } + } + + /** + * 重构后的抽奖方法 - 优化响应速度 + */ + public function draw_gift($gift_bag_id, $user_id, $gift_user_ids, $num = 1, $room_id = 0, $heart_id = 0,$auction_id = 0) + { + // 最大重试次数 + $maxRetries = 3; + for ($attempt = 0; $attempt < $maxRetries; $attempt++) { + try { + // 1. 验证参数并提前处理错误 + $validationResult = $this->validateDrawParameters($gift_bag_id, $user_id, $gift_user_ids); + if ($validationResult !== true) { + return $validationResult; + } + // 2. 预加载必要数据 + $loadResult = $this->loadDrawData($gift_bag_id, $user_id, $room_id, $num, $gift_user_ids); + if ($loadResult['code'] !== 1) { + return $loadResult; + } + // 添加以下检查以防止 null 错误 + if (!isset($loadResult['data']) || !is_array($loadResult['data'])) { + return ['code' => 0, 'msg' => '数据加载失败', 'data' => null]; + } + ['bag_data' => $bag_data, 'room' => $room, 'xlh_ext' => $xlh_ext] = $loadResult['data']; + + // 3. 预计算抽奖结果 + $precomputeResult = $this->precomputeDrawResults( + $bag_data, + $gift_user_ids, + $num + ); + if ($precomputeResult['code'] !== 1) { + return $precomputeResult; + } + $precomputedResults = $precomputeResult['data']['results']; + $availableGiftss = $precomputeResult['data']['availableGifts']; + $currentXlhPeriodsNum = $precomputeResult['data']['current_xlh_periods_num']; + $addcurrentXlhPeriodsNum = $precomputeResult['data']['addcurrentXlhPeriodsNum']; + $expectedCount = count(explode(',', $gift_user_ids)) * $num; + if (count($precomputedResults) != $expectedCount) { + // 记录错误到Redis + $this->recordDrawErrorToRedis($expectedCount, count($precomputedResults), $room_id, $user_id, $gift_bag_id, $num, $gift_user_ids, $precomputedResults); + return ['code' => 0, 'msg' => '网络加载失败,请重试!', 'data' => null]; + } + // 4. 执行抽奖事务(核心操作) + $transactionResult = $this->executeDrawTransaction( + $bag_data, + $user_id, + $room_id, + $num, + $precomputedResults, + $availableGiftss, + $gift_user_ids, + $heart_id, + $auction_id + ); + if ($transactionResult['code'] !== 1) { + return $transactionResult; + } + $boxTurntableLog = $transactionResult['data']['log_id']; + $giftCounts = $transactionResult['data']['gift_counts']; + + // 5. 处理后续操作(非事务性操作) + $this->handlePostDrawOperations( + $precomputedResults, + $boxTurntableLog, + $room_id, + $xlh_ext, + $currentXlhPeriodsNum, + $addcurrentXlhPeriodsNum, + $room + ); + + // 6. 构建并返回结果 + return $this->buildDrawResult($boxTurntableLog, $giftCounts); + + } catch (\Exception $e) { + $key = 'blind_box_draw_errors_' . date('Y-m-d-H-i-s'); + $errorData = [ + 'gift_bag_id' => $gift_bag_id, + 'user_id' => $user_id, + 'gift_user_ids' => $gift_user_ids, + 'num' => $num, + 'room_id' => $room_id, + 'heart_id' => $heart_id, + 'auction_id' => $auction_id, + ]; + if ($this->redis) { + $this->redis->setex($key, 86400 * 7, $e->getMessage() . ' ' . json_encode($errorData)); + } + // 如果是死锁且还有重试机会 + if (strpos($e->getMessage(), 'Deadlock') !== false && $attempt < $maxRetries - 1) { + // 随机延迟后重试 + usleep(rand(50000, 200000)); // 50-200ms + continue; + } + return ['code' => 0, 'msg' => "网络加载失败,请重试!", 'data' => null]; + } + } + } + /** + * 验证抽奖参数 + */ + private function validateDrawParameters($gift_bag_id, $user_id, $gift_user_ids) + { + // 提前验证收礼人 + $toarray = explode(',', $gift_user_ids); + if (in_array($user_id, $toarray)) { + return ['code' => 0, 'msg' => "收礼人不能包含自己", 'data' => null]; + } + // 验证用户ID + if (empty($user_id)) { + return ['code' => 0, 'msg' => '用户ID不能为空', 'data' => null]; + } + // 验证盲盒ID + if (empty($gift_bag_id)) { + return ['code' => 0, 'msg' => '盲盒ID不能为空', 'data' => null]; + } + return true; + } + /** + * 预加载必要数据 + */ + private function loadDrawData($gift_bag_id, $user_id, $room_id,$num,$gift_user_ids) + { + // 1. 合并查询盲盒配置和礼物信息 + $bag_data = db::name("vs_gift_bag") + ->alias('bag') + ->join('vs_gift gift', 'gift.gid = JSON_UNQUOTE(JSON_EXTRACT(bag.ext, "$.gift_id"))', 'LEFT') + ->field('bag.id,bag.name,bag.ext,gift.gid as gift_id,gift.gift_price') + ->where('bag.id', $gift_bag_id) + ->find(); + if (!$bag_data || !is_array($bag_data) || !isset($bag_data['gift_price'])) { + return ['code' => 0, 'msg' => '盲盒配置不存在或盲盒礼物不存在', 'data' => null]; + } + // 2. 获取房间信息 + $room = db::name('vs_room') + ->field('id,room_name,xlh_periods,xlh_periods_num,is_open_blind_box_turntable') + ->where(['id' => $room_id]) + ->find(); + + if (!$room) { + return ['code' => 0, 'msg' => '房间不存在', 'data' => null]; + } + + // 3. 检查用户金币 + $user_waller = db::name('user_wallet') + ->where(['user_id' => $user_id]) + ->find(); + + if (!$user_waller) { + return ['code' => 0, 'msg' => '用户钱包不存在', 'data' => null]; + } + if ($user_waller['coin'] < $bag_data['gift_price'] * $num * count(explode(',', $gift_user_ids))) { + return ['code' => 0, 'msg' => '用户金币不足', 'data' => null]; + } + // 4. 获取巡乐会配置(使用缓存) + $xlh_ext = $this->getCachedXlhConfig(); + + return [ + 'code' => 1, + 'msg' => '数据加载成功', + 'data' => [ + 'bag_data' => $bag_data, + 'room' => $room, + 'xlh_ext' => $xlh_ext, +// 'user_waller' => $user_waller + ] + ]; + } + /** + * 预计算抽奖结果 + */ + private function precomputeDrawResults($bag_data, $gift_user_ids, $num) + { + $toarray = explode(',', $gift_user_ids); + // 1. 计算奖池信息 + $poolInfo = $this->calculatePoolInfo($bag_data['id']); + if ($poolInfo['code'] !== 1) { + return $poolInfo; + } + $totalRemaining = $poolInfo['data']['total_remaining'];//奖池剩余数量 + $periods = $poolInfo['data']['periods']; //奖池期数 + $totalDrawTimes = $poolInfo['data']['total_draw_times']; //总抽奖次数 + + // 2. 获取可用礼物 + $availableGifts = $this->getAvailableGifts($bag_data['id'], $totalDrawTimes); + if (empty($availableGifts)) { + $availableGifts = $this->resetPoolAndReload($bag_data['id']); //重置奖池并重新加载 + if (empty($availableGifts)) { + throw new \Exception('重置奖池后仍无可用礼物'); + } + $totalDrawTimes = 0;//总抽奖次数重置 + } + // 在处理奖池重置逻辑之前添加检查 + if (!is_array($availableGifts)) { + throw new \Exception('可用礼物数据格式错误'); + } + // 3. 预加载礼物信息(减少后续查询) + $giftInfoMap = $this->preloadGiftInfo($availableGifts); + + // 4. 处理奖池重置逻辑 - 优化版本 + $needGiftNum = count($toarray) * $num; //总需要的礼物数 + $remaining_available_gifts = []; + $remainingGiftCount = array_sum(array_column($availableGifts, 'remaining_number')); + + if ($remainingGiftCount < $needGiftNum) { + // 如果当前奖池礼物不足以满足需求 + // 保存当前剩余礼物作为上期剩余 + $remaining_available_gifts = $availableGifts; + + // 重置奖池 + $availableGifts = $this->resetPoolAndReload($bag_data['id']); + if (empty($availableGifts)) { + throw new \Exception('重置奖池后仍无可用礼物'); + } + $totalDrawTimes = 0; // 总抽奖次数重置 + } + $current_xlh_periods_num = $this->getCachedXlhPeriodsNum("get"); + // 5. 使用Alias Method预计算抽奖结果(O(1)复杂度) + $precomputedResults = $this->precomputeResultsWithAliasMethod( + $toarray, + $num, + $availableGifts, + $giftInfoMap, + $totalDrawTimes, + $periods, + $current_xlh_periods_num, + $remaining_available_gifts + ); + if (empty($precomputedResults['precomputedResults'])) { + throw new \Exception('预计算抽奖结果失败'); + } + + return [ + 'code' => 1, + 'msg' => '预计算成功', + 'data' => [ + 'results' => $precomputedResults['precomputedResults'], + 'current_xlh_periods_num' => $current_xlh_periods_num, + 'availableGifts' => $precomputedResults['precomputedResultss'], + 'addcurrentXlhPeriodsNum' => $precomputedResults['addcurrentXlhPeriodsNum'], + ] + ]; + } + + /** + * 使用Alias Method预计算抽奖结果(O(1)复杂度) + */ + private function precomputeResultsWithAliasMethod( + $toarray, + $num, + $availableGifts, + $giftInfoMap, + &$totalDrawTimes, + &$periods, + &$currentXlhPeriodsNum, + $remaining_available_gifts + ) { + if (!is_array($toarray) || !is_array($availableGifts) || !is_array($giftInfoMap)) { + throw new \Exception('预计算参数格式错误'); + } + $precomputedResults = []; + $precomputedResultss = []; + $addcurrentXlhPeriodsNum = 0; + + // 计算上期剩余礼物总数 + $remainingGiftCount = array_sum(array_column($remaining_available_gifts, 'remaining_number')); + $needGiftNum = count($toarray) * $num; + $newGiftsNeeded = max(0, $needGiftNum - $remainingGiftCount); // 计算还需要多少礼物从新奖池中抽取 + + // 先从上期剩余礼物中分配 + if (!empty($remaining_available_gifts)) { + $aliasTableForRemaining = $this->buildAliasTable($remaining_available_gifts); + + foreach ($toarray as $giftUserId) { + // 为每个用户先分配上期剩余礼物 + $userRemainingAllocation = floor($remainingGiftCount / count($toarray)); + if (count($toarray) > 0) { // 防止除零错误 + $extraGifts = $remainingGiftCount % count($toarray); + if (array_search($giftUserId, $toarray) < $extraGifts) { + $userRemainingAllocation++; + } + } + + for ($i = 0; $i < $userRemainingAllocation; $i++) { + $selectedGift = $this->selectGiftWithAliasMethod($aliasTableForRemaining); + if ($selectedGift) { + $gift = $giftInfoMap[$selectedGift['foreign_id']]; + $precomputedResults[] = [ + 'gift_user_id' => $giftUserId, + 'gift_bag_detail' => $selectedGift, + 'gift' => $gift, + 'draw_times' => $totalDrawTimes, + 'periods' => $periods, + ]; + $precomputedResultss[] = [ + 'gift_user_id' => $giftUserId, + 'gift_bag_detail' => $selectedGift, + 'gift' => $gift, + 'draw_times' => $totalDrawTimes, + 'periods' => $periods, + ]; + $totalDrawTimes++; + $currentXlhPeriodsNum++; + $addcurrentXlhPeriodsNum++; + + // 更新Alias表 + $this->updateAliasTable($aliasTableForRemaining, $selectedGift['id']); + } + } + } + } + + // 再从新奖池中分配剩余所需礼物 + if ($newGiftsNeeded > 0 && !empty($availableGifts)) { + $aliasTableForNew = $this->buildAliasTable($availableGifts); + + foreach ($toarray as $giftUserId) { + // 计算每个用户需要从新奖池获得的礼物数量 + $userNewAllocation = floor($newGiftsNeeded / count($toarray)); + if (count($toarray) > 0) { + $extraGifts = $newGiftsNeeded % count($toarray); + if (array_search($giftUserId, $toarray) < $extraGifts) { + $userNewAllocation++; + } + } + + for ($i = 0; $i < $userNewAllocation; $i++) { + $selectedGift = $this->selectGiftWithAliasMethod($aliasTableForNew); + if ($selectedGift) { + $giftInfoMap = $this->preloadGiftInfo($availableGifts); + $gift = $giftInfoMap[$selectedGift['foreign_id']]; + if($gift) + $precomputedResults[] = [ + 'gift_user_id' => $giftUserId, + 'gift_bag_detail' => $selectedGift, + 'gift' => $gift, + 'draw_times' => $totalDrawTimes, + 'periods' => $periods, + ]; + $precomputedResultss[] = [ + 'gift_user_id' => $giftUserId, + 'gift_bag_detail' => $selectedGift, + 'gift' => $gift, + 'draw_times' => $totalDrawTimes, + 'periods' => $periods, + ]; + $totalDrawTimes++; + $currentXlhPeriodsNum++; + $addcurrentXlhPeriodsNum++; + + // 更新Alias表 + $this->updateAliasTable($aliasTableForNew, $selectedGift['id']); + } + } + } + } + + return ['precomputedResults' => $precomputedResults, 'precomputedResultss' => $precomputedResultss, 'addcurrentXlhPeriodsNum' => $addcurrentXlhPeriodsNum]; + } + + /** + * 构建Alias表(O(n)复杂度,只执行一次) + */ + private function buildAliasTable($gifts) + { + $n = count($gifts); + if ($n === 0) return null; + + $totalRemaining = array_sum(array_column($gifts, 'remaining_number')); + if ($totalRemaining <= 0) return null; + + // 初始化Alias表 + $small = []; + $large = []; + $prob = []; + $alias = []; + $indexMap = []; + + // 归一化概率并填充索引映射 + foreach ($gifts as $i => $gift) { + $indexMap[$i] = $gift; + $prob[$i] = $gift['remaining_number'] * $n / $totalRemaining; + if ($prob[$i] < 1.0) { + $small[] = $i; + } else { + $large[] = $i; + } + } + + // 构建Alias表 + while (!empty($small) && !empty($large)) { + $s = array_pop($small); + $l = array_pop($large); + $alias[$s] = $l; + $prob[$l] = ($prob[$l] + $prob[$s]) - 1.0; + + if ($prob[$l] < 1.0) { + $small[] = $l; + } else { + $large[] = $l; + } + } + + return [ + 'n' => $n, + 'prob' => $prob, + 'alias' => $alias, + 'index_map' => $indexMap, + 'gifts' => $gifts + ]; + } + + /** + * 使用Alias Method选择礼物(O(1)复杂度) + */ + private function selectGiftWithAliasMethod($aliasTable) + { + if (!$aliasTable) return null; + + $n = $aliasTable['n']; + $k = mt_rand(0, $n - 1); + + // 随机选择 + if (mt_rand() / mt_getrandmax() < $aliasTable['prob'][$k]) { + return $aliasTable['index_map'][$k]; + } else { + return $aliasTable['index_map'][$aliasTable['alias'][$k]] ?? null; + } + } + + /** + * 更新Alias表(模拟库存减少) + */ + private function updateAliasTable(&$aliasTable, $giftId) + { + // 查找礼物在Alias表中的位置 + $gifts = &$aliasTable['gifts']; + $indexMap = &$aliasTable['index_map']; + + foreach ($gifts as &$gift) { + if ($gift['id'] == $giftId) { + $gift['remaining_number']--; + break; + } + } + + // 重新构建Alias表(当剩余数量变化较大时) + // 这里可以根据实际情况调整重建频率 + $totalRemaining = array_sum(array_column($gifts, 'remaining_number')); + if ($totalRemaining <= 0) { + $aliasTable = null; + } + } + /** + * 执行抽奖事务(核心操作) + */ + private function executeDrawTransaction($bag_data, $user_id, $room_id, $num, $precomputedResults,$availableGiftss,$gift_user_ids,$heart_id,$auction_id) + { + $gift_user_num = count(explode(',', $gift_user_ids)); //人数 + $bagGiftPrice = $bag_data['gift_price'] * $num * $gift_user_num; + + // 增加重试机制 + $maxRetries = 3; + for ($retry = 0; $retry < $maxRetries; $retry++) { + try { + db::startTrans(); + // 按照固定顺序处理事务步骤 + // 1. 扣除用户金币(优先处理) + $this->deductUserCoins($user_id, $bagGiftPrice, $room_id); + + // 2. 创建抽奖记录 + $boxTurntableLog = db::name('vs_blind_box_turntable_log')->insertGetId([ + 'user_id' => $user_id, + 'gift_bag_id' => $bag_data['id'], + 'num' => $num, + 'room_id' => $room_id, + 'bag_price' => $bag_data['gift_price'], + 'createtime' => time() + ]); + + if (!$boxTurntableLog) { + throw new \Exception('添加盲盒转盘记录失败'); + } + + // 3. 批量更新库存(按ID排序避免死锁) + $this->batchUpdateGiftInventory($availableGiftss, $room_id); + + // 4. 批量插入礼包发放记录 + $this->batchInsertGiftBagReceiveLog($user_id, $boxTurntableLog, $bag_data, $room_id, $precomputedResults); + + // 5. 发送礼物 + $result = $this->sendGiftsToRecipients($precomputedResults, $room_id,$user_id,$heart_id,$auction_id); + if (isset($result['code']) && $result['code'] !== 1) { + throw new \Exception($result['msg']); + } + + db::commit(); + + // 统计礼物数量 + $giftCounts = $this->countGifts($precomputedResults); + + return [ + 'code' => 1, + 'msg' => '事务执行成功', + 'data' => [ + 'log_id' => $boxTurntableLog, + 'gift_counts' => $giftCounts + ] + ]; + } catch (\Exception $e) { + db::rollback(); + // 检查是否是死锁错误 + if (strpos($e->getMessage(), 'Deadlock') !== false && $retry < $maxRetries - 1) { + // 等待随机时间后重试 + usleep(rand(10000, 100000)); // 10-100ms + continue; + } + return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null]; + } + } + return ['code' => 0, 'msg' => '操作超时,请重试', 'data' => null]; + } + + /** + * 批量更新礼物库存 + */ + private function batchUpdateGiftInventory($precomputedResults, $room_id) + { + // 按礼物ID分组统计需要减少的数量 + $inventoryUpdates = []; + foreach ($precomputedResults as $result) { + $giftId = $result['gift_bag_detail']['id']??0; + $inventoryUpdates[$giftId] = ($inventoryUpdates[$giftId] ?? 0) + 1; + } + + // 按ID排序避免死锁 + ksort($inventoryUpdates); + + // 批量更新 + foreach ($inventoryUpdates as $giftId => $count) { + $ret = db::name("vs_gift_bag_detail")->where('id',$giftId) + ->setDec('remaining_number', $count); + if (!$ret) { + Log::record('巡乐会更新礼物剩余数量: ' . $room_id."【数据】".var_export($precomputedResults, true),"info"); + throw new \Exception('更新礼物剩余数量失败'); + } + } + } + + /** + * 批量插入礼包发放记录 + */ + private function batchInsertGiftBagReceiveLog($user_id, $boxTurntableLog, $bag_data, $room_id, $precomputedResults) + { + + $batchInsertData = []; + + foreach ($precomputedResults as $result) { + if(!isset($result['gift']['gift_price'])){ + Log::record('数据报错:'.json_encode($result),"info"); + } + $batchInsertData[] = [ + 'user_id' => $user_id, + 'gift_user_id' => $result['gift_user_id'], + 'parent_id' => $boxTurntableLog, + 'gift_bag_id' => $bag_data['id'], + 'gift_id' => $result['gift_bag_detail']['foreign_id'], + 'periods' => $result['periods'], + 'room_id' => $room_id, + 'gift_price' => $result['gift']['gift_price'], + 'bag_price' => $bag_data['gift_price'], + 'createtime' => time() + ]; + } + + if (!empty($batchInsertData)) { + $insertResult = db::name("vs_gift_bag_receive_pan_log")->insertAll($batchInsertData); + if (!$insertResult) { + throw new \Exception('插入礼包发放记录失败'); + } + } + } + + /** + * 扣除用户金币 + */ + private function deductUserCoins($user_id, $bagGiftPrice, $room_id) + { + // 使用悲观锁查询用户钱包 + $userWallet = db::name('user_wallet') + ->where(['user_id' => $user_id]) + ->find(); + if (!$userWallet || $userWallet['coin'] < $bagGiftPrice) { + throw new \Exception('用户金币不足'); + } + $walletUpdate = model('GiveGift')->change_user_cion_or_earnings_log( + $user_id, + $bagGiftPrice, + $room_id, + 1, + 10, + '盲盒转盘抽奖消耗' + ); + + if (!$walletUpdate) { + throw new \Exception('扣除用户金币失败'); + } + + $userLevel = model('Level')->user_level_data_update( + $user_id, + $bagGiftPrice, + 1, + $room_id + ); + + if (!$userLevel) { + throw new \Exception('用户等级更新失败'); + } + } + /** + * 处理抽奖后的后续操作(非事务性) + */ + private function handlePostDrawOperations( + $precomputedResults, + $boxTurntableLog, + $room_id, + $xlh_ext, + $currentXlhPeriodsNum, + $addcurrentXlhPeriodsNum, + $room + ) { + // 1. 批量插入盲盒转盘结果记录 + $this->batchInsertBlindBoxResults($precomputedResults, $boxTurntableLog); + + // 3. 处理巡乐会相关操作 + if (!empty($xlh_ext) && $xlh_ext['inlet_bag_id'] == $precomputedResults[0]['gift_bag_detail']['gift_bag_id']) { + $this->handleXlhOperations($room_id, $xlh_ext, $currentXlhPeriodsNum,$addcurrentXlhPeriodsNum,$room); + } + } + + /** + * 批量插入盲盒转盘结果记录 + */ + private function batchInsertBlindBoxResults($precomputedResults, $boxTurntableLog) + { + // 统计每个用户每个礼物的数量 + $giftUserCounts = []; + foreach ($precomputedResults as $result) { + $key = $result['gift_user_id'] . '_' . $result['gift_bag_detail']['foreign_id']; + if (!isset($giftUserCounts[$key])) { + $giftUserCounts[$key] = [ + 'gift_user_id' => $result['gift_user_id'], + 'gift_id' => $result['gift_bag_detail']['foreign_id'], + 'count' => 0, + 'gift_price' => $result['gift']['gift_price'] + ]; + } + $giftUserCounts[$key]['count']++; + } + + // 批量插入 + $batchInsertData = []; + foreach ($giftUserCounts as $userGift) { + $batchInsertData[] = [ + 'tid' => $boxTurntableLog, + 'gift_user_id' => $userGift['gift_user_id'], + 'gift_id' => $userGift['gift_id'], + 'count' => $userGift['count'], + 'gift_price' => $userGift['gift_price'], + 'all_gift_price' => $userGift['gift_price'] * $userGift['count'], + 'createtime' => time(), + 'heart_id' => 0 + ]; + } + + if (!empty($batchInsertData)) { + db::name('vs_blind_box_turntable_results_log')->insertAll($batchInsertData); + } + } + + /** + * 发送礼物给接收者 + */ + private function sendGiftsToRecipients($precomputedResults, $room_id,$user_id,$heart_id,$auction_id) + { + // 统计每个用户每个礼物的数量 + $giftUserCounts = []; + foreach ($precomputedResults as $result) { + $key = $result['gift_user_id'] . '_' . $result['gift_bag_detail']['foreign_id']; + if (!isset($giftUserCounts[$key])) { + $giftUserCounts[$key] = [ + 'gift_user_id' => $result['gift_user_id'], + 'gift_id' => $result['gift_bag_detail']['foreign_id'], + 'count' => 0, + 'gift_price' => $result['gift']['gift_price'] + ]; + } + $giftUserCounts[$key]['count']++; + } + + // 批量发送礼物 + foreach ($giftUserCounts as $userGift) { + if($userGift['count'] > 9){ //防止礼物超发,礼物超10个则不发送 + continue; + } + $giveGiftExt = [ + 'gift_id' => $userGift['gift_id'], + 'count' => $userGift['count'], + 'gift_price' => $userGift['gift_price'], + 'all_gift_price' => $userGift['gift_price'] * $userGift['count'], + 'is_draw_gift' => 1 + ]; + if(!empty($auction_id)){ + model('RoomAuction')->room_auction_join($auction_id,$user_id,$userGift['gift_id'],$userGift['count'],2,$giveGiftExt); + }else{ + $res = model('Room')->room_gift( + $user_id, + $userGift['gift_user_id'], + $userGift['gift_id'], + $userGift['count'], + 1, + $room_id, + 0, + $heart_id, + $giveGiftExt + ); + } + if (isset($res) && $res['code'] != 1) { + Log::record('发送礼物失败: ' . $res['msg'] . $userGift['gift_user_id'], "info"); + return ['code' => 0, 'msg' => $res['msg'], 'data' => null]; + } + } + return ['code' => 1, 'msg' => '发送礼物成功', 'data' => null]; + } + + /** + * 处理巡乐会相关操作 + */ + private function handleXlhOperations($room_id, $xlh_ext, $currentXlhPeriodsNum,$addcurrentXlhPeriodsNum,$room) + { + $xlhIsPiaoPing = 0; + $xlhPeriodsNum = $this->getCachedXlhPeriodsNum("get"); + if($xlhPeriodsNum < $xlh_ext['open_condition']['waiting_start_num'] && $currentXlhPeriodsNum >= $xlh_ext['open_condition']['waiting_start_num']){ + $xlhIsPiaoPing = 1; + } + if($xlhPeriodsNum < $xlh_ext['open_condition']['start_num'] && $currentXlhPeriodsNum >= $xlh_ext['open_condition']['start_num']){ + $xlhIsPiaoPing = 2; + } + // 更新房间巡乐会次数 + $this->getCachedXlhPeriodsNum("set",$addcurrentXlhPeriodsNum); + + // 处理飘屏 + if ($xlhIsPiaoPing == 1 || $xlhIsPiaoPing == 2) { + $this->handleXlhPiaoPing($room_id, $xlh_ext, $xlhIsPiaoPing); + } + + $this->updateAndPushXlhStatus($room_id, $xlh_ext, $currentXlhPeriodsNum); + } + private function handleXlhPiaoPing($room_id, $xlh_ext, $xlhIsPiaoPing){ + if($xlhIsPiaoPing == 1){ + // 即将开始推送飘屏 + $text = "巡乐会即将开始..."; + // 推送礼物横幅 + $push = new Push(UID, $room_id); + $text_list_new = [ + 'text' => $text, + 'room_id' => $room_id, + 'from_type' => 101 + ]; + $push->xunlehui($text_list_new); + } + if($xlhIsPiaoPing == 2){ + // 正式开始推送飘屏 + $text = "巡乐会游戏已正式开启..."; + // 推送礼物横幅 + $push = new Push(UID, $room_id); + $text_list_new = [ + 'text' => $text, + 'room_id' => $room_id, + 'from_type' => 102 + ]; + $push->xunlehui($text_list_new); + // 巡乐会正式开始 + $this_xlh_periods = $this->getCachedXlhPeriods('get'); + $pan_xlh_id = db::name('vs_room_pan_xlh')->insertGetId([ + 'room_id' => $room_id, + 'gift_id' => $xlh_ext['locking_condition']['locking_gift_id'], + 'homeowner_gift_id' => $xlh_ext['locking_condition']['give_homeowner_gift_id'], + 'periods' => $this_xlh_periods+1, + 'num' => 0, + 'end_time' => time() + $xlh_ext['locking_time']['end_time'] * 60, + 'createtime' => time() + ]); + if(!$pan_xlh_id){ + return ['code' => 0, 'msg' => '创建巡乐会失败!', 'data' => []]; + } + $this->getCachedXlhPeriods('set', $this_xlh_periods+1);//修改巡乐会期数 + } + } + private function updateAndPushXlhStatus($room_id, $xlh_ext, $currentXlhPeriodsNum){ + $xlh['waiting_start_num'] = $xlh_ext['open_condition']['waiting_start_num'];//等待开奖次数 + $xlh['start_num'] = $xlh_ext['open_condition']['start_num'];//开始开奖次数 + // 当前抽奖次数 + $xlh['current_num'] = $currentXlhPeriodsNum; + $xlh['end_time'] = 0; + // 状态 + if($xlh['current_num'] >= $xlh_ext['open_condition']['start_num']){ + $xlh['status'] = 1;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始 + //查询巡乐会信息 + $pan_xlh = db::name('vs_room_pan_xlh')->where('send_time',0)->order('id desc')->find(); + if(empty($pan_xlh)){ + $this->handleXlhPiaoPing($room_id, $xlh_ext, 2); + $pan_xlh = db::name('vs_room_pan_xlh')->where('send_time',0)->order('id desc')->find(); + } + $xlh['end_time'] = $pan_xlh['end_time'] ?? 0; + } elseif($xlh['current_num'] >= $xlh_ext['open_condition']['waiting_start_num'] && $xlh['current_num'] < $xlh_ext['open_condition']['start_num']){ + $xlh['status'] = 2;//状态 1:巡乐会开始 2:即将开始开始 0:等待开始 + + }else{ + $xlh['status'] = 0; + } + // 推送进度条 + $push = new Push(UID, $room_id); + $text_list_new = [ + 'xlh_data' => $xlh, + 'text' => "", + 'room_id' => $room_id, + 'from_type' => 100 + ]; + $push->xunlehui($text_list_new); + + // 聊天室推送系统消息 + // 推送 +// $text = [ +// 'xlh_data' => $xlh, +// 'text' => "" +// ]; +// model('Chat')->sendMsg(1056,$room_id,$text); + } + /** + * 统计礼物数量 + */ + private function countGifts($precomputedResults) + { + $giftCounts = []; + foreach ($precomputedResults as $result) { + $giftId = $result['gift_bag_detail']['foreign_id']; + if (!isset($giftCounts[$giftId])) { + $giftCounts[$giftId] = [ + 'gift_id' => $giftId, + 'count' => 0, + 'gift_price' => $result['gift']['gift_price'] + ]; + } + $giftCounts[$giftId]['count']++; + } + return $giftCounts; + } + + /** + * 构建抽奖结果 + */ + private function buildDrawResult($boxTurntableLog, $giftCounts) + { + $resultList = []; + foreach ($giftCounts as $gift) { + $resultList[] = [ + 'gift_id' => $gift['gift_id'], + 'count' => $gift['count'] + ]; + } + + return [ + 'code' => 1, + 'msg' => '成功', + 'data' => [ + 'blind_box_turntable_id' => $boxTurntableLog, + 'reslut_list' => $resultList + ] + ]; + } + /** + * 计算奖池信息 + */ + private function calculatePoolInfo($gift_bag_id) + { + $roomPanInfo = db::name("vs_gift_bag_detail") + ->where(['gift_bag_id' => $gift_bag_id]) + ->field('SUM(quantity) as total_quantity, SUM(remaining_number) as total_remaining') + ->find(); + $periods = db::name("vs_gift_bag") + ->where(['id' => $gift_bag_id]) + ->value('periods'); + $totalQuantity = $roomPanInfo['total_quantity'] ?: 0; + $totalRemaining = $roomPanInfo['total_remaining'] ?: 0; + $periods = $periods ?: 0; + $totalDrawTimes = max(0, $totalQuantity - $totalRemaining); //总抽奖次数 + return [ + 'code' => 1, + 'msg' => '计算成功', + 'data' => [ + 'total_quantity' => $totalQuantity, + 'total_remaining' => $totalRemaining, + 'periods' => $periods, + 'total_draw_times' => $totalDrawTimes + ] + ]; + } + + /** + * 获取可用礼物 + * @param $gift_bag_id + * @param $total_draw_times 总抽奖次数 + */ + private function getAvailableGifts($gift_bag_id, $total_draw_times = 0) + { + $where = [ + 'gift_bag_id' => $gift_bag_id, + 'quantity' => ['>', 0], + 'remaining_number' => ['>', 0], + 'weight' => ['<=', $total_draw_times], + ]; + return db::name("vs_gift_bag_detail") + ->field('id,quantity,remaining_number,weight,foreign_id,gift_bag_id') + ->where($where) + ->select(); + } + + /** + * 预加载礼物信息 + */ + private function preloadGiftInfo($available_gifts) + { + $giftIds = array_unique(array_column($available_gifts, 'foreign_id')); + if (empty($giftIds)) return []; + $gifts = db::name('vs_gift') + ->where('gid', 'in', $giftIds) + ->select(); + return array_column($gifts, null, 'gid'); + } + + /** + * 重置奖池并重新加载 + */ + private function resetPoolAndReload($gift_bag_id) + { + $this->reset_gift_pool($gift_bag_id); + return $this->getAvailableGifts($gift_bag_id); + } + + /** + * 获取缓存的巡乐会配置 + */ + private function getCachedXlhConfig() { + $cacheKey = "xlh_config_13"; + $ext = Cache::get($cacheKey); + if (!$ext) { + $bag_data = db::name("vs_gift_bag") + ->field('id,name,ext,periods') + ->where('id', 13) + ->find(); + if (!$bag_data) { + return []; + } + $ext = json_decode($bag_data['ext'], true); + $ext['gift_bag_name'] = $bag_data['name']; + Cache::set($cacheKey, $ext, 3600); // 缓存1小时 + } + return $ext; + } + /** + * 获取缓存的巡乐会开启次数 + */ + private function getCachedXlhPeriodsNum($type="get",$num=1) { + $cacheKey = "xlh_periods_num"; + $xlh_periods_num = Cache::get($cacheKey) ?? 0; + if($type=="set"){ + $xlh_periods_num = $xlh_periods_num + $num; + Cache::set($cacheKey, $xlh_periods_num, 0); + } + return $xlh_periods_num; + } + /** + * 获取缓存的巡乐会期数 + */ + private function getCachedXlhPeriods($type="get",$periods=1) { + $cacheKey = "this_xlh_periods"; + $xlh_periods_num = Cache::get($cacheKey) ?? 0; + if($type=="set"){ + $xlh_periods_num = $periods; + Cache::set($cacheKey, $xlh_periods_num, 0); + } + return $xlh_periods_num; + } + + /** + * 重置奖池 + * @param int $room_id 房间ID + * @param int $gift_bag_id 礼物包ID + */ + private function reset_gift_pool($gift_bag_id,$remaining_available_gifts=[]) { + $bag_detail = db::name("vs_gift_bag_detail")->where('gift_bag_id',$gift_bag_id)->select(); + db::name("vs_gift_bag")->where('id',$gift_bag_id)->setInc('periods'); //更新期数 + db::name("vs_gift_bag_detail")->where('gift_bag_id',$gift_bag_id)->update(['remaining_number'=>db::raw('quantity')]);//重置奖池 + //防止并发,上把如果件数小于0,则加上 + foreach ($bag_detail as $pan) { + if($pan['remaining_number']<0){ + db::name("vs_gift_bag_detail")->where('id', $pan['id'])->setInc('remaining_number', $pan['remaining_number']); + } + } + //补充上把礼物有剩余 + if(!empty($remaining_available_gifts)){ + foreach ($remaining_available_gifts as $gift) { + db::name("vs_gift_bag_detail")->where('id', $gift['id'])->setInc('remaining_number',$gift['remaining_number']); + } + } + } + + /* + * 巡乐会抽奖----------------------------------------------------------------------------------------- + */ + /* + * 巡乐会抽奖(优化版) + */ + public function xlh_draw_gift($user_id, $num, $room_id) + { + $gift_bag_id = 13; + // 1. 获取并缓存盲盒配置 + $ext = $this->getCachedXlhConfig(); + // 2. 检查用户金币和房间状态 + $bag_gift_price = $ext['xlh_box_price'] * $num; + // 3. 检查巡乐会状态 + $pan_xlh = db::name('vs_room_pan_xlh') + ->where(['send_time' => 0]) + ->order('id', 'desc') + ->find(); + if (empty($pan_xlh)) { + return ['code' => 0, 'msg' => '本轮未开始', 'data' => null]; + } + if ($pan_xlh['end_time'] <= time()) { + return ['code' => 0, 'msg' => '本轮已结束', 'data' => null]; + } + // 4. 预加载必要数据 + $gift_bag_detail = db::name("vs_gift_bag_detail") + ->field('id,quantity,remaining_number,weight,foreign_id,gift_bag_id') + ->where(['gift_bag_id'=>$gift_bag_id]) + ->where(['remaining_number' => ['>', 0]]) + ->select(); + + // 计算总数量和剩余数量 + $total_quantity = db::name("vs_gift_bag_detail") + ->where(['gift_bag_id' => $gift_bag_id]) + ->sum('quantity'); + + $total_remaining = array_sum(array_column($gift_bag_detail, 'remaining_number')); + $total_draw_times = $total_quantity - $total_remaining; // 已抽奖次数 + + if ($total_draw_times < 0) $total_draw_times = 0; + + // 5. 获取可用礼物(提前过滤无效礼物) + $available_gifts = []; + foreach ($gift_bag_detail as $pan) { + if ($pan['remaining_number'] > 0 && $pan['weight'] <= $total_draw_times) { + $available_gifts[] = $pan; + } + } + if (empty($available_gifts)) { + // 移除已无剩余数量的礼物 + $remaining_available_gifts = array_filter($gift_bag_detail, function($gift) { + return $gift['remaining_number'] > 0; + }); + $this->reset_gift_pool($gift_bag_id,$remaining_available_gifts); + $available_gifts = $this->getAvailableGifts($gift_bag_id); + } + + // 6. 预计算抽奖结果 + $drawn_gifts = []; // 用于统计抽中结果 + $main_prize_updates = []; // 用于记录主奖品更新 + $is_zhong_jiang = 0; + $pan_xlh_num = $pan_xlh['num']; + + // 批量处理配置 + $batch_size = min(10, $num); // 每批次处理10次 + $total_processed = 0; + $all_results = []; // 存储所有抽奖结果 + try { + db::startTrans(); + while ($total_processed < $num) { + $current_batch = min($batch_size, $num - $total_processed); // 当前批次处理数量 + // 批量扣除金币(只在第一次事务中处理) + if ($total_processed == 0) { + $user_waller = db::name('user_wallet')->where(['user_id' => $user_id])->find(); + if (!$user_waller || $user_waller['coin'] < $bag_gift_price) { + return ['code' => 0, 'msg' => '用户金币不足', 'data' => null]; + } + $wallet_update = model('GiveGift')->change_user_cion_or_earnings_log( + $user_id, + $bag_gift_price, + $room_id, + 1, + 10, + $ext['gift_bag_name'].'抽奖消耗' + ); + if (!$wallet_update) { + throw new \Exception('扣除用户金币失败'); + } + + $user_level = model('Level')->user_level_data_update( + $user_id, + $bag_gift_price, + 1, + $room_id + ); + if (!$user_level) { + throw new \Exception('用户等级更新失败'); + } + } + + // 处理当前批次的抽奖 + $inventory_updates = []; // 用于记录库存变化 + $remaining_available_gifts = $available_gifts; + for ($i = 0; $i < $current_batch; $i++) { + // 从可用礼物中选择 + $selected_gift = $this->selectGiftFromAvailable($available_gifts); + if (!$selected_gift) { + $gift_bag_detail = $this->resetPoolAndReload($gift_bag_id); + $selected_gift = $this->selectGiftFromAvailable($gift_bag_detail); + if(!$selected_gift){ + throw new \Exception('预计算抽奖失败,重置后无可用礼物'); + } + } + // 记录库存变化 + $inventory_updates[$selected_gift['id']] = + ($inventory_updates[$selected_gift['id']] ?? 0) + 1; + + // 记录抽中结果 + $gift_id = $selected_gift['foreign_id']; + $drawn_gifts[$gift_id] = ($drawn_gifts[$gift_id] ?? 0) + 1; + + // 处理主奖品 + if ($gift_id == $ext['locking_condition']['selected_gift_id']) { + $pan_xlh_num++; + $main_prize_updates[] = [ + 'num' => $pan_xlh_num, + 'user_id' => $user_id, + 'gift_id' => $gift_id + ]; + + // 计算延长时间 + $add_end_time = $this->calculateEndTime($pan_xlh_num, $ext, $room_id); + $end_time = time() + $add_end_time; + + // 记录主奖品更新 + $main_prize_updates[count($main_prize_updates) - 1]['end_time'] = $end_time; + } + + // 记录完整结果 + $all_results[] = [ + 'gift_id' => $gift_id, + 'gift_detail_id' => $selected_gift['id'], + 'gift_bag_detail' => $selected_gift + ]; + + // 更新可用礼物缓存 + foreach ($available_gifts as &$gift) { + if ($gift['id'] == $selected_gift['id']) { + $gift['remaining_number']--; + break; + } + } + unset($gift); + + // 移除已无剩余数量的礼物 + $available_gifts = array_filter($available_gifts, function($gift) { + return $gift['remaining_number'] > 0; + }); + + // 检查是否需要重置奖池 + $total_remaining = array_sum(array_column($available_gifts, 'remaining_number')); + if ($total_remaining <= 0 && $total_processed + $i + 1 < $num) {// 剩余数量小于等于0且当前处理数量小于总数量 + $available_gifts = $this->resetPoolAndReload($gift_bag_id); + if (empty($available_gifts)) { + throw new \Exception('重置奖池后仍无可用礼物'); + } + } + } + + // 批量更新库存 + ksort($inventory_updates); // 按ID排序 + foreach ($inventory_updates as $detail_id => $count) { + db::name("vs_gift_bag_detail")->where('id',$detail_id)->setDec('remaining_number', $count); + } + + // 处理主奖品更新 + if (!empty($main_prize_updates)) { + $last_update = end($main_prize_updates); + db::name('vs_room_pan_xlh')->where('id', $pan_xlh['id'])->update([ + 'user_id' => $last_update['user_id'], + 'room_id' => $room_id, + 'pay_price' => $ext['xlh_box_price'], + 'locking_gift_id' => $last_update['gift_id'], + 'num' => $last_update['num'], + 'end_time' => $last_update['end_time'], + 'updatetime' => time() + ]); + + db::name('vs_room_pan_xlh_log')->insert([ + 'xlh_id' => $pan_xlh['id'], + 'user_id' => $last_update['user_id'], + 'room_id' => $room_id, + 'num' => $last_update['num'], + 'locking_end_time' => $last_update['end_time'], + 'createtime' => time() + ]); + $is_zhong_jiang = 1; + }else{ + $is_zhong_jiang = 0; + } + $total_processed += $current_batch; + } + // 7. 批量处理结果记录 + if(count($drawn_gifts) > $num){ + $key = 'xlh_draw_gift_errors_' . date('Y-m-d-H-i-s'); + $errorData = [ + 'user_id' => $user_id, + 'gift_bag_id' => $gift_bag_id, + 'room_id' => $room_id, + 'num' => $num, + 'drawn_gifts_num' => count($drawn_gifts) + ]; + $this->redis->setex($key, 86400 * 7, "巡乐会抽奖失败-数量超限". ' ' .json_encode($errorData)); + return ['code' => 0, 'msg' => "抽奖中,请稍等...", 'data' => null]; + } + // 批量插入礼包发放记录 + $gift_records = []; + $periods = $this->getCachedXlhPeriods('get') ?? 0; + foreach ($drawn_gifts as $gift_id => $count) { + $gift_records[] = [ + 'user_id' => $user_id, + 'parent_id' => $pan_xlh['id'], + 'gift_bag_id' => $gift_bag_id, + 'gift_id' => $gift_id, + 'periods' => $periods, + 'room_id' => $room_id, + 'num' => $count, + 'gift_price' => $this->getGiftPrice($gift_id), + 'bag_price' => $ext['xlh_box_price'], + 'createtime' => time() + ]; + } + + if (!empty($gift_records)) { + db::name("vs_gift_bag_receive_pan_log")->insertAll($gift_records); + } + + // 批量处理用户礼物包 + foreach ($drawn_gifts as $gift_id => $count) { + $res = model('UserGiftPack')->change_user_gift_pack( + $user_id, + $gift_id, + $count, + model('UserGiftPack')::XLH_DRAW_GIFT_GET, + "巡乐会抽奖所得" + ); + if ($res['code'] != 1) { + throw new \Exception($res['msg']); + } + } + + // 添加活动记录 + Db::name('vs_activities_receive')->insert([ + 'user_id' => $user_id, + 'activities_id' => 6, + 'room_id' => $room_id, + 'createtime' => time(), + 'updatetime' => time() + ]); + db::commit(); + } catch (\Exception $e) { + db::rollback(); + $key = 'xlh_draw_gift_errors_' . date('Y-m-d-H-i-s'); + $errorData = [ + 'user_id' => $user_id, + 'gift_bag_id' => $gift_bag_id, + 'room_id' => $room_id, + ]; + $this->redis->setex($key, 86400 * 7, $e->getMessage(). ' ' .json_encode($errorData)); + return ['code' => 0, 'msg' => "抽奖中,请稍等...", 'data' => null]; + } + // 8. 处理推送消息 + if ($is_zhong_jiang == 1) { + $this->handlePrizeNotification($user_id,$gift_id, $room_id, $pan_xlh_num, $end_time,$ext['locking_condition']['locking_gift_id']); + } + + // 9. 构建返回结果 + return $this->buildResult($drawn_gifts); + } + + /** + * 巡乐会抽奖-从可用礼物中选择一个 + */ + private function selectGiftFromAvailable(array &$available_gifts) + { + $remaining = array_sum(array_column($available_gifts, 'remaining_number')); + if ($remaining <= 0) { + return null; + } + // 循环尝试直到抽中有效礼物 + $max_attempts = 5; // 最大尝试次数,防止无限循环 + $attempt = 0; + $selected_gift = null; + while ($attempt < $max_attempts && !$selected_gift) { + $rand_value = mt_rand(1, $remaining); + $current_sum = 0; + + foreach ($available_gifts as $gift) { + if ($gift['remaining_number'] <= 0) { + continue; + } + $current_sum += $gift['remaining_number']; + if ($rand_value <= $current_sum) { + $selected_gift = $gift; + break; + } + } + $attempt++; + } + + return $selected_gift; + } + + /** + * 巡乐会抽奖-计算结束时间 + */ + private function calculateEndTime($pan_xlh_num, $ext, $room_id) + { + $cache_key = 'selected_gift_id_' . $ext['locking_condition']['selected_gift_id']; + + if ($pan_xlh_num <= 1) { + $add_end_time = $ext['locking_time']['tow_no_locking_time'] * 60; + Cache::set($cache_key, $add_end_time, $add_end_time); + return $add_end_time; + } + + if (Cache::get($cache_key)) { + $erci_xlh_num = Cache::get($cache_key); + $add_end_time = $erci_xlh_num - $ext['locking_time']['next_time'] * 60; + Cache::set($cache_key, $add_end_time, $add_end_time); + } else { + $add_end_time = ($ext['locking_time']['tow_no_locking_time'] - $ext['locking_time']['next_time']) * 60; + } + + if ($add_end_time <= 30) { + Cache::set($cache_key, 30, 30); + return 30; + } + + return $add_end_time; + } + + /** + * 巡乐会抽奖-重新加载奖池 + */ + private function reloadGiftPool($room_id, $gift_bag_id) + { + return db::name("vs_gift_bag_detail") + ->field('id,quantity,remaining_number,weight,foreign_id,gift_bag_id') + ->where(['gift_bag_id'=>$gift_bag_id]) + ->select(); + } + + /** + * 巡乐会抽奖-获取礼物价格 + */ + private function getGiftPrice($gift_id) + { + static $gift_prices = []; + + if (!isset($gift_prices[$gift_id])) { + $gift_prices[$gift_id] = db::name("vs_gift") + ->where(['gid' => $gift_id]) + ->value('gift_price'); + } + + return $gift_prices[$gift_id]; + } + + /** + * 巡乐会抽奖-处理中奖通知 + */ + private function handlePrizeNotification($user_id,$gift_id, $room_id, $pan_xlh_num, $end_time,$locking_gift_id) + { + $FromUserInfo = db::name('user')->field('nickname,avatar')->where(['id' => $user_id])->find(); + $gift_info = db::name('vs_gift')->field('gift_name')->where(['gid' => $gift_id])->find(); + $locking_gift = db::name('vs_gift')->field('gift_name')->where(['gid' => $locking_gift_id])->find(); + $room_data = db::name('vs_room')->field('room_name,user_id')->where(['id' => $room_id])->find(); + $room_user = db::name('user')->where('id',$room_data['user_id'])->field('nickname,avatar')->find(); + //锁定礼物 + +// $text = [ +// 'gift_num' => $pan_xlh_num, +// 'FromUserInfo' => $FromUserInfo, +// 'end_time' => $end_time, +// 'text' => $FromUserInfo['nickname'] . ' 在 ' . ' 巡乐会活动中 获得' . $gift_info['gift_name'] . '礼物 x 1' +// ]; +// +// model('Chat')->sendMsg(1057, $room_id, $text); + + //推送礼物横幅 + $text = $FromUserInfo['nickname'] .' 巡乐会活动中锁定礼物'.$locking_gift['gift_name'].' x ' .$pan_xlh_num ; + $push = new Push(0, $room_id); + $text_list_new = [ + 'text' => $text, + 'room_id' => $room_id, + 'from_type' => 103, + 'gift_num' => $pan_xlh_num, + 'FromUserInfo' => $FromUserInfo, + 'end_time' => $end_time, + 'room_user' => $room_user + ]; + $push->xunlehui($text_list_new); + } + + /** + * 巡乐会抽奖-构建返回结果 + */ + private function buildResult($drawn_gifts) + { + $result_list = []; + $gift_info_cache = []; + + foreach ($drawn_gifts as $gift_id => $count) { + if (!isset($gift_info_cache[$gift_id])) { + $gift_info = db::name('vs_gift') + ->where(['gid' => $gift_id]) + ->find(); + $gift_info_cache[$gift_id] = $gift_info; + } else { + $gift_info = $gift_info_cache[$gift_id]; + } + + $result_list[] = [ + 'gift_id' => $gift_id, + 'gift_name' => $gift_info['gift_name'], + 'base_image' => $gift_info['base_image'], + 'gift_price' => $gift_info['gift_price'], + 'count' => $count, + ]; + } + + // 按价格降序排序 + usort($result_list, function($a, $b) { + return $b['gift_price'] <=> $a['gift_price']; + }); + + return ['code' => 1, 'msg' => '成功', 'data' => $result_list]; + } + //错误日志记录------------------------------------------------------- + /** + * 记录抽奖错误日志到Redis + */ + private function recordDrawErrorToRedis($expectedCount, $actualCount, $room_id, $user_id, $gift_bag_id, $num, $gift_user_ids, $precomputedResults) + { + // 检查Redis连接是否可用 + if (!$this->redis) { + Log::record('Redis连接不可用,无法记录错误日志', 'error'); + return; + } + + try { + $errorData = [ + 'timestamp' => time(), + 'expected_count' => $expectedCount, + 'actual_count' => $actualCount, + 'room_id' => $room_id, + 'user_id' => $user_id, + 'gift_bag_id' => $gift_bag_id, + 'num' => $num, + 'gift_user_ids' => $gift_user_ids, + 'precomputed_results_count' => count($precomputedResults), + 'precomputed_results' => $precomputedResults, + 'error_type' => 'draw_count_mismatch' + ]; + + // 使用正确的Redis方法存储数据 + $key = 'blind_box_draw_world_errors_' . date('Y-m-d-H-i-s'); + $this->redis->setex($key, 86400 * 7, json_encode($errorData)); + } catch (\Exception $e) { + Log::record('Redis操作失败: ' . $e->getMessage(), 'error'); + } + } + +} diff --git a/application/api/model/Friend.php b/application/api/model/Friend.php new file mode 100644 index 0000000..b54507c --- /dev/null +++ b/application/api/model/Friend.php @@ -0,0 +1,801 @@ +where(['room_id' => $room_id, 'pit_number' => 9,'user_id' => $user_id])->find(); + if(!$host){ + return ['code' => 0, 'msg' => '没有权限操作', 'data' => null]; + } + + $room_info = db::name('vs_room')->field('id,step,room_status')->where(['id' => $room_id,'room_status' =>1])->find(); + if (!$room_info) { + return ['code' => 0, 'msg' => '房间不存在!', 'data' => null]; + } + if($room_info['step'] == 2 || $room_info['step'] == 3){ + return ['code' => 0, 'msg' => '交友正在进行中!', 'data' => null]; + } + //在麦位上的用户 + $pit_user = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7],'user_id' => ['<>',0]])->count(); + + if($pit_user >= 2) { + $data['room_id'] = $room_id; + $data['end_time'] = time() + get_system_config_value('friend_time') * 60; + $data['create_time'] = time(); + $data['status'] = 1; + + $id = db::name('vs_user_friending')->insertGetId($data); + + if (!$id) { + return ['code' => 0, 'msg' => '操作失败!', 'data' => null]; + } + //修改房间状态 + db::name('vs_room')->where(['id' => $room_id])->update(['step' => 2]); + //清除房间用户的魅力 + model('Room')->clear_user_charm($user_id, $room_id); + + //推送给前端消息 + $text['text'] = '交友开始'; + $text['step'] = 2; + $text['friend_id'] = $id; + $text['end_time'] = $data['end_time']; + model('api/Chat')->sendMsg(1049,$room_id,$text); + return ['code' => 1, 'msg' => '操作成功!', 'data' => ['friend_id' => $id]]; + }else{ + return ['code' => 0, 'msg' => '交友麦位至少两位用户才能开始', 'data' => null]; + } + } + + + //延时 + public function delay($user_id,$room_id,$id,$delay_times){ + // 判断用户是否在主持麦 + $host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 9,'user_id' => $user_id])->find(); + if(!$host){ + return ['code' => 0, 'msg' => '没有权限操作', 'data' => null]; + } + + if (!$id || !$room_id) { + return ['code' => 0, 'msg' => '参数有误!', 'data' => null]; + } + if($delay_times <= 0){ + $delay_times = get_system_config_value('friend_delay_times'); + } + //修改结束 时间 + $res = db::name('vs_user_friending')->where('id', $id)->update([ + 'end_time' => Db::raw('end_time + ' . ($delay_times * 60)) + ]); + if(!$res){ + return ['code' => 0, 'msg' => '操作失败!', 'data' => null]; + } + //推送延时 + $text['text'] = '延时'; + $text['friend_id'] = $id; + $text['end_time'] = db::name('vs_user_friending')->where('id', $id)->value('end_time'); + model('api/Chat')->sendMsg(1050,$room_id,$text); + return ['code' => 1, 'msg' => '操作成功!', 'data' => null]; + } + + //交友结束(结束牵手良缘) + public function end_friend($user_id,$room_id,$id,$is_system = 0){ + if (!$id || !$room_id) { + return ['code' => 0, 'msg' => '参数有误!', 'data' => null]; + } + + if($is_system == 0){ + // 判断用户是否在主持麦 + $host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 9,'user_id' => $user_id])->find(); + if(!$host){ + return ['code' => 0, 'msg' => '没有权限操作', 'data' => null]; + } + } + + // 获取心动值最高的 + $originalPairs = db::name('vs_user_friending_heart') + ->where(['room_id'=>$room_id,'friend_id'=>$id ,'status' =>1]) + ->order('heart_value DESC')->find(); + $friend_heart_value = get_system_config_value('friend_heart_value'); + if($originalPairs && $originalPairs['heart_value'] >= $friend_heart_value){ + $step = 3;//结束进入牵手良缘卡关系 + //心动值达到伐值 返回用户信息与关系列表 + $return['user1_id'] =$originalPairs['user1_id']; + $return['user1_avatar'] = db::name('user')->where(['id'=>$originalPairs['user1_id']])->value('avatar'); + $return['user1_nickname'] = db::name('user')->where(['id'=>$originalPairs['user1_id']])->value('nickname'); + $return['user2_id'] =$originalPairs['user2_id']; + $return['user2_avatar'] = db::name('user')->where(['id'=>$originalPairs['user2_id']])->value('avatar'); + $return['user2_nickname'] = db::name('user')->where(['id'=>$originalPairs['user2_id']])->value('nickname'); + $return['heart_value'] = $originalPairs['heart_value']; + $return['heart_id'] = $originalPairs['id']; + $room_updatatime = db::name('vs_room')->where(['id' => $room_id,'step' => $step])->value('updatetime'); + if($room_updatatime){ //60秒内没操作 则创建关系无 + if(time() - $room_updatatime > 60){ + $this->createRelation(0,$room_id,$id,$return['user1_id'],$return['user2_id'],0); + return ['code' => 1, 'msg' => '操作成功!', 'data' => $return]; + } + }else{ + // 修改当前交友阶段 + db::name('vs_room')->where(['id' => $room_id])->update(['step' => $step,'updatetime' => time()]); + } + }else{ + $step = 1;//结束下一轮 + // 修改当前交友阶段 分开写 放到前面是为了下麦 + db::name('vs_room')->where(['id' => $room_id])->update(['step' => 1]); + //所有人下麦 + $on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7],'user_id' => ['<>',0]])->select(); + if($on_pit){ + foreach ($on_pit as $pit){ + model('RoomPit')->DownPit($pit['user_id'], $room_id,$pit['pit_number']); + } + } + $return = null; + } + + //结束交友游戏 + if($step == 1){ + db::name('vs_user_friending')->where(['id' => $id])->update(['status' => 2]); + } + //推送给前端消息 + $text['text'] = $step == 1 ? '交友结束' : '牵手良缘'; + $text['step'] = $step;//1 等待邂逅 2 心动连线 3 牵手良缘 + $text['friend_user'] = $return; + $text['friend_id'] = $id; + model('api/Chat')->sendMsg(1049,$room_id,$text); + model('Room')->clear_user_charm(db::name('vs_room')->where(['id' => $room_id])->value('user_id'), $room_id); + return ['code' => 1, 'msg' => '操作成功!', 'data' => $return]; + } + + //心动值超过配置值 创建关系 + public function createRelation($user_id,$room_id,$friend_id,$user1_id,$user2_id,$friending_config_id){ + + if (!$user1_id || !$user2_id || !$friend_id || !$room_id) { + return ['code' => 0, 'msg' => '参数有误!', 'data' => null]; + } + + $user1 = min($user1_id, $user2_id); + $user2 = max($user1_id, $user2_id); + $friending_heart = db::name('vs_user_friending_heart') + ->where(['room_id'=>$room_id,'friend_id'=>$friend_id ,'user1_id' =>$user1,'user2_id' => $user2])->order('id desc')->find(); + + $originalPairs = db::name('vs_user_friending_heart') + ->where(['id'=>$friending_heart['id']]) + ->update(['status' => 3,'friend_config_id' =>$friending_config_id]); + $msg = ''; + if ($originalPairs) { + $relation = db::name('vs_relation')->where('id',$friending_config_id)->value('name'); + if($friending_heart['heart_value'] >= get_system_config_value('friend_heart_create_room') && $friending_config_id > 0){ + //创建小房间 + $room_ids = model('api/Room')->user_create_room($user1,'的电影房',get_system_config_value('web_site').'/data/avatar/head_pic.png','交友房产生的一次性房间',7); + if($room_ids['code'] != 1){ + $msg = 'cp电影房创建失败'; + }else{ + //记录小房间 + $datda = [ + 'room_id' => $room_ids['data'], + 'relation_id' => $friending_config_id, + 'user_id' => $user1, + 'user_id1' => $user2, + 'time_day' => time() + get_system_config_value('friend_room_timea') * 60, + 'createtime' => time(), + 'status' => 1, + 'type' => 1 + ]; + db::name('vs_room_cp_movie')->insert($datda); + + if($room_ids['data']){ + $text['text'] = '交友结束并创建房间'; + $text['room_id'] = $room_ids['data'];//前端用来让用户跳转的房间id + } + } + }else{ + $text['text'] = '交友结束未创建房间'; + } + $text['relation_name'] = $relation; + $text['user1_id'] = $user1; + $text['user2_id'] = $user2; + $text['user1_avatar'] = db::name('user')->where(['id'=>$user1])->value('avatar'); + $text['user1_nickname'] = db::name('user')->where(['id'=>$user1])->value('nickname'); + $text['user2_avatar'] = db::name('user')->where(['id'=>$user2])->value('avatar'); + $text['user2_nickname'] = db::name('user')->where(['id'=>$user2])->value('nickname'); + model('api/Chat')->sendMsg(1051,$room_id,$text); + + // 修改当前交友阶段 + db::name('vs_room')->where(['id' => $room_id])->update(['step' => 1]); + db::name('vs_user_friending')->where(['id' => $friend_id])->update(['status' => 2]); + //所有人下麦 + $on_pit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7],'user_id' => ['<>',0]])->select(); + if($on_pit){ + foreach ($on_pit as $pit){ + model('RoomPit')->DownPit($pit['user_id'], $room_id,$pit['pit_number']); + } + } + + $shijian = floor($friending_heart['heart_value']/get_system_config_value('friend_heart_value')) * get_system_config_value('friend_heart_times'); + $friendendtime = time() + $shijian * 3600; + + //更新关系结束时间 + db::name('vs_user_friending_heart')->where(['id'=>$friending_heart['id']])->update(['contact_end_time' => $friendendtime]); + + //关系增加时间 + $room_auction = model('RoomAuction')->room_auction_create_or_add($user1_id,$user2_id,$friending_config_id,$shijian*3600,0); + + //推送给前端消息 + $text['text'] = '交友结束'; + $text['step'] = 1;//1 等待邂逅 2 心动连线 3 牵手良缘 + model('api/Chat')->sendMsg(1049,$room_id,$text); + + return ['code' => 1, 'msg' => '创建关系成功!'.$msg, 'data' => null]; + } else { + //推送给前端消息 + $text['text'] = '交友结束'; + $text['step'] = 1;//1 等待邂逅 2 心动连线 3 牵手良缘 + model('api/Chat')->sendMsg(1049,$room_id,$text); + db::name('vs_user_friending')->where(['id' => $friend_id])->update(['status' => 2]); + return ['code' => 0, 'msg' => '创建关系失败!', 'data' => null]; + } + } + + + //退出私密房间 + public function outRoom($user_id,$room_id){ + //推送给前端消息 + $text['text'] = '退出私密小屋'; + model('api/Chat')->sendMsg(1055,$room_id,$text); + + +// //查询在房间的用户 +// $users = db::name('vs_room_visitor')->where(['room_id'=>$room_id])->select(); +// if($users){ +// //退出房间 +// foreach ($users as $v){ +// //退出房间 +// model('Room')->quit_room($v['user_id'], $room_id,$v['user_id']); +// } +// }else{ +// model('Room')->quit_room($user_id, $room_id,$user_id); +// } + + //注销房间 + db::name('vs_room')->where(['id'=>$room_id])->update(['room_status'=>3]); + db::name('vs_room_cp_movie')->where(['room_id'=>$room_id])->update(['status'=>4]); + model('api/Tencent')->delete_group('room'.$room_id); + + return ['code' => 1, 'msg' => '退出成功!', 'data' => null]; + } + + + + + //房间内送礼 + /* + * @param $uid 用户id + * @param $to_uid 接收用户id组 + * @param $gift_id 礼物id + * @param $gift_num 礼物数量 + * @param $from_type 来源 1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 5系统任务 6-cp房间送礼 + * @param $type 1金币购买 2送背包礼物 + * @param $room_id 房间id + * @param $pit_number 坑位 + */ + public function room_give_gift($uid, $to_uid, $gift_id, $gift_num, $from_type, $type, $room_id, $pit_number, $heart_id,$give_gift_ext) + { + $res = model('GiveGift')->give_gift($uid, $to_uid, $gift_id, $gift_num, $from_type, $type, $room_id, $pit_number,0,$give_gift_ext); + if($res['code'] != 1){ + return $res; + } + + //送礼成功后续操作 + //查看当前时间是否在交友表的创建时间和结束时间段内 用来区分是否要拉取心动值高的用户上麦 + $friend = db::name('vs_user_friending')->where(['room_id' => $room_id,'status' => 1])->order('id desc')->find(); + if($friend && time() >= $friend['create_time'] && time() <= $friend['end_time']){ + $heart_exp = get_system_config_value('coin_charm_exp');//金币与魅力值转换比 + $sumPrice = $res['data']['gift_total'] * $heart_exp; + $user_idd = $to_uid; + + if($heart_id){//有这个值就是助力 不参加抢麦操作 + db::name('vs_user_friending_heart')->where(['id' => $heart_id])->setInc('heart_value', $sumPrice); + $this->pullHeartChange($room_id,$friend['id']);//聊天室心动值变化通知 + //生成新排名 判断抱上麦 还是换麦 + $this->pullUserPit($room_id,$friend['id']); + }else{ + //判断送礼人或收礼人里面有主持和嘉宾 + $host = $this->is_host($uid,$to_uid,$room_id); + $user_idd = explode(",", $user_idd); // 将字符串转换为数组 + //判断是否是主持 + if($host['is_preside'] == 1){ + if(!in_array($uid,$host['is_preside_user'])){//主持不是当前送礼人,那就是在收礼人中 + //从数组中剔除主持人 && $is_preside_user!= UID + $user_idd = array_diff($user_idd, $host['is_preside_user']); // 从数组中移除 + if($user_idd){ + //插入/更新心动表 + $this->addUserHeart($uid,$user_idd,$friend['id'],$sumPrice,$room_id,$res['data']['gift_user_data']); + //送礼产生心动值并计算 判断拉取用户上麦还是换麦 + //生成新排名 判断抱上麦 还是换麦 + $this->pullUserPit($room_id,$friend['id']); + } + } + }else{ + //插入/更新心动表 + $this->addUserHeart($uid,$user_idd,$friend['id'],$sumPrice,$room_id,$res['data']['gift_user_data']); + //送礼产生心动值并计算 判断拉取用户上麦还是换麦 + //生成新排名 判断抱上麦 还是换麦 + $this->pullUserPit($room_id,$friend['id']); + } + } + } + return ['code' => 1, 'msg' => '送礼成功', 'data' => null]; + } + + //是否主持 + public function is_host($uid,$to_uid,$room_id){ + //获取当前主持人和嘉宾 + $host[] = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number' => 9])->value('user_id'); + $host[] = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number' => 10])->value('user_id'); + + $is_preside_user = []; + $is_preside = 0; + $user_ids = explode(",", $to_uid); + foreach ($user_ids as $value) { + //判断收礼人是否是主持 + if (in_array($value, $host)) { + $is_preside = 1; + $is_preside_user[] = $value; + } + } + //送礼人是主持或嘉宾 + if (in_array($uid, $host)) { + $is_preside = 1; + $is_preside_user[] = $uid; + } + return ['is_preside' =>$is_preside,'is_preside_user' => $is_preside_user]; + } + + function pullHeartChange($room_id,$friend_id){ + //聊天室心动值变化通知 + $newRanking = $this->getRanking($room_id,$friend_id); + //心动值和心动表id + if(!isset($newRanking[0]['heart_value']) || $newRanking[0]['heart_value'] <= 0){ + $heart1 = -1; + $heartId1 = -1; + }else{ + $heart1 = $newRanking[0]['heart_value']; + $heartId1 = $newRanking[0]['id']; + } + if(!isset($newRanking[1]['heart_value']) || $newRanking[1]['heart_value'] <= 0){ + $heart2 = -1; + $heartId2 = -1; + }else{ + $heart2 = $newRanking[1]['heart_value']; + $heartId2 = $newRanking[1]['id']; + } + if(!isset($newRanking[2]['heart_value']) || $newRanking[2]['heart_value'] <= 0){ + $heart3 = -1; + $heartId3 = -1; + }else{ + $heart3 = $newRanking[2]['heart_value']; + $heartId3 = $newRanking[2]['id']; + } + $heart[0] = [ + "heartNum" => $heart1, + "heartId" => $heartId1, + ]; + $heart[1] = [ + "heartNum" => $heart2, + "heartId" => $heartId2, + ]; + $heart[2] = [ + "heartNum" => $heart3, + "heartId" => $heartId3, + ]; + +// $push = new Push(0, $this->room_id); //实例化推送类 +// $push->heartChatRoom($heart); + //推送给前端消息 + $text['text'] = '心动值变化通知'; + $text['list'] = $heart; + model('api/Chat')->sendMsg(1054,$room_id,$text); + return $heart; + } + + // 获取心跳值排行 + public function getRanking($room_id,$friend_id) { + // 获取有心动值的用户对且不重复 + $originalPairs = db::name('vs_user_friending_heart') + ->where(['room_id'=>$room_id,'friend_id'=>$friend_id]) + ->order('heart_value DESC')->select(); + // 初始化排名数组和已使用用户数组 + $ranking = []; + $usedUsers = []; + // 优先选择高价值且无重复用户的对 + $heart_ids = []; + foreach ($originalPairs as &$rel) { + // 检查当前用户对是否包含已使用的用户ID + if (!in_array($rel['user1_id'], $usedUsers) && + !in_array($rel['user2_id'], $usedUsers)) { + // 将符合条件的用户对添加到排名列表中 + $ranking[] = [ + 'heart_value' => $rel['heart_value'], + 'id' => $rel['id'], + 'user1_id' => $rel['user1_id'], + 'user2_id' => $rel['user2_id'], + ]; + // 更新已使用用户列表 + $usedUsers = array_merge($usedUsers, [$rel['user1_id'], $rel['user2_id']]); + $heart_ids[] = $rel['id']; + // 如果排名列表达到3对用户,则停止循环 + if (count($ranking) >= 3) break; + } + } + $ranking1 = []; + $ranking2 = []; + if(count($ranking)<3){ + $make_up_num = 3 - count($ranking); + $ranking_make_up = db::name('vs_user_friending_heart') + ->where(['room_id'=>$room_id,'friend_id'=>$friend_id ,'id'=> ['notin',$heart_ids]]) + ->limit($make_up_num) + ->order('heart_value DESC')->select(); + foreach ($ranking_make_up as $rel1) { + // 如果两个用户都已使用,跳过这条记录 + if(in_array($rel1['user1_id'], $usedUsers) && in_array($rel1['user2_id'], $usedUsers)){ + continue; + } + + // 如果只有user1已使用,将user2加入排名 + if(in_array($rel1['user1_id'], $usedUsers)){ + $ranking1[] = [ + 'heart_value' => 0, + 'id' => $rel1['id'], + 'user1_id' => -1, + 'user2_id' => $rel1['user2_id'], + ]; + $usedUsers[] = $rel1['user2_id']; + $heart_ids[] = $rel1['id']; + } + // 如果只有user2已使用,将user1加入排名 + elseif(in_array($rel1['user2_id'], $usedUsers)){ + $ranking1[] = [ + 'heart_value' => 0, + 'id' => $rel1['id'], + 'user1_id' => $rel1['user1_id'], + 'user2_id' => -1, + ]; + $usedUsers[] = $rel1['user1_id']; + $heart_ids[] = $rel1['id']; + } + } + + } + // 返回最终的排名列表 + $ranking_rut = array_merge($ranking, $ranking1); + $nnum = count($ranking)*2 + count($ranking1); + if($nnum<6){ + $make_up_num = 6 - $nnum; + $ranking_make_up = db::name('vs_user_friending_heart') + ->where(array('room_id'=>$room_id,'friend_id'=>$friend_id ,'id'=>array('notin',$heart_ids))) + ->limit($make_up_num) + ->order('heart_value DESC')->select(); + if($ranking_make_up){ + foreach ($ranking_make_up as $rel1) { + if(in_array($rel1['user1_id'], $usedUsers) && in_array($rel1['user2_id'], $usedUsers)){ + continue; + } + if(in_array($rel1['user1_id'], $usedUsers)){ + $ranking2[] = [ + 'heart_value' => 0, + 'id' => $rel1['id'], + 'user1_id' => -1, + 'user2_id' => $rel1['user2_id'], + ]; + $usedUsers[] = $rel1['user2_id']; + } + if(in_array($rel1['user2_id'], $usedUsers)){ + $ranking2[] = [ + 'heart_value' => 0, + 'id' => $rel1['id'], + 'user1_id' => $rel1['user1_id'], + 'user2_id' => -1, + ]; + $usedUsers[] = $rel1['user1_id']; + } + } + } + + } + return array_merge($ranking_rut, $ranking2); + } + + + //抱上麦 还是换麦 + public function pullUserPit($room_id,$friend_id){ + $friendPlayPit = $this->friendPlayPit($room_id,$friend_id); // 获取实际应该对应的麦位 + $this->changePitToPosPair($room_id,$friendPlayPit);//换麦,上下麦 + $this->pullHeartChange($room_id,$friend_id);//聊天室心动值变化通知 + } + + //交友处理麦位排名 + public function friendPlayPit($room_id,$friend_id){ + //查询当前交友心动值表 + $heart_data = $this->getRanking($room_id,$friend_id); + //数组根据里面的heart_value 由大到小进行排序 + usort($heart_data, function($a, $b) { + return $b['heart_value'] - $a['heart_value']; + }); + $pit = []; + $pit_number_array = [2=>5,1=>6,3=>4,5=>2,6=>1,4=>3]; //麦位对应关系 + $pit_number_array_reverse = [0=>2,1=>1,2=>3,3=>4,4=>5,5=>6]; + if($heart_data){ + //排麦位 + $pit_unique = []; + $key = 0; + foreach($heart_data as $value) { + if(count($pit) >= 6){ + break; + } + + // 处理两个用户都存在的情况 + if($value['user1_id'] != -1 && $value['user2_id'] != -1){ + if(!in_array($value['user1_id'],$pit_unique)){ + // 检查目标麦位是否已被占用 + if(!isset($pit[$pit_number_array_reverse[$key]])) { + $pit[$pit_number_array_reverse[$key]] = $value['user1_id']; + $pit[$pit_number_array[$pit_number_array_reverse[$key]]] = $value['user2_id']; + $pit_unique = array_merge($pit_unique, [$value['user1_id'], $value['user2_id']]); + } + } + } + // 处理只有user2存在的情况 + elseif($value['user1_id'] == -1 && !in_array($value['user2_id'],$pit_unique)){ + // 检查该键是否已被使用 + if(!isset($pit[$pit_number_array_reverse[$key]])) { + $pit[$pit_number_array_reverse[$key]] = $value['user2_id']; + $pit_unique[] = $value['user2_id']; + } + } + // 处理只有user1存在的情况 + elseif($value['user2_id'] == -1 && !in_array($value['user1_id'],$pit_unique)){ + // 检查该键是否已被使用 + if(!isset($pit[$pit_number_array_reverse[$key]])) { + $pit[$pit_number_array_reverse[$key]] = $value['user1_id']; + $pit_unique[] = $value['user1_id']; + } + } + $key++; + } + } + return $pit; + } + + + + //换麦 + public function changePitToPosPairs($room_id,$friendPlayPit){ + $now_pit_u = array_flip($friendPlayPit); + //按照键值排序数组 + ksort($now_pit_u); + //查询现在麦位上有用户的数据 并且重组结果,键为麦位,值为用户,值必须存在,没值则不展示 + $pit_user = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number'=>['<',7],'user_id' => ['>', 0]]) + ->order('pit_number ASC') + ->column('pit_number,user_id'); + //比较两个数组,无论是键的差异还是值的差异,都输出字符串”有差异“否则输出”没有差异“ + $result = array_diff_assoc($pit_user, $now_pit_u); + $result2 = array_diff_assoc($now_pit_u, $pit_user); + if(!empty($result) || !empty($result2)){ +// var_dump('有差异'); + //获取实际麦位上的用 + $newPitUser = array_keys($friendPlayPit); + //获取当前麦位上的用户 + $oldPitUser = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number'=>['<',7]])->column('user_id'); + //获取交集 + $intersection = array_intersect($newPitUser,$oldPitUser); + //取差集 + $diff = array_diff($newPitUser,$oldPitUser); + $changeData = []; + if($diff){ + //推下麦 + foreach($diff as $key => $value){ + if(in_array($value,$oldPitUser)){ + //查询当前空麦位 + $pit_null = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]); + if($pit_null){ +// $this->room_pit_model->getOnPit($this->room_id, $value, $pit_null); + model('api/RoomPit')->OnPit($value, $room_id, $pit_null); +// db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_null])->update(['user_id' => $value]); + }else{ + //下麦 + $UserRoomPit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $value])->value('pit_number'); + model('api/RoomPit')->DownPit($value, $room_id, $UserRoomPit); + } + } + + if(in_array($value,$newPitUser)){ + //推上麦 + //获取目标麦位是否有人 + $getRoomPitUser= db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $friendPlayPit[$value]])->value('user_id'); + if($getRoomPitUser){ + //查询当前空麦位 + $getRoomNullPitss = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10,$friendPlayPit[$value]]); + if($getRoomNullPitss){ +// $this->room_pit_model->getOnPit($this->room_id, $getRoomPitUser, $getRoomNullPitss); + db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $getRoomNullPitss])->update(['user_id' => $getRoomPitUser]); + }else{ + model('api/RoomPit')->DownPit($getRoomPitUser, $room_id, $friendPlayPit[$value]); + } + } + model('api/RoomPit')->OnPit($value, $room_id, $friendPlayPit[$value]); + } + } + } + if($intersection){//交换麦位 + //查询麦上的用户 + $newPitUserStr = implode(',',$newPitUser); + $getRoomPit = db::name('vs_room_pit')->where("room_id=".$room_id." AND user_id in (".$newPitUserStr.")")->column('pit_number'); + db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['in', $getRoomPit]])->update(['user_id' => 0]); + $changePitUser = []; + foreach ($friendPlayPit as $key => $value){ + if(empty($value)){ + $value = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]); + } + //获取目标麦位是否有人 + $isPitHaveUser= db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $value])->value('user_id'); + if($isPitHaveUser && !in_array($isPitHaveUser,$newPitUser)){ + $changePitUser[$key]['user_id'] = $isPitHaveUser; + $changePitUser[$key]['pit_number'] = $value; + } + db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $value])->update(['user_id' => $key]); + } + //处理原麦位上的用户 + foreach ($changePitUser as $key_change => $value_change){ + //判断是否在左边 1,,2,,3 麦位上 + if(in_array($value_change['pit_number'],[1,2,3])){ + $null_pit = model('api/RoomPit')->getRoomNullPitWithout($room_id, [4,5,6,7,8,9,10]); + if(empty($null_pit)){ + $null_pit = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]); + } + }else{ + $null_pit = model('api/RoomPit')->getRoomNullPitWithout($room_id, [1,2,3,7,8,9,10]); + if(empty($null_pit)){ + $null_pit = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]); + } + } + db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $null_pit])->update(['user_id' => $value_change['user_id']]); + } +// $getRoomNullPit = $this->room_pit_model->where(['room_id'=>$room_id,'pit_number'=>['notin',[7,9]]])->select(); + $getRoomNullPit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7]])->select(); + $data_users = []; + foreach($getRoomNullPit as $key_data => $value_data){ + $data_users[$key_data]['user_id'] = $value_data['user_id']; + $data_users[$key_data]['nickname'] = db::name('user')->where('id',$value_data['user_id'])->value('nickname'); + $data_users[$key_data]['avatar'] = db::name('user')->where('id',$value_data['user_id'])->value('avatar'); + $data_users[$key_data]['sex'] = db::name('user')->where('id',$value_data['user_id'])->value('sex'); + //获取用户在此房间今天的魅力值 + $charm =[]; + if($value_data['user_id']){ + $charm = db::name('vs_room_user_charm')->where(['user_id' => $value_data['user_id'],'room_id' => $room_id])->value('charm'); + } + $data_users[$key_data]['dress'] = model('Decorate')->user_decorate_detail($value_data['user_id'],1); + $data_users[$key_data]['charm'] = $charm??0; + $data_users[$key_data]['pit_number'] = $value_data['pit_number']; + } + //推送给前端消息 + $text['text'] = '房间换麦位'; + $text['list'] = $data_users; + model('api/Chat')->sendMsg(1053,$room_id,$text); + } + + } + } + + //换麦 + public function changePitToPosPair($room_id,$friendPlayPit){ + $new_pit_u = $friendPlayPit; + //按照键值排序数组 + ksort($new_pit_u); + //查询原有麦位上有用户的数据 并且重组结果,键为麦位,值为用户,值必须存在,没值则不展示 + $pit_users = db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number'=>['<',7],'user_id' => ['>', 0]]) + ->order('pit_number ASC') + ->field('pit_number,user_id')->select(); + $pit_user = []; + foreach ($pit_users as $value_pit_user){ + $pit_user[$value_pit_user['pit_number']] = $value_pit_user['user_id']; + } + //比较两个数组,无论是键的差异还是值的差异,都输出字符串”有差异“否则输出”没有差异“ + $result = array_diff_assoc($pit_user, $new_pit_u);//第一个数组中存在但其他数组中不存在的键/值对 + $result2 = array_diff_assoc($new_pit_u, $pit_user); + if(!empty($result) || !empty($result2)){//换麦 + db::name('vs_room_pit')->where(['room_id' => $room_id,'pit_number' => ['<',7]])->update(['user_id' => 0]); + //新麦位上的用户 + foreach ($new_pit_u as $key_result2 => $value_result2){ + db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $key_result2])->update(['user_id' => $value_result2]); + } + if($result){//原有麦位上的用户,且不在新麦位上的用户 + foreach ($result as $key_result => $value_result){ + $pit_null = model('api/RoomPit')->getRoomNullPitWithout($room_id, [7,8,9,10]); + $onPitUser = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $value_result])->find(); + if($pit_null && !$onPitUser){ + db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_null])->update(['user_id' => $value_result]); + } + } + } + + $getRoomNullPit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => ['<',7]])->select(); + $data_users = []; + foreach($getRoomNullPit as $key_data => $value_data){ + $data_users[$key_data]['user_id'] = $value_data['user_id']; + $data_users[$key_data]['nickname'] = db::name('user')->where('id',$value_data['user_id'])->value('nickname'); + $data_users[$key_data]['avatar'] = db::name('user')->where('id',$value_data['user_id'])->value('avatar'); + $data_users[$key_data]['sex'] = db::name('user')->where('id',$value_data['user_id'])->value('sex'); + //获取用户在此房间今天的魅力值 + $charm =[]; + if($value_data['user_id']){ + $charm = db::name('vs_room_user_charm')->where(['user_id' => $value_data['user_id'],'room_id' => $room_id])->value('charm'); + } + $data_users[$key_data]['dress'] = model('Decorate')->user_decorate_detail($value_data['user_id'],1); + $data_users[$key_data]['charm'] = $charm??0; + $data_users[$key_data]['pit_number'] = $value_data['pit_number']; + } + //推送给前端消息 + $text['text'] = '房间换麦位'; + $text['list'] = $data_users; + model('api/Chat')->sendMsg(1053,$room_id,$text); + } + + } + + + //交友厅游戏开始后送礼后一系列操作 + //插入/更新心动表 + public function addUserHeart($uid,$user_id,$friend_id,$value,$room_id,$user_data){ + //给多个用户送礼 + //数组重组 下标从0开始 + $user_ids = array_values($user_id); +// $heart_value = $value;//心动值 + $heart_value = 0; + $heart_exp = get_system_config_value('coin_charm_exp');//金币与魅力值转换比 + for ($i = 0; $i < count($user_ids); $i++) { + foreach ($user_data as $cv){ + if($user_ids[$i] == $cv['user_id']){ + $heart_value = $cv['gift_price'] * $heart_exp; + } + } + // 处理用户ID顺序 + $user1 = min($uid, $user_ids[$i]); + $user2 = max($uid, $user_ids[$i]); + // 更新心动关系表 + $relation = db::name('vs_user_friending_heart')->where([ + 'user1_id' => $user1, + 'user2_id' => $user2, + 'friend_id' => $friend_id + ])->find(); + + if ($relation) { + db::name('vs_user_friending_heart')->where([ + 'room_id' => $room_id, + 'user1_id' => $user1, + 'user2_id' => $user2, + 'friend_id' => $friend_id + ])->setInc('heart_value', $heart_value); + } else { + $relation['id'] = db::name('vs_user_friending_heart')->insert([ + 'room_id' => $room_id, + 'user1_id' => $user1, + 'user2_id' => $user2, + 'friend_id' => $friend_id, + 'heart_value' => $heart_value + ]); + } + } + //修改用户心动连线状态 +// $relation = db::name('vs_user_friending_heart')->where("(user1_id=".$uid." OR user2_id=".$uid.") AND friend_id=$friend_id AND room_id=$room_id AND status!=3")->order('heart_value desc')->find(); +// if($relation){ +// db::name('vs_user_friending_heart')->where("(user1_id=".$uid." OR user2_id=".$uid.") AND friend_id=$friend_id AND room_id=$room_id AND status!=3")->update(['status'=>2]); +// db::name('vs_user_friending_heart')->where(['id'=>$relation['id']])->update(['status'=>1]); +// } + + } +} \ No newline at end of file diff --git a/application/api/model/RoomHourRanking.php b/application/api/model/RoomHourRanking.php new file mode 100644 index 0000000..d22eb7f --- /dev/null +++ b/application/api/model/RoomHourRanking.php @@ -0,0 +1,73 @@ +where('id', 1)->value('open_time'); + if ($open_time == 0) { + return ['code' => 0, 'msg' => '排行榜暂未开启', 'data' => null]; + } + + //是否开启巡乐会 + $is_open_xlh = db::name('vs_hour_ranking_config')->where('id', 1)->value('is_open_xlh'); + + // 更进一步的优化版本: + $subQuery = Db::name('vs_give_gift') + ->where('from', 2) + ->whereBetween('createtime', [$start_time, $end_time]) + ->buildSql(); + + $profit = db::name('vs_room')->alias('a') + ->join([$subQuery => 'b'], 'a.id = b.from_id', 'left') + ->join('vs_room_label c', 'a.label_id = c.id','left') + ->field('a.id as room_id,a.user_id,a.room_name,a.label_id,a.room_cover,IFNULL(SUM(b.total_price), 0) as total_price,c.label_icon') + ->where('a.room_status', 1) + ->where('a.apply_status', 2) + ->where('a.type_id', '<>', 6) + ->group('a.id') + ->order('total_price', 'desc') + ->page($page, $page_limit) + ->select(); + + if($profit){ + foreach ($profit as &$v) { + $v['total_price'] = $v['total_price'] * get_system_config_value('coin_charm_exp'); + if($v['room_id'] > 0 && $is_open_xlh == 1){ + $xlh_status = model('BlindBoxTurntableGift')->get_user_xlh_info($v['room_id']); + $v['xlh_status'] = $xlh_status['xlh_status']; + }else{ + $v['xlh_status'] = 0; + } + //查询房间是否有红包 + if($v['room_id'] > 0){ + $red_pack_status = Db::name('redpacket')->where(['room_id' => $v['room_id'], 'status' => ['<=',1]])->count(); + $v['redpacket_status'] = $red_pack_status; + }else{ + $v['redpacket_status'] = 0; + } + } + } + //当前小时开始时间 和结束时间 00:00-00:59 这样的格式 + $time_range = date('H:') . '00-' . date('H:'). '59'; + return ['code' => 1, 'msg' => '获取成功', 'data' => ['time_range' => $time_range, 'lists' =>$profit]]; + } + +} \ No newline at end of file diff --git a/application/common/library/RedpacketLua.php b/application/common/library/RedpacketLua.php new file mode 100644 index 0000000..e5359ae --- /dev/null +++ b/application/common/library/RedpacketLua.php @@ -0,0 +1,114 @@ + endTime then + redis.call('HSET', redpacketKey, 'status', 2) + return {0, "红包已结束", 0} +end + +-- 检查是否已经抢过 +local hasGrabbed = redis.call('SISMEMBER', userSetKey, userId) +if hasGrabbed == 1 then + return {0, "已经抢过该红包", 0} +end + +-- 检查是否还有剩余 +local leftAmount = tonumber(redpacket['left_amount']) +local leftCount = tonumber(redpacket['left_count']) + +if leftCount <= 0 or leftAmount <= 0 then + return {0, "红包已抢完", 0} +end + +-- 计算红包金额 +local amount = 0 +local isFinished = 0 + +if leftCount == 1 then + -- 最后一个红包,获得剩余所有金额 + amount = leftAmount + isFinished = 1 +else + -- 随机算法:二倍均值法,保证公平性 + local maxAmount = leftAmount / leftCount * 2 + amount = math.random(1, math.floor(maxAmount)) + -- 确保金额不会超过剩余金额 + if amount > leftAmount then + amount = leftAmount + end + -- 检查是否是最后一个(由于浮点数计算可能有误差) + if leftCount == 1 or (leftAmount - amount) < 0.01 then + isFinished = 1 + end +end + +-- 更新红包数据 +local newLeftAmount = leftAmount - amount +local newLeftCount = leftCount - 1 + +redis.call('HSET', redpacketKey, 'left_amount', newLeftAmount) +redis.call('HSET', redpacketKey, 'left_count', newLeftCount) + +-- 标记用户已抢 +redis.call('SADD', userSetKey, userId) + +-- 如果抢完了,更新状态为已结束(2) +if isFinished == 1 then + redis.call('HSET', redpacketKey, 'status', 2) +end + +return {1, tostring(amount), isFinished} +LUA; + } + + +} \ No newline at end of file diff --git a/application/common/model/Redpacket.php b/application/common/model/Redpacket.php new file mode 100644 index 0000000..0d4405d --- /dev/null +++ b/application/common/model/Redpacket.php @@ -0,0 +1,171 @@ + '立刻', + 60 => '1分钟', + 120 => '2分钟', + 300 => '5分钟', + 600 => '10分钟' + ]; + + // 领取条件 + const CONDITION_NONE = 0; + const CONDITION_COLLECT_ROOM = 1; + const CONDITION_MIC_USER = 2; + + protected $autoWriteTimestamp = true; + protected $createTime = 'createtime'; + protected $updateTime = 'updatetime'; + + /** + * 发红包 + */ + public function createRedpacket($data) + { +// var_dump($data);exit; + Db::startTrans(); + try { + // 验证用户余额 + $wallet = Db::name('user_wallet')->where('user_id', $data['user_id'])->find(); + + $coinField = $data['coin_type'] == self::COIN_GOLD ? 'coin' : 'earnings'; + if ($wallet[$coinField] < $data['total_amount']) { + return ['code' => 0, 'msg' => '余额不足', 'data' => null]; + } + + // 扣除余额 + $delres = Db::name('user_wallet') + ->where('user_id', $data['user_id']) + ->dec($coinField, $data['total_amount']) + ->update(); + //记录日志 32-发红包(金币),29-发红包(钻石),30-抢红包(金币),31-抢红包(钻石) + //记录用户金币日志 + $data_log = [ + 'user_id' => $data['user_id'], + 'change_value' => $data['total_amount'], + 'room_id' => $data['room_id'], + 'money_type' => $data['coin_type'], + 'change_type' => $data['coin_type'] == self::COIN_GOLD ? 32 : 29, + 'from_id' => $data['room_id'], + 'remarks' => $data['coin_type'] == self::COIN_GOLD ? '金币(发红包)' : '钻石(发红包)', + 'createtime' => time() + ]; + + $res = Db::name('vs_user_money_log')->insert($data_log); + if(!$res || !$delres){ + Db::rollback(); + } + // 计算开始时间 + $startTime = $data['countdown'] > 0 ? (time() + $data['countdown']) : time(); + //获取配置项 红包没有抢完所展示时间 + $endTime = $startTime + get_system_config_value('red_packet_time') ?? 120; // 默认2分钟后结束 + + // 创建红包 + $redpacketData = [ + 'user_id' => $data['user_id'], + 'room_id' => $data['room_id'], + 'type' => $data['type'], + 'password' => $data['password'] ?? '', + 'countdown' => $data['countdown'], + 'coin_type' => $data['coin_type'], + 'total_amount' => $data['total_amount'], + 'total_count' => $data['total_count'], + 'left_amount' => $data['total_amount'], + 'left_count' => $data['total_count'], + 'conditions' => $data['conditions'] ?? '', + 'status' => $data['countdown'] > 0 ? self::STATUS_PENDING : self::STATUS_ACTIVE, + 'start_time' => $startTime, + 'end_time' => $endTime, + 'createtime' => time(), + 'remark' => (!empty($data['remark']) && trim($data['remark']) !== '') ? trim($data['remark']) : '大吉大利,红包拿来啦!' + ]; + + $redpacketId = $this->insertGetId($redpacketData); + + // 设置Redis缓存 + $redis = \think\Cache::store('redis')->handler(); + $redisKey = "redpacket:{$redpacketId}"; + $redis->hMSet($redisKey, [ + 'total_amount' => $data['total_amount'], + 'left_amount' => $data['total_amount'], + 'total_count' => $data['total_count'], + 'left_count' => $data['total_count'], + 'status' => $redpacketData['status'], + 'start_time' => $startTime, + 'end_time' => $endTime + ]); + + // 设置过期时间 + $redis->expireAt($redisKey, $endTime + 3600); // 结束后保留1小时 + Db::commit(); + + //给前端推送信息 + $data['nickname'] = Db::name('user')->where('id', $data['user_id'])->value('nickname'); + $data['avatar'] = Db::name('user')->where('id', $data['user_id'])->value('avatar'); + $data['redpacket_id'] = $redpacketId; + $data['start_time'] = $startTime;//红包开抢时间 + $data['redpacket_time'] = get_system_config_value('red_packet_time');//展示时间 + $data['room_name'] = Db::name('vs_room')->where('id', $data['room_id'])->value('room_name'); + $text = [ + 'redpacketInfo' => $data, + 'text' => '' + ]; + model('api/Chat')->sendMsg(1060,$data['room_id'],$text); + $push = new Push(UID, $data['room_id']); + $texts = [ + 'room_id' => $data['room_id'], + 'text' => $data['nickname'].'在'.$data['room_name'].'房间发了一个红包!', + 'room_name' => $data['room_name'], + 'nickname' => $data['nickname'] + ]; + $push->redpacketArrive($texts); + + return ['code' => 1, 'msg' => '发红包成功', 'data' => $redpacketId]; + + } catch (\Exception $e) { + Db::rollback(); + return ['code' => 0, 'msg' => $e->getMessage(), 'data' => null]; + } + } + + /** + * 获取红包信息 + */ + public function getRedpacketInfo($id) + { + $redpacket = $this->find($id); + if (!$redpacket) { + return null; + } + + $redpacket = $redpacket->toArray(); + $redpacket['nickname'] = Db::name('user')->where('id', $redpacket['user_id'])->value('nickname'); + $redpacket['avatar'] = Db::name('user')->where('id', $redpacket['user_id'])->value('avatar'); + $redpacket['redpacket_id'] = $redpacket['id']; + + return $redpacket; + } +} \ No newline at end of file diff --git a/application/common/model/RedpacketRecord.php b/application/common/model/RedpacketRecord.php new file mode 100644 index 0000000..3bf1f2f --- /dev/null +++ b/application/common/model/RedpacketRecord.php @@ -0,0 +1,12 @@ +validateCreateData($data); + if ($res['code'] == 0) { + return $res; + } + + $redpacketModel = new Redpacket(); + return $redpacketModel->createRedpacket($data); + } + + + /** + * 抢红包并返回详细结果 + */ + public function grabWithResult($redpacketId, $userId) + { + $redpacketModel = new Redpacket(); + $redpacket = $redpacketModel->getRedpacketInfo($redpacketId); + + if (!$redpacket) { + return [ + 'code' => 0, + 'msg' => '红包不存在', + 'data' => null + ]; + } + + // 验证领取条件 + $conditionCheck = $this->checkConditionsWithResult($redpacket, $userId); + if ($conditionCheck['code'] != 1) { + return $conditionCheck; + } + + // 检查红包状态 + $statusCheck = $this->checkRedpacketStatus($redpacket); + if ($statusCheck['code'] != 1) { + return $statusCheck; + } + + // 检查是否已经抢过 + if ($this->hasUserGrabbed($redpacketId, $userId)) { +// $detail = $this->getGrabResult($redpacketId, $userId); + return [ + 'code' => 1, + 'msg' => '已经抢过该红包', + 'data' => ['code' => 2] //1-抢到了,2-已经抢过红包,3-没有抢到 + ]; + } + + // 使用Redis+Lua保证原子性操作 + $redis = Cache::store('redis')->handler(); + $script = RedpacketLua::grabRedpacketScript(); + + $redpacketKey = "redpacket:{$redpacketId}"; + $userSetKey = "redpacket_users:{$redpacketId}"; + + $result = $redis->eval($script, [ + $redpacketKey, + $userSetKey, + $userId, + time() + ], 3); + + if ($result[0] == 0) { + $message = $result[1]; + if ($message == '红包已抢完') { + return [ + 'code' => 1, + 'msg' => '手慢了,红包已抢完', + 'data' => ['code' => 3] //1-抢到了,2-已经抢过红包,3-没有抢到 + ]; + } elseif ($message == '已经抢过该红包') { + return [ + 'code' => 1, + 'msg' => '已经抢过该红包', + 'data' => ['code' => 2] //1-抢到了,2-已经抢过红包,3-没有抢到 + ]; + }elseif ($message == '红包已结束') { + return [ + 'code' => 1, + 'msg' => '手慢了,红包已抢完', + 'data' => ['code' => 3] //1-抢到了,2-已经抢过红包,3-没有抢到 + ]; + } + else{ + return [ + 'code' => 0, + 'msg' => $message, + 'data' => null + ]; + } + } + + $amount = floatval($result[1]); + $isFinished = $result[2] == 1; // Lua脚本返回是否抢完 + //给前端推送销毁这个红包 + // redis 记录该红包是否已经推送过了 只推送一次 + if($isFinished){ + $redisKey = "redpacket:{$redpacketId}:is_finished"; + if (!Cache::get($redisKey)) { + Cache::set($redisKey, 1, $redpacket['countdown']+get_system_config_value('red_packet_time')+60); + $text = [ + 'redpacket_id' => $redpacketId, + 'text' => '抢完了,请销毁该红包' + ]; + model('api/Chat')->sendMsg(1061,$redpacket['room_id'],$text); + } + } + + // Lua脚本执行成功,记录到数据库 + Db::startTrans(); + try { + // 创建领取记录 + $recordData = [ + 'redpacket_id' => $redpacketId, + 'user_id' => $userId, + 'amount' => $amount + ]; + + $recordModel = new RedpacketRecord(); + $recordModel->save($recordData); + + // 更新用户钱包 + $coinField = $redpacket['coin_type'] == 1 ? 'coin' : 'earnings'; + //增加余额 + $addres = Db::name('user_wallet') + ->where('user_id', $userId) + ->inc($coinField, $amount) + ->update(); + //记录用户金币日志 + $data = [ + 'user_id' => $userId, + 'change_value' => $amount, + 'room_id' => $redpacket['room_id'], + 'money_type' => $redpacket['coin_type'], + //记录日志 32-发红包(金币),29-发红包(钻石),30-抢红包(金币),31-抢红包(钻石) + 'change_type' => $redpacket['coin_type'] == 1 ? 30 : 31, + 'from_id' => $redpacket['room_id'], + 'remarks' => '抢红包收入', + 'createtime' => time() + ]; + + $res = Db::name('vs_user_money_log')->insert($data); + if(!$res || !$addres){ + Db::rollback(); + } + + // 更新红包剩余数量和金额,如果抢完了更新状态 + $updateData = [ + 'left_amount' => Db::raw('left_amount - ' . $amount), + 'left_count' => Db::raw('left_count - 1'), + 'updatetime' => time() + ]; + + if ($isFinished) { + $updateData['status'] = Redpacket::STATUS_FINISHED; + } + + Db::name('redpacket') + ->where('id', $redpacketId) + ->update($updateData); + + Db::commit(); + + // 获取抢红包结果详情 + $grabResult = $this->getGrabResult($redpacketId, $userId); + unset($grabResult['previous_records']);//前端不要 + unset($grabResult['all_records']);//前端不要 + unset($grabResult['statistics']);//前端不要 + + return [ + 'code' => 1, + 'msg' => '抢红包成功', +// 'data' => $grabResult +// 'data' => null + 'data' => ['code' => 1] //1-抢到了,2-已经抢过红包,3-没有抢到 + ]; + + } catch (\Exception $e) { + Db::rollback(); + // 回滚Redis操作 + $redis->hIncrByFloat($redpacketKey, 'left_amount', $amount); + $redis->hIncrBy($redpacketKey, 'left_count', 1); + $redis->sRem($userSetKey, $userId); + + return [ + 'code' => 0, + 'msg' => '系统错误,请重试'.$e->getMessage(), + 'data' => null + ]; + } + } + + /** + * 获取抢红包结果详情 + */ + public function getGrabResult($redpacketId, $userId) + { + // 获取红包基本信息 + $redpacket = Db::name('redpacket') + ->where('id', $redpacketId) + ->find(); + + if (!$redpacket) { + return null; + } + + // 获取当前用户的领取记录 + $myRecord = Db::name('redpacket_record') + ->alias('r') + ->field('r.*, u.nickname, u.avatar') + ->join('user u', 'u.id = r.user_id') + ->where('r.redpacket_id', $redpacketId) + ->where('r.user_id', $userId) + ->find(); + + // 获取在我之前抢到的用户记录 + $previousRecords = []; + if ($myRecord) { + $previousRecords = Db::name('redpacket_record') + ->alias('r') + ->field('r.*, u.nickname, u.avatar') + ->join('user u', 'u.id = r.user_id') + ->where('r.redpacket_id', $redpacketId) + ->where('r.createtime', '<', $myRecord['createtime']) + ->order('r.createtime ASC') + ->select(); + } + + // 获取所有记录用于统计 + $allRecords = Db::name('redpacket_record') + ->alias('r') + ->field('r.*, u.nickname, u.avatar') + ->join('user u', 'u.id = r.user_id') + ->where('r.redpacket_id', $redpacketId) + ->order('r.createtime ASC') + ->select(); + + // 统计信息 + $totalGrabbed = count($allRecords); + $totalAmount = array_sum(array_column($allRecords, 'amount')); + + // 手气最佳 + $bestRecord = null; + if ($allRecords) { + $maxAmount = max(array_column($allRecords, 'amount')); + foreach ($allRecords as $record) { + if ($record['amount'] == $maxAmount) { + $bestRecord = $record; + break; + } + } + } + + return [ + 'redpacket_info' => [ + 'id' => $redpacket['id'], + 'total_amount' => $redpacket['total_amount'], + 'total_count' => $redpacket['total_count'], + 'left_amount' => $redpacket['left_amount'], + 'left_count' => $redpacket['left_count'], + 'coin_type' => $redpacket['coin_type'], + 'status' => $redpacket['status'], + 'nickname' => Db::name('user')->where('id', $redpacket['user_id'])->value('nickname') + ], + 'my_record' => $myRecord ? [ + 'amount' => $myRecord['amount'], + 'createtime' => $myRecord['createtime'], + 'nickname' => $myRecord['nickname'], + 'avatar' => $myRecord['avatar'] + ] : null, + 'previous_records' => $previousRecords, + 'all_records' => $allRecords, + 'statistics' => [ + 'total_grabbed' => $totalGrabbed, + 'total_amount_grabbed' => $totalAmount, + 'best_luck' => $bestRecord ? [ + 'nickname' => $bestRecord['nickname'], + 'avatar' => $bestRecord['avatar'], + 'amount' => $bestRecord['amount'] + ] : null + ] + ]; + } + + /** + * 检查红包状态 + */ + private function checkRedpacketStatus($redpacket) + { + $now = time(); + + if ($redpacket['status'] == Redpacket::STATUS_PENDING) { + if ($now < $redpacket['start_time']) { + return [ + 'code' => 0, + 'msg' => '红包还未开始', + 'data' => null + ]; + } + } + +// if ($redpacket['status'] == Redpacket::STATUS_FINISHED || +// $redpacket['status'] == Redpacket::STATUS_REFUNDED) { +// return [ +// 'code' => 0, +// 'msg' => '红包已结束', +// 'data' => null +// ]; +// } +// +// if ($now > $redpacket['end_time']) { +// return [ +// 'code' => 0, +// 'msg' => '红包已结束', +// 'data' => null +// ]; +// } + + return ['code' => 1]; + } + + /** + * 检查用户是否已经抢过 + */ + private function hasUserGrabbed($redpacketId, $userId) + { + $record = Db::name('redpacket_record') + ->where('redpacket_id', $redpacketId) + ->where('user_id', $userId) + ->find(); + + return !empty($record); + } + + /** + * 检查领取条件(返回结果格式) + */ + private function checkConditionsWithResult($redpacket, $userId) + { + $conditions = $redpacket['conditions'] ? explode(',', $redpacket['conditions']): []; + + if (empty($conditions)) { + return ['code' => 1]; + } + + if (in_array(Redpacket::CONDITION_NONE, $conditions)) { + return ['code' => 1]; + } + + foreach ($conditions as $condition) { + switch ($condition) { + case Redpacket::CONDITION_COLLECT_ROOM: + if (!$this->checkUserCollectedRoom($userId, $redpacket['room_id'])) { + return [ + 'code' => 0, + 'msg' => '不满足收藏房间条件', + 'data' => null + ]; + } + break; + + case Redpacket::CONDITION_MIC_USER: + if (!$this->checkUserOnMic($userId, $redpacket['room_id'])) { + return [ + 'code' => 0, + 'msg' => '您不是麦上用户', + 'data' => null + ]; + } + break; + } + } + + return ['code' => 1]; + } + + + /** + * 获取红包详情和领取记录 + */ + public function getDetail($redpacketId, $currentUserId = 0) + { + $redpacketModel = new Redpacket(); + $redpacket['redpacket_info'] = $redpacketModel->getRedpacketInfo($redpacketId); + + if (!$redpacket) { + return null; + } + + // 获取领取记录 + $records = Db::name('redpacket_record') + ->alias('r') + ->field('r.*, u.nickname, u.avatar') + ->join('user u', 'u.id = r.user_id') + ->where('r.redpacket_id', $redpacketId) + ->order('r.createtime ASC') + ->select(); + //处理createtime 字段 + $records = array_map(function ($record) { + $record['createtime'] = date('Y-m-d H:i:s', $record['createtime']); + return $record; + }, $records); + + $redpacket['records'] = $records; + + // 检查当前用户是否已抢 + $redpacket['has_grabbed'] = false; + $redpacket['my_record'] = null; + + if ($currentUserId > 0) { + foreach ($records as $record) { + if ($record['user_id'] == $currentUserId) { + $redpacket['has_grabbed'] = true; + $redpacket['my_record'] = $record; + break; + } + } + } + + return $redpacket; + } + + /** + * 处理过期红包退款 + */ + public function processExpiredRedpackets() + { + $now = time(); + $redpacketModel = new Redpacket(); + + // 查找已结束但未退款的红包 + $expiredRedpackets = Db::name('redpacket') + ->where('status', Redpacket::STATUS_ACTIVE) + ->where('end_time', '<', $now) + ->where('left_count', '>', 0) + ->select(); + + foreach ($expiredRedpackets as $redpacket) { + Db::startTrans(); + try { + // 退款给发红包用户 + if ($redpacket['left_amount'] > 0) { + $walletModel = new UserWallet(); + $walletModel->increaseBalance( + $redpacket['user_id'], + $redpacket['coin_type'], + $redpacket['left_amount'] + ); + } + + // 更新红包状态 + Db::name('redpacket') + ->where('id', $redpacket['id']) + ->update([ + 'status' => Redpacket::STATUS_REFUNDED, + 'updatetime' => $now + ]); + + // 清理Redis缓存 + $redis = Cache::store('redis')->handler(); + $redisKey = "redpacket:{$redpacket['id']}"; + $redis->del($redisKey); + + Db::commit(); + + } catch (\Exception $e) { + Db::rollback(); + // 记录日志 + \think\Log::error("红包退款失败: {$redpacket['id']}, 错误: " . $e->getMessage()); + } + } + } + + + + /** + * 验证创建红包数据 + */ + private function validateCreateData($data) + { + if (empty($data['user_id'])) { + return ['code' => 0, 'msg' => '用户ID不能为空', 'data' => null]; + } + + if (empty($data['room_id'])) { + return ['code' => 0, 'msg' => '房间ID不能为空', 'data' => null]; + } + + if (!in_array($data['type'], [Redpacket::TYPE_NORMAL, Redpacket::TYPE_PASSWORD])) { + return ['code' => 0, 'msg' => '红包类型错误', 'data' => null]; + } + + if ($data['type'] == Redpacket::TYPE_PASSWORD && empty($data['password'])) { + return ['code' => 0, 'msg' => '口令红包必须设置口令', 'data' => null]; + } + + if (!in_array($data['coin_type'], [Redpacket::COIN_GOLD, Redpacket::COIN_DIAMOND])) { + return ['code' => 0, 'msg' => '币种类型错误', 'data' => null]; + } + + if ($data['total_amount'] <= 0 || $data['total_count'] <= 0) { + return ['code' => 0, 'msg' => '金额和数量必须大于0', 'data' => null]; + } + + if ($data['total_amount'] < $data['total_count']) { + return ['code' => 0, 'msg' => '总金额不能小于总个数', 'data' => null]; + } + + // 验证领取条件 + if (isset($data['conditions'])) { + $res_con = $this->validateConditions($data['conditions']); + if ($res_con !== true) { + return $res_con; + } + } + + return ['code' => 1, 'msg' => '验证成功', 'data' => null]; + } + + + /** + * 验证领取条件 + */ + private function validateConditions($conditions) + { + if (empty($conditions)) { + return true; + } + + //字符串转为数组 + $conditions = explode(',', $conditions); + + if (in_array(Redpacket::CONDITION_NONE, $conditions) && count($conditions) > 1) { + return V(0, '选择"无"条件时不能选择其他条件'); + } + return true; + } + + /** + * 检查用户是否满足领取条件 + */ + private function checkConditions($redpacket, $userId) + { + $conditions = $redpacket['conditions'] ?: []; + + if (empty($conditions)) { + return true; + } + + if (in_array(Redpacket::CONDITION_NONE, $conditions)) { + return true; + } + + foreach ($conditions as $condition) { + switch ($condition) { + case Redpacket::CONDITION_COLLECT_ROOM: + // 检查用户是否收藏了房间 + if (!$this->checkUserCollectedRoom($userId)) { + throw new \Exception('不满足收藏房间条件'); + } + break; + + case Redpacket::CONDITION_MIC_USER: + // 检查用户是否在麦位上 + if (!$this->checkUserOnMic($userId)) { + throw new \Exception('不满足麦位用户条件'); + } + break; + } + } + + return true; + } + + /** + * 检查用户是否收藏了房间(需要根据实际业务实现) + */ + private function checkUserCollectedRoom($userId,$roomId) + { + $collect = Db::name('user_follow')->where(['user_id' => $userId,'type' => 2,'follow_id' => $roomId])->find(); + if (!$collect) { + return false; + } + return true; + } + + /** + * 检查用户是否在麦位上(需要根据实际业务实现) + */ + private function checkUserOnMic($userId,$roomId) + { + $room_type = Db::name('vs_room')->where('id',$roomId)->field('type_id,label_id')->find(); + //实际麦位 + if($room_type['type_id'] == 1 || $room_type['type_id'] == 7 || $room_type['type_id'] == 8){ + $onPit = Db::name('vs_room_pit')->where(['user_id' => $userId,'room_id' => $roomId])->value('pit_number'); + if ($onPit <= 0){ + return false; + } + }elseif($room_type['type_id'] ==2){//拍卖 + //获取房间的当前拍卖ID + $auctionId = Db::name('vs_room_auction')->where(['room_id' => $roomId,'status' => 2])->value('auction_id'); + $onPit = []; + if($auctionId){ + $onPits = model('api/RoomAuction')->room_auction_list_on($auctionId); + //提取数组里面的user_id的值 来判断用户是否在里面 + $onPit = array_column($onPits,'user_id'); + //拍卖位 从缓存中取 Cache::get('auction_user_'.$room_id) + $onpitNumber_10 = Cache::get('auction_user_'.$roomId); + if($onpitNumber_10){ + $onPit[] = $onpitNumber_10; + } + } + $onpitNumber_9 = Db::name('vs_room_pit')->where(['pit_number' => 9,'room_id' => $roomId])->value('user_id'); + if($onpitNumber_9){ + $onPit[] = $onpitNumber_9; + } + + if (!in_array($userId,$onPit)){ + return false; + } + } + + return true; + } + + /** + * 检查并更新红包状态 + * 在抢红包前调用,确保状态正确 + */ + public function checkAndUpdateRedpacketStatus($redpacketId) + { + $redpacket = Db::name('redpacket')->where('id', $redpacketId)->find(); + if (!$redpacket) { + return false; + } + + $now = time(); + $redis = Cache::store('redis')->handler(); + $redpacketKey = "redpacket:{$redpacketId}"; + + // 如果红包状态为未开始(0),但当前时间已超过开始时间,则更新为进行中(1) + if ($redpacket['status'] == Redpacket::STATUS_PENDING && $now >= $redpacket['start_time']) { + Db::name('redpacket') + ->where('id', $redpacketId) + ->update([ + 'status' => Redpacket::STATUS_ACTIVE, + 'updatetime' => $now + ]); + + // 更新Redis中的状态 + $redis->hSet($redpacketKey, 'status', Redpacket::STATUS_ACTIVE); + + return true; + } + + // 如果红包状态为进行中(1),但已抢完,则更新为已结束(2) + if ($redpacket['status'] == Redpacket::STATUS_ACTIVE && $redpacket['left_count'] <= 0) { + Db::name('redpacket') + ->where('id', $redpacketId) + ->update([ + 'status' => Redpacket::STATUS_FINISHED, + 'updatetime' => $now + ]); + + // 更新Redis中的状态 + $redis->hSet($redpacketKey, 'status', Redpacket::STATUS_FINISHED); + + return true; + } + + // 如果红包状态为进行中(1),但已超过结束时间,则更新为已结束(2) + if ($redpacket['status'] == Redpacket::STATUS_ACTIVE && $now > $redpacket['end_time']) { + Db::name('redpacket') + ->where('id', $redpacketId) + ->update([ + 'status' => Redpacket::STATUS_FINISHED, + 'updatetime' => $now + ]); + + // 更新Redis中的状态 + $redis->hSet($redpacketKey, 'status', Redpacket::STATUS_FINISHED); + + return true; + } + + return false; + } +} \ No newline at end of file diff --git a/application/cron/controller/FriendEnd.php b/application/cron/controller/FriendEnd.php new file mode 100644 index 0000000..52e4e8b --- /dev/null +++ b/application/cron/controller/FriendEnd.php @@ -0,0 +1,56 @@ +clearFriendingEndRoom();//清除交友房过期未结束数据 + echo "清除结束 \n"; + + echo "清除私密小屋过期数据开始:\n"; + $this->clear_room_end();//清除私密小屋过期数据 + echo "清除私密小屋过期数据结束 \n"; + } + + + //清除交友房过期未结束数据 + public function clearFriendingEndRoom() + { + //清除交友房过期数据 + $room_list = db::name('vs_room')->where(['type_id'=>7])->whereIn('step', [2,3]) + ->field(['id','step'])->select(); + if(!empty($room_list)){ + foreach ($room_list as $room) { + //查询交友信息 + $friending_info = db::name('vs_user_friending')->where('room_id', $room['id'])->where('status', 1)->order('id', 'desc')->find(); + if($friending_info){ + //判断结束时间是否到期 + if($friending_info['end_time'] <= time() || $room['step'] == 3){ + model('Friend')->end_friend(0,$room['id'],$friending_info['id'],1); + } + } + } + } + + } + + + //清除私密小屋过期数据 + public function clear_room_end() + { + $room_list = db::name('vs_room_cp_movie')->where(['status' => 1,'type'=>1,'time_day' =>['<',time()]])->select(); + if(!empty($room_list)){ + foreach ($room_list as $room) { + model('Friend')->outRoom(0,$room['room_id']); + } + } + } +} \ No newline at end of file diff --git a/application/cron/controller/RoomHourRanking.php b/application/cron/controller/RoomHourRanking.php new file mode 100644 index 0000000..b2f768e --- /dev/null +++ b/application/cron/controller/RoomHourRanking.php @@ -0,0 +1,405 @@ +send_gift();//小时榜 送礼物 + echo "发礼物结束 \n"; + + } + + public function send_gift() + { + //获取上一个小时的开始时间和结束时间 + $start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour'))); + $end_time = strtotime(date('Y-m-d H:00:00')); + echo "开始时间:" .$start_time."\n"; + echo "结束时间:" .$end_time."\n"; + //当前小时的前一个小时(24小时计时法,0-23) + $pre_hour = date('H', strtotime('-1 hour')); + echo "上个时间段:" .$pre_hour."\n"; + $is_open_time = db::name('vs_hour_ranking_config')->where('id', 1)->value('open_time'); + if ($is_open_time == 0) { + echo "未开启时间段:" .$is_open_time."\n"; + return; + } + //是否全局飘瓶 + $is_public_server = db::name('vs_hour_ranking_config')->where('id', 1)->value('is_public_server'); + if ($is_public_server == 1) { + //全局飘瓶时间段 + $xlh_time_range = db::name('vs_hour_ranking_config')->where('id', 1)->value('broadcast_times'); + if($xlh_time_range){ + if($xlh_time_range == 25){ + $is_piao = 1; + }else{ + + //当前的前一个小时是否在 $xlh_time_range中 + if (in_array($pre_hour, explode(',', $xlh_time_range))) { + $is_piao = 1; + } else { + $is_piao = 0; + } + } + }else{ + $is_piao = 0; + } + }else{ + $is_piao = 0; + } + + //获取上一个时间段的配置 +// $gift_list = db::name('vs_hour_ranking_gift_config')->where('time_id',$pre_hour)->group('ranking')->order('id', 'desc')->select(); + $gift_list = $this->get_hour_ranking($pre_hour); +// echo "上个时间段的配置:" .json_encode($gift_list)."\n"; + // 提取所有有奖励的内容 + $allRewards = $this->extractAllRewards($gift_list); + // 按index分组 + $groupedRewards = $this->groupRewardsByIndex($allRewards); + // 按名次顺序分配奖励 + $distributionResult = $this->distributeByRank($groupedRewards); + + //获取上个数组的个数,从而获取配置了多少个名次 + $count = count($distributionResult); + echo "上个时间段的配置总数:" .$count."\n"; + //获取前一个小时的 前$count名房间排行 + $room_list = model('api/RoomHourRanking')->room_hour_ranking(1, $count, $start_time, $end_time); + $room_owner = []; + if ($room_list['code'] == 1) { + //获取房间排行奖励最低值 + $min_price = db::name('vs_hour_ranking_config')->where('id', 1)->value('min_price'); + if ($room_list['data']['lists']) { + echo "房间列表:" .json_encode($room_list['data']['lists'])."\n"; + foreach ($room_list['data']['lists'] as $v){ + if ($v['total_price'] >= $min_price) { + $room_owner[] = [ + 'user_id' => $v['user_id'], + 'room_name' => $v['room_name'], + 'room_id' => $v['room_id'], + 'total_price' => $v['total_price'] + ]; + } + } + } + } + + if ($distributionResult && $room_owner) { + $text_list_new = []; + echo "礼物数:" .json_encode($distributionResult)."\n"; + echo "房主:" .json_encode($room_owner)."\n"; + foreach ($distributionResult as $k => $value) { + //礼物全部给他偷偷放在装扮表及金额 中 + //有几个用户就发几个 + if(count($room_owner) > $k){ + // 为每个房间添加一个标志,表示是否已处理推送信息 + $hasProcessedPush = false; + + foreach ($value['rewards'] as $v){ + if($v['type'] == 0){//1金币2礼物3头像4坐骑 + echo "发金币:" .$v['value'].'==>'.$room_owner[$k]['user_id']."\n"; + $res = $this->add_coin($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao); + }elseif ($v['type'] == 1){ + echo "发礼物:" .$v['value'].'==>'.$room_owner[$k]['user_id']."\n"; + $res = $this->add_gift($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao); + }elseif ($v['type'] == 2){ + $res = $this->add_decorate($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao,3); + }elseif ($v['type'] == 3){ + $res = $this->add_decorate($v['value'], $room_owner[$k]['user_id'],$k + 1,$room_owner[$k]['room_id'],$room_owner[$k]['total_price'],$is_piao,4); + } + // 只有在第一次处理奖励时添加推送信息,避免重复推送 + if(!$hasProcessedPush && $is_piao == 1) { + $room_name = $room_owner[$k]['room_name']; + //推送礼物横幅 + if ($k == 0) { + $text = '新科状元!【' . $room_name . '】独占鳌头!'; + } elseif ($k == 1) { + $text = '金榜榜眼!【' . $room_name . '】才气逼人!'; + } elseif ($k == 2) { + $text = '风采探花!【' . $room_name . '】实力绽放!'; + } + + $text_list_new[] = [ + 'text' => $text ?? '恭喜【' . $room_name . '】获得礼物!', + 'room_id' => $room_owner[$k]['room_id'], + 'room_name' => $room_name, + 'rank_number' => $k + 1, + ]; + + $hasProcessedPush = true; // 标记已处理推送 + } + } + + } + } + if(!empty($text_list_new)){ + $push = new Push(); + $push->hourRanking($text_list_new); + } + } + echo "送礼-共" . count($room_owner) . "个房间房主获益\n"; + } + + //添加金币到钱包 + public function add_coin($coin,$user_id,$ranking,$room_id,$total_price,$is_piao){ + if($coin > 0){ + $data = [ + 'user_id' => $user_id, + 'change_value' => $coin, +// 'room_id' => $room_ids, + 'money_type' => 1, + 'change_type' => 27, + 'from_id' => 0, + 'remarks' => '小时榜获得', + 'createtime' => time() + ]; + + //开启事务 + Db::startTrans(); + $res = Db::name('vs_user_money_log')->insert($data); + if(!$res){ + Db::rollback(); + } + + //增加用户金币 + $res1 = Db::name('user_wallet')->where(['user_id'=>$user_id])->setInc('coin',$coin); + if(!$res1){ + Db::rollback(); + } + + //添加到排行表 + $start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour'))); + $end_time = strtotime(date('Y-m-d H:00:00')) - 1; + $res2 = db::name('vs_hour_ranking')->insert([ + 'ranking' => $ranking, + 'room_id' => $room_id, + 'flowing_water' => $total_price, + 'coin' => $coin, + 'time_id' => date('H', strtotime('-1 hour')), + 'stime' => $start_time, + 'etime' => $end_time, + 'createtime' => time(), + 'updatetime' => time(), + 'is_public_server' => $is_piao + ]); + if(!$res2){ + Db::rollback(); + } + Db::commit(); + } + + return true; + } + + //添加礼物到背包 + public function add_gift($gift_id,$user_id,$ranking,$room_id,$total_price,$is_piao){ + $res = model('api/UserGiftPack')->change_user_gift_pack($user_id,$gift_id,1,model('UserGiftPack')::HOUR_RANK_GET,"小时榜获得"); + if($res['code'] == 0){ + Log::record("小时榜获取礼物失败:".$res['msg'],"info"); + } + + //添加到排行表 + $start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour'))); + $end_time = strtotime(date('Y-m-d H:00:00')) - 1; + $res2 = db::name('vs_hour_ranking')->insert([ + 'ranking' => $ranking, + 'room_id' => $room_id, + 'flowing_water' => $total_price, + 'gift_id' => $gift_id, + 'gift_type' => 2, + 'time_id' => date('H', strtotime('-1 hour')), + 'stime' => $start_time, + 'etime' => $end_time, + 'createtime' => time(), + 'updatetime' => time(), + 'is_public_server' => $is_piao + ]); + if(!$res2){ + Log::record("小时榜礼物锁定失败","info"); + } + return true; + } + + //添加装扮到背包 + public function add_decorate($avatar_id,$user_id,$ranking,$room_id,$total_price,$is_piao,$type){ + $decorate_price_info = db::name('vs_decorate_price')->where(['id'=>$avatar_id])->find(); + if(empty($decorate_price_info)){ + Log::record("小时榜获取装扮失败:没有找到装扮!".$avatar_id,"info"); + } + $res = model('api/Decorate')->pay_decorate($user_id,$decorate_price_info['did'],$decorate_price_info['day'],2); + if($res['code'] == 0){ + Log::record("小时榜获取装扮失败:".$res['msg']."-".$avatar_id,"info"); + } + //添加到排行表 + $start_time = strtotime(date('Y-m-d H:00:00', strtotime('-1 hour'))); + $end_time = strtotime(date('Y-m-d H:00:00')) - 1; + $res2 = db::name('vs_hour_ranking')->insert([ + 'ranking' => $ranking, + 'room_id' => $room_id, + 'flowing_water' => $total_price, + 'gift_id' => $avatar_id, + 'gift_type' => $type, + 'time_id' => date('H', strtotime('-1 hour')), + 'stime' => $start_time, + 'etime' => $end_time, + 'createtime' => time(), + 'updatetime' => time(), + 'is_public_server' => $is_piao, + ]); + if(!$res2){ + Log::record("小时榜咋装扮锁定失败","info"); + } + return true; + } + + + /** + * 提取所有有奖励的内容 + */ + private function extractAllRewards($responseData) + { + $allRewards = []; + + foreach ($responseData as $timeSlot) { + foreach ($timeSlot['reward'] as $rewardItem) { + $index = $rewardItem['index']; + $content = $rewardItem['content']; + + // 只处理有奖励内容的数据 + if (!empty($content)) { + foreach ($content as $rewardContent) { + $allRewards[] = [ + 'index' => $index, + 'type' => $rewardContent['type'], + 'value' => $rewardContent['value'], + 'name' => $rewardContent['name'] ?? '' + ]; + } + } + } + } + + return $allRewards; + } + + /** + * 按index分组奖励 + */ + private function groupRewardsByIndex($allRewards) + { + $grouped = []; + + foreach ($allRewards as $reward) { + $index = $reward['index']; + if (!isset($grouped[$index])) { + $grouped[$index] = []; + } + $grouped[$index][] = $reward; + } + + // 按index排序 + ksort($grouped); + + return $grouped; + } + + /** + * 按名次顺序分配奖励 + */ + private function distributeByRank($groupedRewards) + { + $distribution = []; + $currentRank = 0; // 从第1名开始 + + // 按index顺序分配(index 0 = 第1名,index 1 = 第2名,以此类推) + foreach ($groupedRewards as $index => $rewards) { + // 确保名次连续,如果有空缺则填充空名次 + while ($currentRank < $index) { + $distribution[] = [ + 'rank' => $currentRank + 1, + 'rewards' => [] + ]; + $currentRank++; + } + + // 分配当前名次的奖励 + $distribution[] = [ + 'rank' => $currentRank + 1, + 'rewards' => $rewards + ]; + $currentRank++; + } + + return $distribution; + } + + public function get_hour_ranking($time){ + // 先按时间段和排名索引分组查询 + $timeRanges = db::name('vs_hour_ranking_gift_config')->distinct(true) + ->where('time_id', '=', $time) + ->order('time_id') + ->column('time_id'); + + $result = []; + foreach ($timeRanges as $timeRange) { + // 查询该时间段的所有数据 + $rewards = db::name('vs_hour_ranking_gift_config')->where('time_id', $timeRange) + ->field('ranking, gift_type, gift_id,coin,name') + ->order('ranking') + ->select(); + + $rewardMap = []; + foreach ($rewards as $reward) { + $rankIndex = $reward['ranking']; + + if (!isset($rewardMap[$rankIndex])) { + $rewardMap[$rankIndex] = [ + 'index' => $rankIndex, +// 'name' => $reward['rank_name'], + 'content' => [] + ]; + } + + // 添加奖励内容到content数组 + if ($reward['gift_id'] != 0 || $reward['coin'] != 0) { + if($reward['gift_id'] != 0){ + $rewardMap[$rankIndex]['content'][] = [ + 'type' => $reward['gift_type'], + 'value' => $reward['gift_id'], +// 'coin' => $reward['coin'], + 'name' => $reward['name'], + ]; + } + if($reward['coin'] != 0){ + $rewardMap[$rankIndex]['content'][] = [ + 'type' => $reward['gift_type'], + 'value' => $reward['coin'], + 'name' => $reward['name'], + ]; + } + + } + } + + // 按index排序 + ksort($rewardMap); + + $result[] = [ + 'time' => $timeRange, + 'reward' => array_values($rewardMap) + ]; + } + return $result; + } + + +} \ No newline at end of file diff --git a/application/cron/controller/RoomPan.php b/application/cron/controller/RoomPan.php new file mode 100644 index 0000000..411665a --- /dev/null +++ b/application/cron/controller/RoomPan.php @@ -0,0 +1,195 @@ +xlh_gift_send();//拍卖房结束提醒 + echo "礼物发放结束 \n"; + + echo "盲盒转盘礼物补发:\n"; + $this->blind_box_turntable_gift_send();//盲盒转盘礼物补发 + echo "盲盒转盘礼物补发结束 \n"; + } + + /* + * 盲盒转盘礼物推送补发 + */ + public function blind_box_turntable_gift_send(){ + $blind_box_turntable = db('vs_blind_box_turntable_log')->where(['is_sued'=>0,'createtime'=>['>=',time()-60*30]])->limit(1000)->select(); + if(empty($blind_box_turntable)){ + echo "没有需要发放的礼物 \n"; + } + echo "开始发放".count($blind_box_turntable)." \n"; + foreach ($blind_box_turntable as $k => $v) { + $blind_box_turntable_results_log = db('vs_blind_box_turntable_results_log')->where('tid',$v['id'])->select(); + if(empty($blind_box_turntable_results_log)){ + echo $v['id']." 没有需要发放的礼物 \n"; + continue; + } + $room_id = $v['room_id']; + $room_name = Db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->value('room_name'); + $FromUserInfo = Db::name('user')->where(['id'=>$v['user_id']])->find(); + $FromUserInfo['user_id'] = $FromUserInfo['id']; + $FromUserInfo['icon'][0] = model('UserData')->user_wealth_icon($v['user_id']);//财富图标 + $FromUserInfo['icon'][1] = model('UserData')->user_charm_icon($v['user_id']);//魅力图标 + $user_nickname = $FromUserInfo['nickname']; + $textMessage = $user_nickname; + $text_message = $user_nickname; + foreach ($blind_box_turntable_results_log as $key => $value) { + $ToUserInfo = Db::name('user')->where(['id' => $value['gift_user_id']])->field('id as user_id,nickname,avatar,sex')->find(); + $draw_gift = Db::name('vs_gift')->where(['gid'=>$value['gift_id']])->find(); + $textMessage = $textMessage . ' 送给 ' . $ToUserInfo['nickname']. ' 盲盒转盘礼物 ' . $draw_gift['gift_name'].' x ' .$value['count']."\n"; + $play_image[] = $draw_gift['play_image']; + $gift_names[] = $draw_gift['gift_name']; + + $text_message = $text_message . '在' . $room_name . '房间送给了' . $ToUserInfo['nickname'] . $draw_gift['gift_name'] . 'X' . $value['count']."\n"; + if($draw_gift['is_public_server'] == 1) { + $text_list_new[] = [ + 'text' => $text_message, + 'gift_picture' => $draw_gift['base_image'], + 'room_id' => $room_id, + 'fromUserName' => $FromUserInfo['nickname'], + 'toUserName' => $ToUserInfo['nickname'], + 'giftName' => $draw_gift['gift_name'], + 'roomId' => $room_id, + 'number' => $value['count'], + ]; + } + $ToUserInfosList[$value['gift_user_id']] = $ToUserInfo; + } + foreach($ToUserInfosList as &$userInfo) { + $userInfo['icon'][0] = model('UserData')->user_wealth_icon($userInfo['user_id']);//财富图标 + $userInfo['icon'][1] = model('UserData')->user_charm_icon($userInfo['user_id']);//魅力图标 + $userInfo['charm'] = db::name('vs_room_user_charm')->where(['user_id' => $userInfo['user_id'],'room_id' => $room_id])->value('charm');//魅力 + $ToUserInfos[] = $userInfo; + } + $text = [ + 'FromUserInfo' => $FromUserInfo, + 'ToUserInfos' => $ToUserInfos, + 'GiftInfo' => [ + 'play_image' => implode(',',$play_image), + 'gift_name' => implode(',',$gift_names), + ], + 'text' => rtrim($textMessage, "\n") + ]; + //聊天室推送系统消息 + model('Chat')->sendMsg(1005,$room_id,$text); + $roomtype = Db::name('vs_room')->where(['id' => $room_id])->value('type_id'); + if($roomtype == 6){ + //推送消息 + $hot_value = db::name('vs_give_gift')->where('from_id', $room_id)->where('from',6) + ->sum('total_price'); + $text1 = [ + 'room_id' => $room_id, + 'hot_value' => $hot_value * 10, + 'text' => '房间心动值变化' + ]; + //聊天室推送系统消息 + model('Chat')->sendMsg(1028,$room_id,$text1); + }else{ + if(!empty($text_list_new)){ + //推送礼物横幅 + $push = new Push($v['user_id'], $room_id); + $push->giftBanner($text_list_new); + } + } + db::name('vs_blind_box_turntable_log')->where('id', $v['id'])->update(['is_sued' => 1, 'updatetime' => time()]); + } + } + + /* + * 巡乐会结束 礼物发放 【定时脚本】 + */ + public function xlh_gift_send(){ + $xlh_list = db::name('vs_room_pan_xlh')->where(['send_time'=>0,'end_time'=>['<=',time()]])->select(); + if(empty($xlh_list)){ + echo "没有需要发放的礼物 \n"; + } + foreach ($xlh_list as $key=>$value){ + try{ + if($value['user_id'] == 0){ + echo "第.".$value['periods']." 巡乐会结束 没有中奖用户 \n"; + $res = db::name('vs_room_pan_xlh')->where('id',$value['id'])->update([ + 'send_time' => time() + ]); +// db::name("vs_room")->where('id',$value['room_id'])->update([ +// 'xlh_periods_num' => 0 +// ]); + Cache::set("xlh_periods_num", 0, 0); + //推送礼物横幅 + $text = "本轮巡乐会已结束,请大家重新开始下一轮巡乐会"; + $push = new Push(0, $value['room_id']); + $text_list_new = [ + 'text' => $text, + 'room_id' => $value['room_id'], + 'from_type' => 104 + ]; + $push->xunlehui($text_list_new); + continue; + } + //发放 + //抽中礼物落包 + $res = []; + $res = model('api/UserGiftPack')->change_user_gift_pack($value['user_id'],$value['gift_id'],$value['num'],model('UserGiftPack')::XLH_DRAW_GIFT_GET,"巡乐会中奖发放"); + if ($res['code'] != 1) { + echo $res['msg']."\n"; + continue; + } + echo "巡乐会中奖礼物发放成功 用户Id:".$value['user_id']."\n"; + //房主礼物落包 + $res = []; + //获取房主id + $user_id = db::name('vs_room')->where(['id'=>$value['room_id']])->value('user_id'); + $res = model('api/UserGiftPack')->change_user_gift_pack($user_id,$value['homeowner_gift_id'],1,model('UserGiftPack')::XLH_DRAW_GIFT_GET,"巡乐会中奖后房主礼物发放"); + if ($res['code'] != 1) { + echo $res['msg']."\n"; + continue; + } + echo "巡乐会中奖后房主礼物发放成功 房主Id:".$user_id."\n"; + //处理发放记录 + $res = []; + $res = db::name('vs_room_pan_xlh')->where('id',$value['id'])->update([ + 'send_time' => time() + ]); + $xlh_log = db::name('vs_room_pan_xlh_log')->where(['xlh_id'=>$value['id'],'user_id'=>$value['user_id']])->order('id desc')->find(); + $res = db::name('vs_room_pan_xlh_log')->where('id',$xlh_log['id'])->update([ + 'is_send' => 1 + ]); + if ($res === false) { + echo "处理发放记录失败 \n"; + continue; + } + Cache::set("xlh_periods_num", 0, 0); + //推送 + $FromUserInfo = db::name('user')->field('nickname,avatar')->where(['id'=>$value['user_id']])->find(); + $gift_name = db::name('vs_gift')->where(['gid'=>$value['gift_id']])->value('gift_name'); + $text = $FromUserInfo['nickname'] . ' 用户在巡乐会中 ' .$gift_name.'礼物 x ' .$value['num']." 已收入背包"; + //推送礼物横幅 + $push = new Push(0, $value['room_id']); + $text_list_new = [ + 'text' => $text, + 'room_id' => $value['room_id'], + 'from_type' => 104 + ]; + $push->xunlehui($text_list_new); + }catch (\Exception $e){ + echo $e->getMessage()."\n"; + } + } + } +} \ No newline at end of file diff --git a/application/cron/controller/Test.php b/application/cron/controller/Test.php new file mode 100644 index 0000000..53c5b61 --- /dev/null +++ b/application/cron/controller/Test.php @@ -0,0 +1,158 @@ +blind_box_error(); + echo "\n"; + + } + + //统计盲盒转盘错误数据 + public function blind_box_error() + { + die("暂停"); + // 设置数据库查询超时时间 + Db::query("SET SESSION wait_timeout=600"); + Db::query("SET SESSION interactive_timeout=600"); + + // 使用连表查询,直接找出送给多人的数据 + echo "开始查询送给多人的数据...\n"; + + // 先查询所有有多个不同 gift_user_id 的 tid + $multipleGiftRecords = Db::name('vs_blind_box_turntable_results_log') + ->group('tid') + ->having('COUNT(DISTINCT gift_user_id) > 1') + ->field('tid, COUNT(DISTINCT gift_user_id) as user_count,gift_user_id') + ->select(); + + echo "找到 " . count($multipleGiftRecords) . " 条送给多人的记录\n"; + + // 输出详细信息 + foreach ($multipleGiftRecords as $record) { + echo "转盘ID: {$record['tid']}, 接收人数: {$record['user_count']}\n"; + // 获取该转盘的详细信息 + $turntableInfo = Db::name('vs_blind_box_turntable_log') + ->where('id', $record['tid']) + ->find(); + + if ($turntableInfo) { + echo " 开奖用户ID: {$turntableInfo['user_id']}, 礼包ID: {$turntableInfo['gift_bag_id']}\n"; + } + } + + echo "统计盲盒转盘错误数据完成\n"; + } + + //统计盲盒转盘错误数据 + public function blind_box_error1() + { + die("暂停"); + // 设置数据库查询超时时间 + Db::query("SET SESSION wait_timeout=600"); + Db::query("SET SESSION interactive_timeout=600"); + + // 分批处理数据,避免一次性加载大量数据到内存 + $batchSize = 1000; + $offset = 0; + $data_multiple = []; + $totalProcessed = 0; + + do { + // 分批获取数据 + $turntable_log = Db::name('vs_blind_box_turntable_log') + ->limit($offset, $batchSize) + ->select(); + + // 如果没有更多数据,退出循环 + if (empty($turntable_log)) { + break; + } + + foreach ($turntable_log as $key => $value) { + //查询本轮是否有多个接收礼物的人 + $turntable_results_log = Db::name('vs_blind_box_turntable_results_log') + ->where('tid', $value['id']) + ->group('gift_user_id') + ->select(); + + // 统计送给多人的数据 + if (count($turntable_results_log) > 1) { + $data_multiple[] = [ + 'turntable_id' => $value['id'], + 'recipient_count' => count($turntable_results_log), + 'data' => $value + ]; + } + + $totalProcessed++; + + // 每处理100条记录输出一次进度 + if ($totalProcessed % 100 == 0) { + echo "已处理 {$totalProcessed} 条记录...\n"; + // 每100条记录后清理内存 + gc_collect_cycles(); + } + } + + // 更新偏移量 + $offset += $batchSize; + + // 释放内存 + unset($turntable_log); + unset($turntable_results_log); + + } while ($totalProcessed <= 1400); + + echo "送给多人的数据共 " . count($data_multiple) . " 条记录\n"; + echo "统计盲盒转盘错误数据完成-共处理 " . $totalProcessed . " 条数据\n"; + + // 输出详细信息 + foreach ($data_multiple as $item) { + echo "转盘ID: {$item['turntable_id']}, 接收人数: {$item['recipient_count']}\n"; + } + } + + public function RoomOwners() + { + $room = Db::name('vs_room')->where(['room_status' => 1,'apply_status' => 2])->select(); + $arr = []; + foreach ($room as $key => $value) { + $liushui = Db::name('vs_give_gift')->where(['from_id' => $value['id'],'from' => 2])->sum('total_price'); + $usercode = Db::name('user')->where(['id' => $value['user_id']])->value('user_code'); + $nickname = Db::name('user')->where(['id' => $value['user_id']])->value('nickname'); + $arr[] = [ + 'room_id' => $value['id'], + 'user_id' => $value['user_id'], + 'user_code' => $usercode, + 'nickname' => $nickname, + 'liushui' => $liushui + ]; + } + + //房主的收益 + foreach ($arr as $key => $v){ + $shouyi = db::name('vs_user_money_log')->where(['user_id' => $v['user_id'],'change_type' => 18,'money_type' =>2,'createtime'=>['<',1759585380]])->sum('change_value'); + $arr[$key]['shouyi'] = $shouyi; + $arr[$key]['duibi'] = $shouyi.'-'.$v['liushui']/10/10; + $arr[$key]['chazhi'] = $v['liushui']/10/10 - $shouyi; + } + var_dump($arr); + } + +} \ No newline at end of file diff --git a/application/extra/redis.php b/application/extra/redis.php new file mode 100644 index 0000000..9335dd0 --- /dev/null +++ b/application/extra/redis.php @@ -0,0 +1,12 @@ + '127.0.0.1', + 'port' => 6379, + 'password' => '', + 'select' => 0, + 'timeout' => 0, + 'expire' => 0, + 'persistent' => false, + 'prefix' => 'fa_redpacket_', +]; \ No newline at end of file diff --git a/extend/Yzh/CalculateLaborServiceClient.php b/extend/Yzh/CalculateLaborServiceClient.php new file mode 100644 index 0000000..70ed8b7 --- /dev/null +++ b/extend/Yzh/CalculateLaborServiceClient.php @@ -0,0 +1,81 @@ +laborCaculator request 必须是 Yzh\\Model\\Calculatelabor\\LaborCaculatorRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM); + } + return $this->send('POST', '/api/tax/v1/labor-caculator', $request, "Yzh\\Model\\Calculatelabor\\LaborCaculatorResponse", $option); + } + + /** + * 订单税费试算 + * @param CalcTaxRequest $request + * @param null $option + * @return CalcTaxResponse + */ + public function calcTax($request, $option = null) + { + if (!$request instanceof CalcTaxRequest) { + throw new ConfigException("Calculatelabor->calcTax request 必须是 Yzh\\Model\\Calculatelabor\\CalcTaxRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM); + } + return $this->send('POST', '/api/payment/v1/calc-tax', $request, "Yzh\\Model\\Calculatelabor\\CalcTaxResponse", $option); + } + + /** + * 连续劳务年度税费测算-H5 + * @param CalculationYearH5UrlRequest $request + * @param null $option + * @return CalculationYearH5UrlResponse + */ + public function calculationYearH5Url($request, $option = null) + { + if (!$request instanceof CalculationYearH5UrlRequest) { + throw new ConfigException("Calculatelabor->calculationYearH5Url request 必须是 Yzh\\Model\\Calculatelabor\\CalculationYearH5UrlRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM); + } + return $this->send('GET', '/api/labor/service/calculation/year/h5url', $request, "Yzh\\Model\\Calculatelabor\\CalculationYearH5UrlResponse", $option); + } + + /** + * 连续劳务单笔结算税费测算-H5 + * @param CalculationH5UrlRequest $request + * @param null $option + * @return CalculationH5UrlResponse + */ + public function calculationH5Url($request, $option = null) + { + if (!$request instanceof CalculationH5UrlRequest) { + throw new ConfigException("Calculatelabor->calculationH5Url request 必须是 Yzh\\Model\\Calculatelabor\\CalculationH5UrlRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM); + } + return $this->send('GET', '/api/labor/service/calculation/h5url', $request, "Yzh\\Model\\Calculatelabor\\CalculationH5UrlResponse", $option); + } +} \ No newline at end of file diff --git a/extend/Yzh/CustomerLinkClient.php b/extend/Yzh/CustomerLinkClient.php new file mode 100644 index 0000000..d612800 --- /dev/null +++ b/extend/Yzh/CustomerLinkClient.php @@ -0,0 +1,40 @@ +config->app_key; + + if ($this->config->sign_type == Config::SIGN_TYPE_RSA) { + $signature = $this->rsa->sign($signdata); + }else if($this->config->sign_type == Config::SIGN_TYPE_HMAC) { + $signature = $this->hmac->sign($signdata); + } + + $encodesign = urlencode($signature); + + $url = $base_url."?sign_type=".$this->config->sign_type."&sign=".$encodesign."&member_id=".$member_id."&mess=".$mess."×tamp=".$timestamp; + return $url; + } + } \ No newline at end of file diff --git a/extend/Yzh/Model/Calculatelabor/CalcTaxDetail.php b/extend/Yzh/Model/Calculatelabor/CalcTaxDetail.php new file mode 100644 index 0000000..c96fc78 --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/CalcTaxDetail.php @@ -0,0 +1,335 @@ +personal_tax = $personal_tax; + } + + /** + * 预扣个税 + * @return string + */ + public function getPersonalTax() + { + return $this->personal_tax; + } + + /** + * 预扣增值税 + * @var string $value_added_tax + */ + public function setValueAddedTax($value_added_tax) + { + $this->value_added_tax = $value_added_tax; + } + + /** + * 预扣增值税 + * @return string + */ + public function getValueAddedTax() + { + return $this->value_added_tax; + } + + /** + * 预扣附加税费 + * @var string $additional_tax + */ + public function setAdditionalTax($additional_tax) + { + $this->additional_tax = $additional_tax; + } + + /** + * 预扣附加税费 + * @return string + */ + public function getAdditionalTax() + { + return $this->additional_tax; + } + + /** + * 用户预扣个税 + * @var string $user_personal_tax + */ + public function setUserPersonalTax($user_personal_tax) + { + $this->user_personal_tax = $user_personal_tax; + } + + /** + * 用户预扣个税 + * @return string + */ + public function getUserPersonalTax() + { + return $this->user_personal_tax; + } + + /** + * 平台企业预扣个税 + * @var string $dealer_personal_tax + */ + public function setDealerPersonalTax($dealer_personal_tax) + { + $this->dealer_personal_tax = $dealer_personal_tax; + } + + /** + * 平台企业预扣个税 + * @return string + */ + public function getDealerPersonalTax() + { + return $this->dealer_personal_tax; + } + + /** + * 云账户预扣个税 + * @var string $broker_personal_tax + */ + public function setBrokerPersonalTax($broker_personal_tax) + { + $this->broker_personal_tax = $broker_personal_tax; + } + + /** + * 云账户预扣个税 + * @return string + */ + public function getBrokerPersonalTax() + { + return $this->broker_personal_tax; + } + + /** + * 用户预扣增值税 + * @var string $user_value_added_tax + */ + public function setUserValueAddedTax($user_value_added_tax) + { + $this->user_value_added_tax = $user_value_added_tax; + } + + /** + * 用户预扣增值税 + * @return string + */ + public function getUserValueAddedTax() + { + return $this->user_value_added_tax; + } + + /** + * 平台企业预扣增值税 + * @var string $dealer_value_added_tax + */ + public function setDealerValueAddedTax($dealer_value_added_tax) + { + $this->dealer_value_added_tax = $dealer_value_added_tax; + } + + /** + * 平台企业预扣增值税 + * @return string + */ + public function getDealerValueAddedTax() + { + return $this->dealer_value_added_tax; + } + + /** + * 云账户预扣增值税 + * @var string $broker_value_added_tax + */ + public function setBrokerValueAddedTax($broker_value_added_tax) + { + $this->broker_value_added_tax = $broker_value_added_tax; + } + + /** + * 云账户预扣增值税 + * @return string + */ + public function getBrokerValueAddedTax() + { + return $this->broker_value_added_tax; + } + + /** + * 用户预扣附加税费 + * @var string $user_additional_tax + */ + public function setUserAdditionalTax($user_additional_tax) + { + $this->user_additional_tax = $user_additional_tax; + } + + /** + * 用户预扣附加税费 + * @return string + */ + public function getUserAdditionalTax() + { + return $this->user_additional_tax; + } + + /** + * 平台企业预扣附加税费 + * @var string $dealer_additional_tax + */ + public function setDealerAdditionalTax($dealer_additional_tax) + { + $this->dealer_additional_tax = $dealer_additional_tax; + } + + /** + * 平台企业预扣附加税费 + * @return string + */ + public function getDealerAdditionalTax() + { + return $this->dealer_additional_tax; + } + + /** + * 云账户预扣附加税费 + * @var string $broker_additional_tax + */ + public function setBrokerAdditionalTax($broker_additional_tax) + { + $this->broker_additional_tax = $broker_additional_tax; + } + + /** + * 云账户预扣附加税费 + * @return string + */ + public function getBrokerAdditionalTax() + { + return $this->broker_additional_tax; + } + + /** + * 预扣个税税率 + * @var string $personal_tax_rate + */ + public function setPersonalTaxRate($personal_tax_rate) + { + $this->personal_tax_rate = $personal_tax_rate; + } + + /** + * 预扣个税税率 + * @return string + */ + public function getPersonalTaxRate() + { + return $this->personal_tax_rate; + } + + /** + * 预扣个税速算扣除数 + * @var string $deduct_tax + */ + public function setDeductTax($deduct_tax) + { + $this->deduct_tax = $deduct_tax; + } + + /** + * 预扣个税速算扣除数 + * @return string + */ + public function getDeductTax() + { + return $this->deduct_tax; + } +} diff --git a/extend/Yzh/Model/Calculatelabor/CalcTaxRequest.php b/extend/Yzh/Model/Calculatelabor/CalcTaxRequest.php new file mode 100644 index 0000000..e11c6cb --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/CalcTaxRequest.php @@ -0,0 +1,52 @@ +{$property} = $params[$property]; + } + } + } +} diff --git a/extend/Yzh/Model/Calculatelabor/CalcTaxResponse.php b/extend/Yzh/Model/Calculatelabor/CalcTaxResponse.php new file mode 100644 index 0000000..4b0dab7 --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/CalcTaxResponse.php @@ -0,0 +1,33 @@ +data; + } + + /** + * 设置数据对象 + * @param array $data + * @return self + */ + public function setData($data) + { + $this->data = new CalcTaxResponseData($data); + return $this; + } +} diff --git a/extend/Yzh/Model/Calculatelabor/CalcTaxResponseData.php b/extend/Yzh/Model/Calculatelabor/CalcTaxResponseData.php new file mode 100644 index 0000000..3c52a1a --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/CalcTaxResponseData.php @@ -0,0 +1,405 @@ +pay = $pay; + } + + /** + * 测算金额 + * @return string + */ + public function getPay() + { + return $this->pay; + } + + /** + * 税费总额 + * @var string $tax + */ + public function setTax($tax) + { + $this->tax = $tax; + } + + /** + * 税费总额 + * @return string + */ + public function getTax() + { + return $this->tax; + } + + /** + * 税后结算金额 + * @var string $after_tax_amount + */ + public function setAfterTaxAmount($after_tax_amount) + { + $this->after_tax_amount = $after_tax_amount; + } + + /** + * 税后结算金额 + * @return string + */ + public function getAfterTaxAmount() + { + return $this->after_tax_amount; + } + + /** + * 缴税明细 + * @var CalcTaxDetail $tax_detail + */ + public function setTaxDetail($tax_detail) + { + $this->tax_detail = $tax_detail; + } + + /** + * 缴税明细 + * @return CalcTaxDetail + */ + public function getTaxDetail() + { + return $this->tax_detail; + } + + /** + * 税前订单金额 + * @var string $before_tax_amount + */ + public function setBeforeTaxAmount($before_tax_amount) + { + $this->before_tax_amount = $before_tax_amount; + } + + /** + * 税前订单金额 + * @return string + */ + public function getBeforeTaxAmount() + { + return $this->before_tax_amount; + } + + /** + * 用户税费总额 + * @var string $user_tax + */ + public function setUserTax($user_tax) + { + $this->user_tax = $user_tax; + } + + /** + * 用户税费总额 + * @return string + */ + public function getUserTax() + { + return $this->user_tax; + } + + /** + * 平台企业税费总额 + * @var string $dealer_tax + */ + public function setDealerTax($dealer_tax) + { + $this->dealer_tax = $dealer_tax; + } + + /** + * 平台企业税费总额 + * @return string + */ + public function getDealerTax() + { + return $this->dealer_tax; + } + + /** + * 云账户税费总额 + * @var string $broker_tax + */ + public function setBrokerTax($broker_tax) + { + $this->broker_tax = $broker_tax; + } + + /** + * 云账户税费总额 + * @return string + */ + public function getBrokerTax() + { + return $this->broker_tax; + } + + /** + * 用户服务费 + * @var string $user_fee + */ + public function setUserFee($user_fee) + { + $this->user_fee = $user_fee; + } + + /** + * 用户服务费 + * @return string + */ + public function getUserFee() + { + return $this->user_fee; + } + + /** + * 结果 + * @var string $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * 结果 + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * 结果详细状态码 + * @var string $status_detail + */ + public function setStatusDetail($status_detail) + { + $this->status_detail = $status_detail; + } + + /** + * 结果详细状态码 + * @return string + */ + public function getStatusDetail() + { + return $this->status_detail; + } + + /** + * 结果说明 + * @var string $status_message + */ + public function setStatusMessage($status_message) + { + $this->status_message = $status_message; + } + + /** + * 结果说明 + * @return string + */ + public function getStatusMessage() + { + return $this->status_message; + } + + /** + * 结果详细状态码描述 + * @var string $status_detail_message + */ + public function setStatusDetailMessage($status_detail_message) + { + $this->status_detail_message = $status_detail_message; + } + + /** + * 结果详细状态码描述 + * @return string + */ + public function getStatusDetailMessage() + { + return $this->status_detail_message; + } + + /** + * 用户实收金额(未扣除追缴的增附税) + * @var string $user_real_excluding_vat_amount + */ + public function setUserRealExcludingVatAmount($user_real_excluding_vat_amount) + { + $this->user_real_excluding_vat_amount = $user_real_excluding_vat_amount; + } + + /** + * 用户实收金额(未扣除追缴的增附税) + * @return string + */ + public function getUserRealExcludingVatAmount() + { + return $this->user_real_excluding_vat_amount; + } + + /** + * 用户还未缴清的增附税 + * @var string $user_remaining_repayment_amount + */ + public function setUserRemainingRepaymentAmount($user_remaining_repayment_amount) + { + $this->user_remaining_repayment_amount = $user_remaining_repayment_amount; + } + + /** + * 用户还未缴清的增附税 + * @return string + */ + public function getUserRemainingRepaymentAmount() + { + return $this->user_remaining_repayment_amount; + } + + /** + * 已追缴增附税(本笔订单) + * @var string $user_recover_tax_amount + */ + public function setUserRecoverTaxAmount($user_recover_tax_amount) + { + $this->user_recover_tax_amount = $user_recover_tax_amount; + } + + /** + * 已追缴增附税(本笔订单) + * @return string + */ + public function getUserRecoverTaxAmount() + { + return $this->user_recover_tax_amount; + } + + /** + * 待追缴增附税总金额 + * @var string $user_total_recover_tax_amount + */ + public function setUserTotalRecoverTaxAmount($user_total_recover_tax_amount) + { + $this->user_total_recover_tax_amount = $user_total_recover_tax_amount; + } + + /** + * 待追缴增附税总金额 + * @return string + */ + public function getUserTotalRecoverTaxAmount() + { + return $this->user_total_recover_tax_amount; + } +} diff --git a/extend/Yzh/Model/Calculatelabor/CalculationH5UrlRequest.php b/extend/Yzh/Model/Calculatelabor/CalculationH5UrlRequest.php new file mode 100644 index 0000000..3c87dc3 --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/CalculationH5UrlRequest.php @@ -0,0 +1,47 @@ +{$property} = $params[$property]; + } + } + } +} diff --git a/extend/Yzh/Model/Calculatelabor/CalculationH5UrlResponse.php b/extend/Yzh/Model/Calculatelabor/CalculationH5UrlResponse.php new file mode 100644 index 0000000..d1659f2 --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/CalculationH5UrlResponse.php @@ -0,0 +1,33 @@ +data; + } + + /** + * 设置数据对象 + * @param array $data + * @return self + */ + public function setData($data) + { + $this->data = new CalculationH5UrlResponseData($data); + return $this; + } +} diff --git a/extend/Yzh/Model/Calculatelabor/CalculationH5UrlResponseData.php b/extend/Yzh/Model/Calculatelabor/CalculationH5UrlResponseData.php new file mode 100644 index 0000000..167a0cd --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/CalculationH5UrlResponseData.php @@ -0,0 +1,37 @@ +url = $url; + } + + /** + * 连续劳务单笔结算税费测算 H5 页面 URL + * @return string + */ + public function getUrl() + { + return $this->url; + } +} diff --git a/extend/Yzh/Model/Calculatelabor/CalculationYearH5UrlRequest.php b/extend/Yzh/Model/Calculatelabor/CalculationYearH5UrlRequest.php new file mode 100644 index 0000000..4d42d1e --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/CalculationYearH5UrlRequest.php @@ -0,0 +1,37 @@ +{$property} = $params[$property]; + } + } + } +} diff --git a/extend/Yzh/Model/Calculatelabor/CalculationYearH5UrlResponse.php b/extend/Yzh/Model/Calculatelabor/CalculationYearH5UrlResponse.php new file mode 100644 index 0000000..3e59065 --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/CalculationYearH5UrlResponse.php @@ -0,0 +1,33 @@ +data; + } + + /** + * 设置数据对象 + * @param array $data + * @return self + */ + public function setData($data) + { + $this->data = new CalculationYearH5UrlResponseData($data); + return $this; + } +} diff --git a/extend/Yzh/Model/Calculatelabor/CalculationYearH5UrlResponseData.php b/extend/Yzh/Model/Calculatelabor/CalculationYearH5UrlResponseData.php new file mode 100644 index 0000000..400569f --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/CalculationYearH5UrlResponseData.php @@ -0,0 +1,37 @@ +url = $url; + } + + /** + * 年度劳务测算 H5 页面 URL + * @return string + */ + public function getUrl() + { + return $this->url; + } +} diff --git a/extend/Yzh/Model/Calculatelabor/LaborCaculatorRequest.php b/extend/Yzh/Model/Calculatelabor/LaborCaculatorRequest.php new file mode 100644 index 0000000..4f50e2f --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/LaborCaculatorRequest.php @@ -0,0 +1,37 @@ +{$property} = $params[$property]; + } + } + } +} diff --git a/extend/Yzh/Model/Calculatelabor/LaborCaculatorResponse.php b/extend/Yzh/Model/Calculatelabor/LaborCaculatorResponse.php new file mode 100644 index 0000000..55983ca --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/LaborCaculatorResponse.php @@ -0,0 +1,33 @@ +data; + } + + /** + * 设置数据对象 + * @param array $data + * @return self + */ + public function setData($data) + { + $this->data = new LaborCaculatorResponseData($data); + return $this; + } +} diff --git a/extend/Yzh/Model/Calculatelabor/LaborCaculatorResponseData.php b/extend/Yzh/Model/Calculatelabor/LaborCaculatorResponseData.php new file mode 100644 index 0000000..3fbbe34 --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/LaborCaculatorResponseData.php @@ -0,0 +1,62 @@ +year_tax_info = $year_tax_info; + } + + /** + * 综合所得汇算清缴 + * @return YearTaxInfo + */ + public function getYearTaxInfo() + { + return $this->year_tax_info; + } + + /** + * @var array $items + */ + public function setMonthTaxList($items) + { + $this->month_tax_list = array(); + foreach ($items as $k => $v) { + array_push($this->month_tax_list, new MontTax($v)); + } + } + + /** + * 月度税务信息列表 + * @return MontTax[] + */ + public function getMonthTaxList() + { + return $this->month_tax_list; + } +} diff --git a/extend/Yzh/Model/Calculatelabor/MontTax.php b/extend/Yzh/Model/Calculatelabor/MontTax.php new file mode 100644 index 0000000..a342945 --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/MontTax.php @@ -0,0 +1,243 @@ +month = $month; + } + + /** + * 月份 + * @return int32 + */ + public function getMonth() + { + return $this->month; + } + + /** + * 含增值税收入 + * @var string $pre_tax_amount + */ + public function setPreTaxAmount($pre_tax_amount) + { + $this->pre_tax_amount = $pre_tax_amount; + } + + /** + * 含增值税收入 + * @return string + */ + public function getPreTaxAmount() + { + return $this->pre_tax_amount; + } + + /** + * 不含增值税收入 + * @var string $excluding_vat_amount + */ + public function setExcludingVatAmount($excluding_vat_amount) + { + $this->excluding_vat_amount = $excluding_vat_amount; + } + + /** + * 不含增值税收入 + * @return string + */ + public function getExcludingVatAmount() + { + return $this->excluding_vat_amount; + } + + /** + * 增值税 + * @var string $value_added_tax + */ + public function setValueAddedTax($value_added_tax) + { + $this->value_added_tax = $value_added_tax; + } + + /** + * 增值税 + * @return string + */ + public function getValueAddedTax() + { + return $this->value_added_tax; + } + + /** + * 附加税 + * @var string $additional_tax + */ + public function setAdditionalTax($additional_tax) + { + $this->additional_tax = $additional_tax; + } + + /** + * 附加税 + * @return string + */ + public function getAdditionalTax() + { + return $this->additional_tax; + } + + /** + * 个税 + * @var string $personal_tax + */ + public function setPersonalTax($personal_tax) + { + $this->personal_tax = $personal_tax; + } + + /** + * 个税 + * @return string + */ + public function getPersonalTax() + { + return $this->personal_tax; + } + + /** + * 个税税率 + * @var string $personal_tax_rate + */ + public function setPersonalTaxRate($personal_tax_rate) + { + $this->personal_tax_rate = $personal_tax_rate; + } + + /** + * 个税税率 + * @return string + */ + public function getPersonalTaxRate() + { + return $this->personal_tax_rate; + } + + /** + * 速算扣除数 + * @var string $deduct_tax + */ + public function setDeductTax($deduct_tax) + { + $this->deduct_tax = $deduct_tax; + } + + /** + * 速算扣除数 + * @return string + */ + public function getDeductTax() + { + return $this->deduct_tax; + } + + /** + * 税后金额 + * @var string $post_tax_amount + */ + public function setPostTaxAmount($post_tax_amount) + { + $this->post_tax_amount = $post_tax_amount; + } + + /** + * 税后金额 + * @return string + */ + public function getPostTaxAmount() + { + return $this->post_tax_amount; + } + + /** + * 税负率 + * @var string $total_tax_rate + */ + public function setTotalTaxRate($total_tax_rate) + { + $this->total_tax_rate = $total_tax_rate; + } + + /** + * 税负率 + * @return string + */ + public function getTotalTaxRate() + { + return $this->total_tax_rate; + } +} diff --git a/extend/Yzh/Model/Calculatelabor/MonthSettlement.php b/extend/Yzh/Model/Calculatelabor/MonthSettlement.php new file mode 100644 index 0000000..6fd8ce8 --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/MonthSettlement.php @@ -0,0 +1,59 @@ +month = $month; + } + + /** + * 月份 + * @return int32 + */ + public function getMonth() + { + return $this->month; + } + + /** + * 月度收入 + * @var string $month_pre_tax_amount + */ + public function setMonthPreTaxAmount($month_pre_tax_amount) + { + $this->month_pre_tax_amount = $month_pre_tax_amount; + } + + /** + * 月度收入 + * @return string + */ + public function getMonthPreTaxAmount() + { + return $this->month_pre_tax_amount; + } +} diff --git a/extend/Yzh/Model/Calculatelabor/YearTaxInfo.php b/extend/Yzh/Model/Calculatelabor/YearTaxInfo.php new file mode 100644 index 0000000..2427805 --- /dev/null +++ b/extend/Yzh/Model/Calculatelabor/YearTaxInfo.php @@ -0,0 +1,151 @@ +continuous_month_personal_tax = $continuous_month_personal_tax; + } + + /** + * 连续劳务年度个税 + * @return string + */ + public function getContinuousMonthPersonalTax() + { + return $this->continuous_month_personal_tax; + } + + /** + * 综合所得汇算清缴年度个税 + * @var string $personal_tax + */ + public function setPersonalTax($personal_tax) + { + $this->personal_tax = $personal_tax; + } + + /** + * 综合所得汇算清缴年度个税 + * @return string + */ + public function getPersonalTax() + { + return $this->personal_tax; + } + + /** + * 年度扣除费用 + * @var string $deduct_cost + */ + public function setDeductCost($deduct_cost) + { + $this->deduct_cost = $deduct_cost; + } + + /** + * 年度扣除费用 + * @return string + */ + public function getDeductCost() + { + return $this->deduct_cost; + } + + /** + * 个税税率 + * @var string $personal_tax_rate + */ + public function setPersonalTaxRate($personal_tax_rate) + { + $this->personal_tax_rate = $personal_tax_rate; + } + + /** + * 个税税率 + * @return string + */ + public function getPersonalTaxRate() + { + return $this->personal_tax_rate; + } + + /** + * 速算扣除数 + * @var string $deduct_tax + */ + public function setDeductTax($deduct_tax) + { + $this->deduct_tax = $deduct_tax; + } + + /** + * 速算扣除数 + * @return string + */ + public function getDeductTax() + { + return $this->deduct_tax; + } + + /** + * 税负率 + * @var string $total_tax_rate + */ + public function setTotalTaxRate($total_tax_rate) + { + $this->total_tax_rate = $total_tax_rate; + } + + /** + * 税负率 + * @return string + */ + public function getTotalTaxRate() + { + return $this->total_tax_rate; + } +} diff --git a/extend/Yzh/Model/Dataservice/OrderTaxDetail.php b/extend/Yzh/Model/Dataservice/OrderTaxDetail.php new file mode 100644 index 0000000..dde5b67 --- /dev/null +++ b/extend/Yzh/Model/Dataservice/OrderTaxDetail.php @@ -0,0 +1,427 @@ +personal_tax = $personal_tax; + } + + /** + * 预扣个税 + * @return string + */ + public function getPersonalTax() + { + return $this->personal_tax; + } + + /** + * 预扣增值税 + * @var string $value_added_tax + */ + public function setValueAddedTax($value_added_tax) + { + $this->value_added_tax = $value_added_tax; + } + + /** + * 预扣增值税 + * @return string + */ + public function getValueAddedTax() + { + return $this->value_added_tax; + } + + /** + * 预扣附加税费 + * @var string $additional_tax + */ + public function setAdditionalTax($additional_tax) + { + $this->additional_tax = $additional_tax; + } + + /** + * 预扣附加税费 + * @return string + */ + public function getAdditionalTax() + { + return $this->additional_tax; + } + + /** + * 实缴个税 + * @var string $received_personal_tax + */ + public function setReceivedPersonalTax($received_personal_tax) + { + $this->received_personal_tax = $received_personal_tax; + } + + /** + * 实缴个税 + * @return string + */ + public function getReceivedPersonalTax() + { + return $this->received_personal_tax; + } + + /** + * 实缴增值税 + * @var string $received_value_added_tax + */ + public function setReceivedValueAddedTax($received_value_added_tax) + { + $this->received_value_added_tax = $received_value_added_tax; + } + + /** + * 实缴增值税 + * @return string + */ + public function getReceivedValueAddedTax() + { + return $this->received_value_added_tax; + } + + /** + * 实缴附加税费 + * @var string $received_additional_tax + */ + public function setReceivedAdditionalTax($received_additional_tax) + { + $this->received_additional_tax = $received_additional_tax; + } + + /** + * 实缴附加税费 + * @return string + */ + public function getReceivedAdditionalTax() + { + return $this->received_additional_tax; + } + + /** + * 用户预扣个税 + * @var string $user_personal_tax + */ + public function setUserPersonalTax($user_personal_tax) + { + $this->user_personal_tax = $user_personal_tax; + } + + /** + * 用户预扣个税 + * @return string + */ + public function getUserPersonalTax() + { + return $this->user_personal_tax; + } + + /** + * 平台企业预扣个税 + * @var string $dealer_personal_tax + */ + public function setDealerPersonalTax($dealer_personal_tax) + { + $this->dealer_personal_tax = $dealer_personal_tax; + } + + /** + * 平台企业预扣个税 + * @return string + */ + public function getDealerPersonalTax() + { + return $this->dealer_personal_tax; + } + + /** + * 用户预扣增值税 + * @var string $user_value_added_tax + */ + public function setUserValueAddedTax($user_value_added_tax) + { + $this->user_value_added_tax = $user_value_added_tax; + } + + /** + * 用户预扣增值税 + * @return string + */ + public function getUserValueAddedTax() + { + return $this->user_value_added_tax; + } + + /** + * 平台企业预扣增值税 + * @var string $dealer_value_added_tax + */ + public function setDealerValueAddedTax($dealer_value_added_tax) + { + $this->dealer_value_added_tax = $dealer_value_added_tax; + } + + /** + * 平台企业预扣增值税 + * @return string + */ + public function getDealerValueAddedTax() + { + return $this->dealer_value_added_tax; + } + + /** + * 用户预扣附加税费 + * @var string $user_additional_tax + */ + public function setUserAdditionalTax($user_additional_tax) + { + $this->user_additional_tax = $user_additional_tax; + } + + /** + * 用户预扣附加税费 + * @return string + */ + public function getUserAdditionalTax() + { + return $this->user_additional_tax; + } + + /** + * 平台企业预扣附加税费 + * @var string $dealer_additional_tax + */ + public function setDealerAdditionalTax($dealer_additional_tax) + { + $this->dealer_additional_tax = $dealer_additional_tax; + } + + /** + * 平台企业预扣附加税费 + * @return string + */ + public function getDealerAdditionalTax() + { + return $this->dealer_additional_tax; + } + + /** + * 用户实缴个税 + * @var string $user_received_personal_tax + */ + public function setUserReceivedPersonalTax($user_received_personal_tax) + { + $this->user_received_personal_tax = $user_received_personal_tax; + } + + /** + * 用户实缴个税 + * @return string + */ + public function getUserReceivedPersonalTax() + { + return $this->user_received_personal_tax; + } + + /** + * 平台企业实缴个税 + * @var string $dealer_received_personal_tax + */ + public function setDealerReceivedPersonalTax($dealer_received_personal_tax) + { + $this->dealer_received_personal_tax = $dealer_received_personal_tax; + } + + /** + * 平台企业实缴个税 + * @return string + */ + public function getDealerReceivedPersonalTax() + { + return $this->dealer_received_personal_tax; + } + + /** + * 用户实缴增值税 + * @var string $user_received_value_added_tax + */ + public function setUserReceivedValueAddedTax($user_received_value_added_tax) + { + $this->user_received_value_added_tax = $user_received_value_added_tax; + } + + /** + * 用户实缴增值税 + * @return string + */ + public function getUserReceivedValueAddedTax() + { + return $this->user_received_value_added_tax; + } + + /** + * 平台企业实缴增值税 + * @var string $dealer_received_value_added_tax + */ + public function setDealerReceivedValueAddedTax($dealer_received_value_added_tax) + { + $this->dealer_received_value_added_tax = $dealer_received_value_added_tax; + } + + /** + * 平台企业实缴增值税 + * @return string + */ + public function getDealerReceivedValueAddedTax() + { + return $this->dealer_received_value_added_tax; + } + + /** + * 用户实缴附加税费 + * @var string $user_received_additional_tax + */ + public function setUserReceivedAdditionalTax($user_received_additional_tax) + { + $this->user_received_additional_tax = $user_received_additional_tax; + } + + /** + * 用户实缴附加税费 + * @return string + */ + public function getUserReceivedAdditionalTax() + { + return $this->user_received_additional_tax; + } + + /** + * 平台企业实缴附加税费 + * @var string $dealer_received_additional_tax + */ + public function setDealerReceivedAdditionalTax($dealer_received_additional_tax) + { + $this->dealer_received_additional_tax = $dealer_received_additional_tax; + } + + /** + * 平台企业实缴附加税费 + * @return string + */ + public function getDealerReceivedAdditionalTax() + { + return $this->dealer_received_additional_tax; + } +} diff --git a/extend/Yzh/Model/Payment/GetOrderLxlwRequest.php b/extend/Yzh/Model/Payment/GetOrderLxlwRequest.php new file mode 100644 index 0000000..eca614f --- /dev/null +++ b/extend/Yzh/Model/Payment/GetOrderLxlwRequest.php @@ -0,0 +1,37 @@ +{$property} = $params[$property]; + } + } + } +} diff --git a/extend/Yzh/Model/Payment/GetOrderLxlwResponse.php b/extend/Yzh/Model/Payment/GetOrderLxlwResponse.php new file mode 100644 index 0000000..50fdeb8 --- /dev/null +++ b/extend/Yzh/Model/Payment/GetOrderLxlwResponse.php @@ -0,0 +1,33 @@ +data; + } + + /** + * 设置数据对象 + * @param array $data + * @return self + */ + public function setData($data) + { + $this->data = new GetOrderLxlwResponseData($data); + return $this; + } +} diff --git a/extend/Yzh/Model/Payment/GetOrderLxlwResponseData.php b/extend/Yzh/Model/Payment/GetOrderLxlwResponseData.php new file mode 100644 index 0000000..80464fa --- /dev/null +++ b/extend/Yzh/Model/Payment/GetOrderLxlwResponseData.php @@ -0,0 +1,1003 @@ +order_id = $order_id; + } + + /** + * 平台企业订单号 + * @return string + */ + public function getOrderId() + { + return $this->order_id; + } + + /** + * 订单金额 + * @var string $pay + */ + public function setPay($pay) + { + $this->pay = $pay; + } + + /** + * 订单金额 + * @return string + */ + public function getPay() + { + return $this->pay; + } + + /** + * 综合服务主体 ID + * @var string $broker_id + */ + public function setBrokerId($broker_id) + { + $this->broker_id = $broker_id; + } + + /** + * 综合服务主体 ID + * @return string + */ + public function getBrokerId() + { + return $this->broker_id; + } + + /** + * 平台企业 ID + * @var string $dealer_id + */ + public function setDealerId($dealer_id) + { + $this->dealer_id = $dealer_id; + } + + /** + * 平台企业 ID + * @return string + */ + public function getDealerId() + { + return $this->dealer_id; + } + + /** + * 姓名 + * @var string $real_name + */ + public function setRealName($real_name) + { + $this->real_name = $real_name; + } + + /** + * 姓名 + * @return string + */ + public function getRealName() + { + return $this->real_name; + } + + /** + * 收款人账号 + * @var string $card_no + */ + public function setCardNo($card_no) + { + $this->card_no = $card_no; + } + + /** + * 收款人账号 + * @return string + */ + public function getCardNo() + { + return $this->card_no; + } + + /** + * 身份证号码 + * @var string $id_card + */ + public function setIdCard($id_card) + { + $this->id_card = $id_card; + } + + /** + * 身份证号码 + * @return string + */ + public function getIdCard() + { + return $this->id_card; + } + + /** + * 手机号 + * @var string $phone_no + */ + public function setPhoneNo($phone_no) + { + $this->phone_no = $phone_no; + } + + /** + * 手机号 + * @return string + */ + public function getPhoneNo() + { + return $this->phone_no; + } + + /** + * 订单状态码 + * @var string $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * 订单状态码 + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * 订单详细状态码 + * @var string $status_detail + */ + public function setStatusDetail($status_detail) + { + $this->status_detail = $status_detail; + } + + /** + * 订单详细状态码 + * @return string + */ + public function getStatusDetail() + { + return $this->status_detail; + } + + /** + * 订单状态码描述 + * @var string $status_message + */ + public function setStatusMessage($status_message) + { + $this->status_message = $status_message; + } + + /** + * 订单状态码描述 + * @return string + */ + public function getStatusMessage() + { + return $this->status_message; + } + + /** + * 订单详情状态码描述 + * @var string $status_detail_message + */ + public function setStatusDetailMessage($status_detail_message) + { + $this->status_detail_message = $status_detail_message; + } + + /** + * 订单详情状态码描述 + * @return string + */ + public function getStatusDetailMessage() + { + return $this->status_detail_message; + } + + /** + * 订单状态补充信息 + * @var string $supplemental_detail_message + */ + public function setSupplementalDetailMessage($supplemental_detail_message) + { + $this->supplemental_detail_message = $supplemental_detail_message; + } + + /** + * 订单状态补充信息 + * @return string + */ + public function getSupplementalDetailMessage() + { + return $this->supplemental_detail_message; + } + + /** + * 综合服务主体支付金额 + * @var string $broker_amount + */ + public function setBrokerAmount($broker_amount) + { + $this->broker_amount = $broker_amount; + } + + /** + * 综合服务主体支付金额 + * @return string + */ + public function getBrokerAmount() + { + return $this->broker_amount; + } + + /** + * 综合服务平台流水号 + * @var string $ref + */ + public function setRef($ref) + { + $this->ref = $ref; + } + + /** + * 综合服务平台流水号 + * @return string + */ + public function getRef() + { + return $this->ref; + } + + /** + * 支付交易流水号 + * @var string $broker_bank_bill + */ + public function setBrokerBankBill($broker_bank_bill) + { + $this->broker_bank_bill = $broker_bank_bill; + } + + /** + * 支付交易流水号 + * @return string + */ + public function getBrokerBankBill() + { + return $this->broker_bank_bill; + } + + /** + * 支付路径 + * @var string $withdraw_platform + */ + public function setWithdrawPlatform($withdraw_platform) + { + $this->withdraw_platform = $withdraw_platform; + } + + /** + * 支付路径 + * @return string + */ + public function getWithdrawPlatform() + { + return $this->withdraw_platform; + } + + /** + * 订单接收时间,精确到秒 + * @var string $created_at + */ + public function setCreatedAt($created_at) + { + $this->created_at = $created_at; + } + + /** + * 订单接收时间,精确到秒 + * @return string + */ + public function getCreatedAt() + { + return $this->created_at; + } + + /** + * 订单完成时间,精确到秒 + * @var string $finished_time + */ + public function setFinishedTime($finished_time) + { + $this->finished_time = $finished_time; + } + + /** + * 订单完成时间,精确到秒 + * @return string + */ + public function getFinishedTime() + { + return $this->finished_time; + } + + /** + * 应收综合服务主体加成服务费金额 + * @var string $broker_fee + */ + public function setBrokerFee($broker_fee) + { + $this->broker_fee = $broker_fee; + } + + /** + * 应收综合服务主体加成服务费金额 + * @return string + */ + public function getBrokerFee() + { + return $this->broker_fee; + } + + /** + * 应收余额账户支出加成服务费金额 + * @var string $broker_real_fee + */ + public function setBrokerRealFee($broker_real_fee) + { + $this->broker_real_fee = $broker_real_fee; + } + + /** + * 应收余额账户支出加成服务费金额 + * @return string + */ + public function getBrokerRealFee() + { + return $this->broker_real_fee; + } + + /** + * 应收加成服务费抵扣金额 + * @var string $broker_deduct_fee + */ + public function setBrokerDeductFee($broker_deduct_fee) + { + $this->broker_deduct_fee = $broker_deduct_fee; + } + + /** + * 应收加成服务费抵扣金额 + * @return string + */ + public function getBrokerDeductFee() + { + return $this->broker_deduct_fee; + } + + /** + * 应收用户加成服务费金额 + * @var string $user_fee + */ + public function setUserFee($user_fee) + { + $this->user_fee = $user_fee; + } + + /** + * 应收用户加成服务费金额 + * @return string + */ + public function getUserFee() + { + return $this->user_fee; + } + + /** + * 实收综合服务主体加成服务费金额 + * @var string $received_broker_fee + */ + public function setReceivedBrokerFee($received_broker_fee) + { + $this->received_broker_fee = $received_broker_fee; + } + + /** + * 实收综合服务主体加成服务费金额 + * @return string + */ + public function getReceivedBrokerFee() + { + return $this->received_broker_fee; + } + + /** + * 实收余额账户支出加成服务费金额 + * @var string $received_broker_real_fee + */ + public function setReceivedBrokerRealFee($received_broker_real_fee) + { + $this->received_broker_real_fee = $received_broker_real_fee; + } + + /** + * 实收余额账户支出加成服务费金额 + * @return string + */ + public function getReceivedBrokerRealFee() + { + return $this->received_broker_real_fee; + } + + /** + * 实收加成服务费抵扣金额 + * @var string $received_broker_deduct_fee + */ + public function setReceivedBrokerDeductFee($received_broker_deduct_fee) + { + $this->received_broker_deduct_fee = $received_broker_deduct_fee; + } + + /** + * 实收加成服务费抵扣金额 + * @return string + */ + public function getReceivedBrokerDeductFee() + { + return $this->received_broker_deduct_fee; + } + + /** + * 实收用户加成服务费金额 + * @var string $received_user_fee + */ + public function setReceivedUserFee($received_user_fee) + { + $this->received_user_fee = $received_user_fee; + } + + /** + * 实收用户加成服务费金额 + * @return string + */ + public function getReceivedUserFee() + { + return $this->received_user_fee; + } + + /** + * 订单备注 + * @var string $pay_remark + */ + public function setPayRemark($pay_remark) + { + $this->pay_remark = $pay_remark; + } + + /** + * 订单备注 + * @return string + */ + public function getPayRemark() + { + return $this->pay_remark; + } + + /** + * 银行名称 + * @var string $bank_name + */ + public function setBankName($bank_name) + { + $this->bank_name = $bank_name; + } + + /** + * 银行名称 + * @return string + */ + public function getBankName() + { + return $this->bank_name; + } + + /** + * 业务线标识 + * @var string $project_id + */ + public function setProjectId($project_id) + { + $this->project_id = $project_id; + } + + /** + * 业务线标识 + * @return string + */ + public function getProjectId() + { + return $this->project_id; + } + + /** + * 新就业形态劳动者 ID,该字段已废弃 + * @var string $anchor_id + */ + public function setAnchorId($anchor_id) + { + $this->anchor_id = $anchor_id; + } + + /** + * 新就业形态劳动者 ID,该字段已废弃 + * @return string + */ + public function getAnchorId() + { + return $this->anchor_id; + } + + /** + * 描述信息,该字段已废弃 + * @var string $notes + */ + public function setNotes($notes) + { + $this->notes = $notes; + } + + /** + * 描述信息,该字段已废弃 + * @return string + */ + public function getNotes() + { + return $this->notes; + } + + /** + * 系统支付金额,该字段已废弃 + * @var string $sys_amount + */ + public function setSysAmount($sys_amount) + { + $this->sys_amount = $sys_amount; + } + + /** + * 系统支付金额,该字段已废弃 + * @return string + */ + public function getSysAmount() + { + return $this->sys_amount; + } + + /** + * 税费,该字段已废弃 + * @var string $tax + */ + public function setTax($tax) + { + $this->tax = $tax; + } + + /** + * 税费,该字段已废弃 + * @return string + */ + public function getTax() + { + return $this->tax; + } + + /** + * 系统支付费用,该字段已废弃 + * @var string $sys_fee + */ + public function setSysFee($sys_fee) + { + $this->sys_fee = $sys_fee; + } + + /** + * 系统支付费用,该字段已废弃 + * @return string + */ + public function getSysFee() + { + return $this->sys_fee; + } + + /** + * 用户实收金额 + * @var string $user_real_amount + */ + public function setUserRealAmount($user_real_amount) + { + $this->user_real_amount = $user_real_amount; + } + + /** + * 用户实收金额 + * @return string + */ + public function getUserRealAmount() + { + return $this->user_real_amount; + } + + /** + * 缴税明细 + * @var TaxDetail $tax_detail + */ + public function setTaxDetail($tax_detail) + { + $this->tax_detail = $tax_detail; + } + + /** + * 缴税明细 + * @return TaxDetail + */ + public function getTaxDetail() + { + return $this->tax_detail; + } + + /** + * 实缴税费总额 + * @var string $received_tax_amount + */ + public function setReceivedTaxAmount($received_tax_amount) + { + $this->received_tax_amount = $received_tax_amount; + } + + /** + * 实缴税费总额 + * @return string + */ + public function getReceivedTaxAmount() + { + return $this->received_tax_amount; + } + + /** + * 互联网平台名称 + * @var string $dealer_platform_name + */ + public function setDealerPlatformName($dealer_platform_name) + { + $this->dealer_platform_name = $dealer_platform_name; + } + + /** + * 互联网平台名称 + * @return string + */ + public function getDealerPlatformName() + { + return $this->dealer_platform_name; + } + + /** + * 用户名称/昵称 + * @var string $dealer_user_nickname + */ + public function setDealerUserNickname($dealer_user_nickname) + { + $this->dealer_user_nickname = $dealer_user_nickname; + } + + /** + * 用户名称/昵称 + * @return string + */ + public function getDealerUserNickname() + { + return $this->dealer_user_nickname; + } + + /** + * 用户唯一标识码 + * @var string $dealer_user_id + */ + public function setDealerUserId($dealer_user_id) + { + $this->dealer_user_id = $dealer_user_id; + } + + /** + * 用户唯一标识码 + * @return string + */ + public function getDealerUserId() + { + return $this->dealer_user_id; + } + + /** + * 用户实收金额(追缴前) + * @var string $user_real_excluding_vat_amount + */ + public function setUserRealExcludingVatAmount($user_real_excluding_vat_amount) + { + $this->user_real_excluding_vat_amount = $user_real_excluding_vat_amount; + } + + /** + * 用户实收金额(追缴前) + * @return string + */ + public function getUserRealExcludingVatAmount() + { + return $this->user_real_excluding_vat_amount; + } + + /** + * 已追缴增附税(本笔订单) + * @var string $user_recover_tax_amount + */ + public function setUserRecoverTaxAmount($user_recover_tax_amount) + { + $this->user_recover_tax_amount = $user_recover_tax_amount; + } + + /** + * 已追缴增附税(本笔订单) + * @return string + */ + public function getUserRecoverTaxAmount() + { + return $this->user_recover_tax_amount; + } +} diff --git a/extend/Yzh/Model/Payment/NotifyOrderLxlwData copy.php b/extend/Yzh/Model/Payment/NotifyOrderLxlwData copy.php new file mode 100644 index 0000000..9b8db26 --- /dev/null +++ b/extend/Yzh/Model/Payment/NotifyOrderLxlwData copy.php @@ -0,0 +1,749 @@ +order_id = $order_id; + } + + /** + * 平台企业订单号 + * @return string + */ + public function getOrderId() + { + return $this->order_id; + } + + /** + * 订单金额 + * @var string $pay + */ + public function setPay($pay) + { + $this->pay = $pay; + } + + /** + * 订单金额 + * @return string + */ + public function getPay() + { + return $this->pay; + } + + /** + * 综合服务主体 ID + * @var string $broker_id + */ + public function setBrokerId($broker_id) + { + $this->broker_id = $broker_id; + } + + /** + * 综合服务主体 ID + * @return string + */ + public function getBrokerId() + { + return $this->broker_id; + } + + /** + * 平台企业 ID + * @var string $dealer_id + */ + public function setDealerId($dealer_id) + { + $this->dealer_id = $dealer_id; + } + + /** + * 平台企业 ID + * @return string + */ + public function getDealerId() + { + return $this->dealer_id; + } + + /** + * 姓名 + * @var string $real_name + */ + public function setRealName($real_name) + { + $this->real_name = $real_name; + } + + /** + * 姓名 + * @return string + */ + public function getRealName() + { + return $this->real_name; + } + + /** + * 收款人账号 + * @var string $card_no + */ + public function setCardNo($card_no) + { + $this->card_no = $card_no; + } + + /** + * 收款人账号 + * @return string + */ + public function getCardNo() + { + return $this->card_no; + } + + /** + * 身份证号码 + * @var string $id_card + */ + public function setIdCard($id_card) + { + $this->id_card = $id_card; + } + + /** + * 身份证号码 + * @return string + */ + public function getIdCard() + { + return $this->id_card; + } + + /** + * 手机号 + * @var string $phone_no + */ + public function setPhoneNo($phone_no) + { + $this->phone_no = $phone_no; + } + + /** + * 手机号 + * @return string + */ + public function getPhoneNo() + { + return $this->phone_no; + } + + /** + * 订单状态码 + * @var string $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * 订单状态码 + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * 订单详情状态码 + * @var string $status_detail + */ + public function setStatusDetail($status_detail) + { + $this->status_detail = $status_detail; + } + + /** + * 订单详情状态码 + * @return string + */ + public function getStatusDetail() + { + return $this->status_detail; + } + + /** + * 订单状态码描述 + * @var string $status_message + */ + public function setStatusMessage($status_message) + { + $this->status_message = $status_message; + } + + /** + * 订单状态码描述 + * @return string + */ + public function getStatusMessage() + { + return $this->status_message; + } + + /** + * 订单详情状态码描述 + * @var string $status_detail_message + */ + public function setStatusDetailMessage($status_detail_message) + { + $this->status_detail_message = $status_detail_message; + } + + /** + * 订单详情状态码描述 + * @return string + */ + public function getStatusDetailMessage() + { + return $this->status_detail_message; + } + + /** + * 订单状态补充信息 + * @var string $supplemental_detail_message + */ + public function setSupplementalDetailMessage($supplemental_detail_message) + { + $this->supplemental_detail_message = $supplemental_detail_message; + } + + /** + * 订单状态补充信息 + * @return string + */ + public function getSupplementalDetailMessage() + { + return $this->supplemental_detail_message; + } + + /** + * 综合服务主体支付金额 + * @var string $broker_amount + */ + public function setBrokerAmount($broker_amount) + { + $this->broker_amount = $broker_amount; + } + + /** + * 综合服务主体支付金额 + * @return string + */ + public function getBrokerAmount() + { + return $this->broker_amount; + } + + /** + * 综合服务平台流水号 + * @var string $ref + */ + public function setRef($ref) + { + $this->ref = $ref; + } + + /** + * 综合服务平台流水号 + * @return string + */ + public function getRef() + { + return $this->ref; + } + + /** + * 支付交易流水号 + * @var string $broker_bank_bill + */ + public function setBrokerBankBill($broker_bank_bill) + { + $this->broker_bank_bill = $broker_bank_bill; + } + + /** + * 支付交易流水号 + * @return string + */ + public function getBrokerBankBill() + { + return $this->broker_bank_bill; + } + + /** + * 支付路径 + * @var string $withdraw_platform + */ + public function setWithdrawPlatform($withdraw_platform) + { + $this->withdraw_platform = $withdraw_platform; + } + + /** + * 支付路径 + * @return string + */ + public function getWithdrawPlatform() + { + return $this->withdraw_platform; + } + + /** + * 订单接收时间,精确到秒 + * @var string $created_at + */ + public function setCreatedAt($created_at) + { + $this->created_at = $created_at; + } + + /** + * 订单接收时间,精确到秒 + * @return string + */ + public function getCreatedAt() + { + return $this->created_at; + } + + /** + * 订单完成时间,精确到秒 + * @var string $finished_time + */ + public function setFinishedTime($finished_time) + { + $this->finished_time = $finished_time; + } + + /** + * 订单完成时间,精确到秒 + * @return string + */ + public function getFinishedTime() + { + return $this->finished_time; + } + + /** + * 应收综合服务主体加成服务费金额 + * @var string $broker_fee + */ + public function setBrokerFee($broker_fee) + { + $this->broker_fee = $broker_fee; + } + + /** + * 应收综合服务主体加成服务费金额 + * @return string + */ + public function getBrokerFee() + { + return $this->broker_fee; + } + + /** + * 应收余额账户支出加成服务费金额 + * @var string $broker_real_fee + */ + public function setBrokerRealFee($broker_real_fee) + { + $this->broker_real_fee = $broker_real_fee; + } + + /** + * 应收余额账户支出加成服务费金额 + * @return string + */ + public function getBrokerRealFee() + { + return $this->broker_real_fee; + } + + /** + * 应收加成服务费抵扣金额 + * @var string $broker_deduct_fee + */ + public function setBrokerDeductFee($broker_deduct_fee) + { + $this->broker_deduct_fee = $broker_deduct_fee; + } + + /** + * 应收加成服务费抵扣金额 + * @return string + */ + public function getBrokerDeductFee() + { + return $this->broker_deduct_fee; + } + + /** + * 应收用户加成服务费金额 + * @var string $user_fee + */ + public function setUserFee($user_fee) + { + $this->user_fee = $user_fee; + } + + /** + * 应收用户加成服务费金额 + * @return string + */ + public function getUserFee() + { + return $this->user_fee; + } + + /** + * 实收综合服务主体加成服务费金额 + * @var string $received_broker_fee + */ + public function setReceivedBrokerFee($received_broker_fee) + { + $this->received_broker_fee = $received_broker_fee; + } + + /** + * 实收综合服务主体加成服务费金额 + * @return string + */ + public function getReceivedBrokerFee() + { + return $this->received_broker_fee; + } + + /** + * 实收余额账户支出加成服务费金额 + * @var string $received_broker_real_fee + */ + public function setReceivedBrokerRealFee($received_broker_real_fee) + { + $this->received_broker_real_fee = $received_broker_real_fee; + } + + /** + * 实收余额账户支出加成服务费金额 + * @return string + */ + public function getReceivedBrokerRealFee() + { + return $this->received_broker_real_fee; + } + + /** + * 实收加成服务费抵扣金额 + * @var string $received_broker_deduct_fee + */ + public function setReceivedBrokerDeductFee($received_broker_deduct_fee) + { + $this->received_broker_deduct_fee = $received_broker_deduct_fee; + } + + /** + * 实收加成服务费抵扣金额 + * @return string + */ + public function getReceivedBrokerDeductFee() + { + return $this->received_broker_deduct_fee; + } + + /** + * 实收用户加成服务费金额 + * @var string $received_user_fee + */ + public function setReceivedUserFee($received_user_fee) + { + $this->received_user_fee = $received_user_fee; + } + + /** + * 实收用户加成服务费金额 + * @return string + */ + public function getReceivedUserFee() + { + return $this->received_user_fee; + } + + /** + * 订单备注 + * @var string $pay_remark + */ + public function setPayRemark($pay_remark) + { + $this->pay_remark = $pay_remark; + } + + /** + * 订单备注 + * @return string + */ + public function getPayRemark() + { + return $this->pay_remark; + } + + /** + * 银行名称 + * @var string $bank_name + */ + public function setBankName($bank_name) + { + $this->bank_name = $bank_name; + } + + /** + * 银行名称 + * @return string + */ + public function getBankName() + { + return $this->bank_name; + } + + /** + * 业务线标识 + * @var string $project_id + */ + public function setProjectId($project_id) + { + $this->project_id = $project_id; + } + + /** + * 业务线标识 + * @return string + */ + public function getProjectId() + { + return $this->project_id; + } + + /** + * 用户实收金额 + * @var string $user_real_amount + */ + public function setUserRealAmount($user_real_amount) + { + $this->user_real_amount = $user_real_amount; + } + + /** + * 用户实收金额 + * @return string + */ + public function getUserRealAmount() + { + return $this->user_real_amount; + } + + /** + * 缴税明细 + * @var TaxDetail $tax_detail + */ + public function setTaxDetail($tax_detail) + { + $this->tax_detail = $tax_detail; + } + + /** + * 缴税明细 + * @return TaxDetail + */ + public function getTaxDetail() + { + return $this->tax_detail; + } +} diff --git a/extend/Yzh/Model/Payment/NotifyOrderLxlwData.php b/extend/Yzh/Model/Payment/NotifyOrderLxlwData.php new file mode 100644 index 0000000..f07b32a --- /dev/null +++ b/extend/Yzh/Model/Payment/NotifyOrderLxlwData.php @@ -0,0 +1,910 @@ +order_id = $order_id; + } + + /** + * 平台企业订单号 + * @return string + */ + public function getOrderId() + { + return $this->order_id; + } + + /** + * 订单金额 + * @var string $pay + */ + public function setPay($pay) + { + $this->pay = $pay; + } + + /** + * 订单金额 + * @return string + */ + public function getPay() + { + return $this->pay; + } + + /** + * 综合服务主体 ID + * @var string $broker_id + */ + public function setBrokerId($broker_id) + { + $this->broker_id = $broker_id; + } + + /** + * 综合服务主体 ID + * @return string + */ + public function getBrokerId() + { + return $this->broker_id; + } + + /** + * 平台企业 ID + * @var string $dealer_id + */ + public function setDealerId($dealer_id) + { + $this->dealer_id = $dealer_id; + } + + /** + * 平台企业 ID + * @return string + */ + public function getDealerId() + { + return $this->dealer_id; + } + + /** + * 姓名 + * @var string $real_name + */ + public function setRealName($real_name) + { + $this->real_name = $real_name; + } + + /** + * 姓名 + * @return string + */ + public function getRealName() + { + return $this->real_name; + } + + /** + * 收款人账号 + * @var string $card_no + */ + public function setCardNo($card_no) + { + $this->card_no = $card_no; + } + + /** + * 收款人账号 + * @return string + */ + public function getCardNo() + { + return $this->card_no; + } + + /** + * 身份证号码 + * @var string $id_card + */ + public function setIdCard($id_card) + { + $this->id_card = $id_card; + } + + /** + * 身份证号码 + * @return string + */ + public function getIdCard() + { + return $this->id_card; + } + + /** + * 手机号 + * @var string $phone_no + */ + public function setPhoneNo($phone_no) + { + $this->phone_no = $phone_no; + } + + /** + * 手机号 + * @return string + */ + public function getPhoneNo() + { + return $this->phone_no; + } + + /** + * 订单状态码 + * @var string $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * 订单状态码 + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * 订单详情状态码 + * @var string $status_detail + */ + public function setStatusDetail($status_detail) + { + $this->status_detail = $status_detail; + } + + /** + * 订单详情状态码 + * @return string + */ + public function getStatusDetail() + { + return $this->status_detail; + } + + /** + * 订单状态码描述 + * @var string $status_message + */ + public function setStatusMessage($status_message) + { + $this->status_message = $status_message; + } + + /** + * 订单状态码描述 + * @return string + */ + public function getStatusMessage() + { + return $this->status_message; + } + + /** + * 订单详情状态码描述 + * @var string $status_detail_message + */ + public function setStatusDetailMessage($status_detail_message) + { + $this->status_detail_message = $status_detail_message; + } + + /** + * 订单详情状态码描述 + * @return string + */ + public function getStatusDetailMessage() + { + return $this->status_detail_message; + } + + /** + * 订单状态补充信息 + * @var string $supplemental_detail_message + */ + public function setSupplementalDetailMessage($supplemental_detail_message) + { + $this->supplemental_detail_message = $supplemental_detail_message; + } + + /** + * 订单状态补充信息 + * @return string + */ + public function getSupplementalDetailMessage() + { + return $this->supplemental_detail_message; + } + + /** + * 综合服务主体支付金额 + * @var string $broker_amount + */ + public function setBrokerAmount($broker_amount) + { + $this->broker_amount = $broker_amount; + } + + /** + * 综合服务主体支付金额 + * @return string + */ + public function getBrokerAmount() + { + return $this->broker_amount; + } + + /** + * 综合服务平台流水号 + * @var string $ref + */ + public function setRef($ref) + { + $this->ref = $ref; + } + + /** + * 综合服务平台流水号 + * @return string + */ + public function getRef() + { + return $this->ref; + } + + /** + * 支付交易流水号 + * @var string $broker_bank_bill + */ + public function setBrokerBankBill($broker_bank_bill) + { + $this->broker_bank_bill = $broker_bank_bill; + } + + /** + * 支付交易流水号 + * @return string + */ + public function getBrokerBankBill() + { + return $this->broker_bank_bill; + } + + /** + * 支付路径 + * @var string $withdraw_platform + */ + public function setWithdrawPlatform($withdraw_platform) + { + $this->withdraw_platform = $withdraw_platform; + } + + /** + * 支付路径 + * @return string + */ + public function getWithdrawPlatform() + { + return $this->withdraw_platform; + } + + /** + * 订单接收时间,精确到秒 + * @var string $created_at + */ + public function setCreatedAt($created_at) + { + $this->created_at = $created_at; + } + + /** + * 订单接收时间,精确到秒 + * @return string + */ + public function getCreatedAt() + { + return $this->created_at; + } + + /** + * 订单完成时间,精确到秒 + * @var string $finished_time + */ + public function setFinishedTime($finished_time) + { + $this->finished_time = $finished_time; + } + + /** + * 订单完成时间,精确到秒 + * @return string + */ + public function getFinishedTime() + { + return $this->finished_time; + } + + /** + * 应收综合服务主体加成服务费金额 + * @var string $broker_fee + */ + public function setBrokerFee($broker_fee) + { + $this->broker_fee = $broker_fee; + } + + /** + * 应收综合服务主体加成服务费金额 + * @return string + */ + public function getBrokerFee() + { + return $this->broker_fee; + } + + /** + * 应收余额账户支出加成服务费金额 + * @var string $broker_real_fee + */ + public function setBrokerRealFee($broker_real_fee) + { + $this->broker_real_fee = $broker_real_fee; + } + + /** + * 应收余额账户支出加成服务费金额 + * @return string + */ + public function getBrokerRealFee() + { + return $this->broker_real_fee; + } + + /** + * 应收加成服务费抵扣金额 + * @var string $broker_deduct_fee + */ + public function setBrokerDeductFee($broker_deduct_fee) + { + $this->broker_deduct_fee = $broker_deduct_fee; + } + + /** + * 应收加成服务费抵扣金额 + * @return string + */ + public function getBrokerDeductFee() + { + return $this->broker_deduct_fee; + } + + /** + * 应收用户加成服务费金额 + * @var string $user_fee + */ + public function setUserFee($user_fee) + { + $this->user_fee = $user_fee; + } + + /** + * 应收用户加成服务费金额 + * @return string + */ + public function getUserFee() + { + return $this->user_fee; + } + + /** + * 实收综合服务主体加成服务费金额 + * @var string $received_broker_fee + */ + public function setReceivedBrokerFee($received_broker_fee) + { + $this->received_broker_fee = $received_broker_fee; + } + + /** + * 实收综合服务主体加成服务费金额 + * @return string + */ + public function getReceivedBrokerFee() + { + return $this->received_broker_fee; + } + + /** + * 实收余额账户支出加成服务费金额 + * @var string $received_broker_real_fee + */ + public function setReceivedBrokerRealFee($received_broker_real_fee) + { + $this->received_broker_real_fee = $received_broker_real_fee; + } + + /** + * 实收余额账户支出加成服务费金额 + * @return string + */ + public function getReceivedBrokerRealFee() + { + return $this->received_broker_real_fee; + } + + /** + * 实收加成服务费抵扣金额 + * @var string $received_broker_deduct_fee + */ + public function setReceivedBrokerDeductFee($received_broker_deduct_fee) + { + $this->received_broker_deduct_fee = $received_broker_deduct_fee; + } + + /** + * 实收加成服务费抵扣金额 + * @return string + */ + public function getReceivedBrokerDeductFee() + { + return $this->received_broker_deduct_fee; + } + + /** + * 实收用户加成服务费金额 + * @var string $received_user_fee + */ + public function setReceivedUserFee($received_user_fee) + { + $this->received_user_fee = $received_user_fee; + } + + /** + * 实收用户加成服务费金额 + * @return string + */ + public function getReceivedUserFee() + { + return $this->received_user_fee; + } + + /** + * 订单备注 + * @var string $pay_remark + */ + public function setPayRemark($pay_remark) + { + $this->pay_remark = $pay_remark; + } + + /** + * 订单备注 + * @return string + */ + public function getPayRemark() + { + return $this->pay_remark; + } + + /** + * 银行名称 + * @var string $bank_name + */ + public function setBankName($bank_name) + { + $this->bank_name = $bank_name; + } + + /** + * 银行名称 + * @return string + */ + public function getBankName() + { + return $this->bank_name; + } + + /** + * 业务线标识 + * @var string $project_id + */ + public function setProjectId($project_id) + { + $this->project_id = $project_id; + } + + /** + * 业务线标识 + * @return string + */ + public function getProjectId() + { + return $this->project_id; + } + + /** + * 用户实收金额 + * @var string $user_real_amount + */ + public function setUserRealAmount($user_real_amount) + { + $this->user_real_amount = $user_real_amount; + } + + /** + * 用户实收金额 + * @return string + */ + public function getUserRealAmount() + { + return $this->user_real_amount; + } + + /** + * 缴税明细 + * @var TaxDetail $tax_detail + */ + public function setTaxDetail($tax_detail) + { + $this->tax_detail = $tax_detail; + } + + /** + * 缴税明细 + * @return TaxDetail + */ + public function getTaxDetail() + { + return $this->tax_detail; + } + + /** + * 互联网平台名称 + * @var string $dealer_platform_name + */ + public function setDealerPlatformName($dealer_platform_name) + { + $this->dealer_platform_name = $dealer_platform_name; + } + + /** + * 互联网平台名称 + * @return string + */ + public function getDealerPlatformName() + { + return $this->dealer_platform_name; + } + + /** + * 用户名称/昵称 + * @var string $dealer_user_nickname + */ + public function setDealerUserNickname($dealer_user_nickname) + { + $this->dealer_user_nickname = $dealer_user_nickname; + } + + /** + * 用户名称/昵称 + * @return string + */ + public function getDealerUserNickname() + { + return $this->dealer_user_nickname; + } + + /** + * 用户唯一标识码 + * @var string $dealer_user_id + */ + public function setDealerUserId($dealer_user_id) + { + $this->dealer_user_id = $dealer_user_id; + } + + /** + * 用户唯一标识码 + * @return string + */ + public function getDealerUserId() + { + return $this->dealer_user_id; + } + + /** + * 预扣税费总额 + * @var string $tax + */ + public function setTax($tax) + { + $this->tax = $tax; + } + + /** + * 预扣税费总额 + * @return string + */ + public function getTax() + { + return $this->tax; + } + + /** + * 实缴税费总额 + * @var string $received_tax_amount + */ + public function setReceivedTaxAmount($received_tax_amount) + { + $this->received_tax_amount = $received_tax_amount; + } + + /** + * 实缴税费总额 + * @return string + */ + public function getReceivedTaxAmount() + { + return $this->received_tax_amount; + } + + /** + * 用户实收金额(追缴前) + * @var string $user_real_excluding_vat_amount + */ + public function setUserRealExcludingVatAmount($user_real_excluding_vat_amount) + { + $this->user_real_excluding_vat_amount = $user_real_excluding_vat_amount; + } + + /** + * 用户实收金额(追缴前) + * @return string + */ + public function getUserRealExcludingVatAmount() + { + return $this->user_real_excluding_vat_amount; + } + + /** + * 已追缴增附税(本笔订单) + * @var string $user_recover_tax_amount + */ + public function setUserRecoverTaxAmount($user_recover_tax_amount) + { + $this->user_recover_tax_amount = $user_recover_tax_amount; + } + + /** + * 已追缴增附税(本笔订单) + * @return string + */ + public function getUserRecoverTaxAmount() + { + return $this->user_recover_tax_amount; + } +} diff --git a/extend/Yzh/Model/Payment/NotifyOrderLxlwRequest copy.php b/extend/Yzh/Model/Payment/NotifyOrderLxlwRequest copy.php new file mode 100644 index 0000000..5a60dc1 --- /dev/null +++ b/extend/Yzh/Model/Payment/NotifyOrderLxlwRequest copy.php @@ -0,0 +1,37 @@ +{$property} = $params[$property]; + } + } + } +} diff --git a/extend/Yzh/Model/Payment/NotifyOrderLxlwRequest.php b/extend/Yzh/Model/Payment/NotifyOrderLxlwRequest.php new file mode 100644 index 0000000..5a60dc1 --- /dev/null +++ b/extend/Yzh/Model/Payment/NotifyOrderLxlwRequest.php @@ -0,0 +1,37 @@ +{$property} = $params[$property]; + } + } + } +} diff --git a/extend/Yzh/Model/Payment/TaxDetail.php b/extend/Yzh/Model/Payment/TaxDetail.php new file mode 100644 index 0000000..561f0b8 --- /dev/null +++ b/extend/Yzh/Model/Payment/TaxDetail.php @@ -0,0 +1,473 @@ +personal_tax = $personal_tax; + } + + /** + * 预扣个税 + * @return string + */ + public function getPersonalTax() + { + return $this->personal_tax; + } + + /** + * 预扣增值税 + * @var string $value_added_tax + */ + public function setValueAddedTax($value_added_tax) + { + $this->value_added_tax = $value_added_tax; + } + + /** + * 预扣增值税 + * @return string + */ + public function getValueAddedTax() + { + return $this->value_added_tax; + } + + /** + * 预扣附加税费 + * @var string $additional_tax + */ + public function setAdditionalTax($additional_tax) + { + $this->additional_tax = $additional_tax; + } + + /** + * 预扣附加税费 + * @return string + */ + public function getAdditionalTax() + { + return $this->additional_tax; + } + + /** + * 实缴个税 + * @var string $received_personal_tax + */ + public function setReceivedPersonalTax($received_personal_tax) + { + $this->received_personal_tax = $received_personal_tax; + } + + /** + * 实缴个税 + * @return string + */ + public function getReceivedPersonalTax() + { + return $this->received_personal_tax; + } + + /** + * 实缴增值税 + * @var string $received_value_added_tax + */ + public function setReceivedValueAddedTax($received_value_added_tax) + { + $this->received_value_added_tax = $received_value_added_tax; + } + + /** + * 实缴增值税 + * @return string + */ + public function getReceivedValueAddedTax() + { + return $this->received_value_added_tax; + } + + /** + * 实缴附加税费 + * @var string $received_additional_tax + */ + public function setReceivedAdditionalTax($received_additional_tax) + { + $this->received_additional_tax = $received_additional_tax; + } + + /** + * 实缴附加税费 + * @return string + */ + public function getReceivedAdditionalTax() + { + return $this->received_additional_tax; + } + + /** + * 用户预扣个税 + * @var string $user_personal_tax + */ + public function setUserPersonalTax($user_personal_tax) + { + $this->user_personal_tax = $user_personal_tax; + } + + /** + * 用户预扣个税 + * @return string + */ + public function getUserPersonalTax() + { + return $this->user_personal_tax; + } + + /** + * 平台企业预扣个税 + * @var string $dealer_personal_tax + */ + public function setDealerPersonalTax($dealer_personal_tax) + { + $this->dealer_personal_tax = $dealer_personal_tax; + } + + /** + * 平台企业预扣个税 + * @return string + */ + public function getDealerPersonalTax() + { + return $this->dealer_personal_tax; + } + + /** + * 用户预扣增值税 + * @var string $user_value_added_tax + */ + public function setUserValueAddedTax($user_value_added_tax) + { + $this->user_value_added_tax = $user_value_added_tax; + } + + /** + * 用户预扣增值税 + * @return string + */ + public function getUserValueAddedTax() + { + return $this->user_value_added_tax; + } + + /** + * 平台企业预扣增值税 + * @var string $dealer_value_added_tax + */ + public function setDealerValueAddedTax($dealer_value_added_tax) + { + $this->dealer_value_added_tax = $dealer_value_added_tax; + } + + /** + * 平台企业预扣增值税 + * @return string + */ + public function getDealerValueAddedTax() + { + return $this->dealer_value_added_tax; + } + + /** + * 用户预扣附加税费 + * @var string $user_additional_tax + */ + public function setUserAdditionalTax($user_additional_tax) + { + $this->user_additional_tax = $user_additional_tax; + } + + /** + * 用户预扣附加税费 + * @return string + */ + public function getUserAdditionalTax() + { + return $this->user_additional_tax; + } + + /** + * 平台企业预扣附加税费 + * @var string $dealer_additional_tax + */ + public function setDealerAdditionalTax($dealer_additional_tax) + { + $this->dealer_additional_tax = $dealer_additional_tax; + } + + /** + * 平台企业预扣附加税费 + * @return string + */ + public function getDealerAdditionalTax() + { + return $this->dealer_additional_tax; + } + + /** + * 用户实缴个税 + * @var string $user_received_personal_tax + */ + public function setUserReceivedPersonalTax($user_received_personal_tax) + { + $this->user_received_personal_tax = $user_received_personal_tax; + } + + /** + * 用户实缴个税 + * @return string + */ + public function getUserReceivedPersonalTax() + { + return $this->user_received_personal_tax; + } + + /** + * 平台企业实缴个税 + * @var string $dealer_received_personal_tax + */ + public function setDealerReceivedPersonalTax($dealer_received_personal_tax) + { + $this->dealer_received_personal_tax = $dealer_received_personal_tax; + } + + /** + * 平台企业实缴个税 + * @return string + */ + public function getDealerReceivedPersonalTax() + { + return $this->dealer_received_personal_tax; + } + + /** + * 用户实缴增值税 + * @var string $user_received_value_added_tax + */ + public function setUserReceivedValueAddedTax($user_received_value_added_tax) + { + $this->user_received_value_added_tax = $user_received_value_added_tax; + } + + /** + * 用户实缴增值税 + * @return string + */ + public function getUserReceivedValueAddedTax() + { + return $this->user_received_value_added_tax; + } + + /** + * 平台企业实缴增值税 + * @var string $dealer_received_value_added_tax + */ + public function setDealerReceivedValueAddedTax($dealer_received_value_added_tax) + { + $this->dealer_received_value_added_tax = $dealer_received_value_added_tax; + } + + /** + * 平台企业实缴增值税 + * @return string + */ + public function getDealerReceivedValueAddedTax() + { + return $this->dealer_received_value_added_tax; + } + + /** + * 用户实缴附加税费 + * @var string $user_received_additional_tax + */ + public function setUserReceivedAdditionalTax($user_received_additional_tax) + { + $this->user_received_additional_tax = $user_received_additional_tax; + } + + /** + * 用户实缴附加税费 + * @return string + */ + public function getUserReceivedAdditionalTax() + { + return $this->user_received_additional_tax; + } + + /** + * 平台企业实缴附加税费 + * @var string $dealer_received_additional_tax + */ + public function setDealerReceivedAdditionalTax($dealer_received_additional_tax) + { + $this->dealer_received_additional_tax = $dealer_received_additional_tax; + } + + /** + * 平台企业实缴附加税费 + * @return string + */ + public function getDealerReceivedAdditionalTax() + { + return $this->dealer_received_additional_tax; + } + + /** + * 预扣个税税率 + * @var string $personal_tax_rate + */ + public function setPersonalTaxRate($personal_tax_rate) + { + $this->personal_tax_rate = $personal_tax_rate; + } + + /** + * 预扣个税税率 + * @return string + */ + public function getPersonalTaxRate() + { + return $this->personal_tax_rate; + } + + /** + * 预扣个税速算扣除数 + * @var string $deduct_tax + */ + public function setDeductTax($deduct_tax) + { + $this->deduct_tax = $deduct_tax; + } + + /** + * 预扣个税速算扣除数 + * @return string + */ + public function getDeductTax() + { + return $this->deduct_tax; + } +} diff --git a/extend/Yzh/Model/Realname/CollectRealNameInfoRequest.php b/extend/Yzh/Model/Realname/CollectRealNameInfoRequest.php new file mode 100644 index 0000000..4e498ab --- /dev/null +++ b/extend/Yzh/Model/Realname/CollectRealNameInfoRequest.php @@ -0,0 +1,97 @@ +{$property} = $params[$property]; + } + } + } +} diff --git a/extend/Yzh/Model/Realname/CollectRealNameInfoResponse.php b/extend/Yzh/Model/Realname/CollectRealNameInfoResponse.php new file mode 100644 index 0000000..e9ff1d4 --- /dev/null +++ b/extend/Yzh/Model/Realname/CollectRealNameInfoResponse.php @@ -0,0 +1,33 @@ +data; + } + + /** + * 设置数据对象 + * @param array $data + * @return self + */ + public function setData($data) + { + $this->data = new CollectRealNameInfoResponseData($data); + return $this; + } +} diff --git a/extend/Yzh/Model/Realname/CollectRealNameInfoResponseData.php b/extend/Yzh/Model/Realname/CollectRealNameInfoResponseData.php new file mode 100644 index 0000000..404264c --- /dev/null +++ b/extend/Yzh/Model/Realname/CollectRealNameInfoResponseData.php @@ -0,0 +1,37 @@ +status = $status; + } + + /** + * 录入状态 + * @return string + */ + public function getStatus() + { + return $this->status; + } +} diff --git a/extend/Yzh/Model/Realname/QueryRealNameInfoRequest.php b/extend/Yzh/Model/Realname/QueryRealNameInfoRequest.php new file mode 100644 index 0000000..9391520 --- /dev/null +++ b/extend/Yzh/Model/Realname/QueryRealNameInfoRequest.php @@ -0,0 +1,42 @@ +{$property} = $params[$property]; + } + } + } +} diff --git a/extend/Yzh/Model/Realname/QueryRealNameInfoResponse.php b/extend/Yzh/Model/Realname/QueryRealNameInfoResponse.php new file mode 100644 index 0000000..b381c22 --- /dev/null +++ b/extend/Yzh/Model/Realname/QueryRealNameInfoResponse.php @@ -0,0 +1,33 @@ +data; + } + + /** + * 设置数据对象 + * @param array $data + * @return self + */ + public function setData($data) + { + $this->data = new QueryRealNameInfoResponseData($data); + return $this; + } +} diff --git a/extend/Yzh/Model/Realname/QueryRealNameInfoResponseData.php b/extend/Yzh/Model/Realname/QueryRealNameInfoResponseData.php new file mode 100644 index 0000000..7122c91 --- /dev/null +++ b/extend/Yzh/Model/Realname/QueryRealNameInfoResponseData.php @@ -0,0 +1,244 @@ +realname_result = $realname_result; + } + + /** + * 实名认证结果 + * @return int32 + */ + public function getRealnameResult() + { + return $this->realname_result; + } + + /** + * 实名认证通过时间 + * @var string $realname_time + */ + public function setRealnameTime($realname_time) + { + $this->realname_time = $realname_time; + } + + /** + * 实名认证通过时间 + * @return string + */ + public function getRealnameTime() + { + return $this->realname_time; + } + + /** + * 实名认证方式 + * @var int32 $realname_type + */ + public function setRealnameType($realname_type) + { + $this->realname_type = $realname_type; + } + + /** + * 实名认证方式 + * @return int32 + */ + public function getRealnameType() + { + return $this->realname_type; + } + + /** + * 实名认证唯一可追溯编码 + * @var string $realname_trace_id + */ + public function setRealnameTraceId($realname_trace_id) + { + $this->realname_trace_id = $realname_trace_id; + } + + /** + * 实名认证唯一可追溯编码 + * @return string + */ + public function getRealnameTraceId() + { + return $this->realname_trace_id; + } + + /** + * 认证平台 + * @var string $realname_platform + */ + public function setRealnamePlatform($realname_platform) + { + $this->realname_platform = $realname_platform; + } + + /** + * 认证平台 + * @return string + */ + public function getRealnamePlatform() + { + return $this->realname_platform; + } + + /** + * 是否存在人脸照片 + * @var string $face_image + */ + public function setFaceImage($face_image) + { + $this->face_image = $face_image; + } + + /** + * 是否存在人脸照片 + * @return string + */ + public function getFaceImage() + { + return $this->face_image; + } + + /** + * 人脸识别验证分数 + * @var string $face_verify_score + */ + public function setFaceVerifyScore($face_verify_score) + { + $this->face_verify_score = $face_verify_score; + } + + /** + * 人脸识别验证分数 + * @return string + */ + public function getFaceVerifyScore() + { + return $this->face_verify_score; + } + + /** + * 银行卡号 + * @var string $bank_no + */ + public function setBankNo($bank_no) + { + $this->bank_no = $bank_no; + } + + /** + * 银行卡号 + * @return string + */ + public function getBankNo() + { + return $this->bank_no; + } + + /** + * 银行预留手机号 + * @var string $bank_phone + */ + public function setBankPhone($bank_phone) + { + $this->bank_phone = $bank_phone; + } + + /** + * 银行预留手机号 + * @return string + */ + public function getBankPhone() + { + return $this->bank_phone; + } + + /** + * 平台企业审核人 + * @var string $reviewer + */ + public function setReviewer($reviewer) + { + $this->reviewer = $reviewer; + } + + /** + * 平台企业审核人 + * @return string + */ + public function getReviewer() + { + return $this->reviewer; + } +} diff --git a/extend/Yzh/Model/Usercollect/GetUserCollectPhoneStatusRequest.php b/extend/Yzh/Model/Usercollect/GetUserCollectPhoneStatusRequest.php new file mode 100644 index 0000000..842475d --- /dev/null +++ b/extend/Yzh/Model/Usercollect/GetUserCollectPhoneStatusRequest.php @@ -0,0 +1,52 @@ +{$property} = $params[$property]; + } + } + } +} diff --git a/extend/Yzh/Model/Usercollect/GetUserCollectPhoneStatusResponse.php b/extend/Yzh/Model/Usercollect/GetUserCollectPhoneStatusResponse.php new file mode 100644 index 0000000..786f7e2 --- /dev/null +++ b/extend/Yzh/Model/Usercollect/GetUserCollectPhoneStatusResponse.php @@ -0,0 +1,33 @@ +data; + } + + /** + * 设置数据对象 + * @param array $data + * @return self + */ + public function setData($data) + { + $this->data = new GetUserCollectPhoneStatusResponseData($data); + return $this; + } +} diff --git a/extend/Yzh/Model/Usercollect/GetUserCollectPhoneStatusResponseData.php b/extend/Yzh/Model/Usercollect/GetUserCollectPhoneStatusResponseData.php new file mode 100644 index 0000000..68b2d7c --- /dev/null +++ b/extend/Yzh/Model/Usercollect/GetUserCollectPhoneStatusResponseData.php @@ -0,0 +1,60 @@ +token = $token; + } + + /** + * 手机号码收集 Token + * @return string + */ + public function getToken() + { + return $this->token; + } + + /** + * 绑定状态 + * @var int32 $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * 绑定状态 + * @return int32 + */ + public function getStatus() + { + return $this->status; + } +} diff --git a/extend/Yzh/Model/Usercollect/GetUserCollectPhoneUrlRequest.php b/extend/Yzh/Model/Usercollect/GetUserCollectPhoneUrlRequest.php new file mode 100644 index 0000000..5f81dc4 --- /dev/null +++ b/extend/Yzh/Model/Usercollect/GetUserCollectPhoneUrlRequest.php @@ -0,0 +1,42 @@ +{$property} = $params[$property]; + } + } + } +} diff --git a/extend/Yzh/Model/Usercollect/GetUserCollectPhoneUrlResponse.php b/extend/Yzh/Model/Usercollect/GetUserCollectPhoneUrlResponse.php new file mode 100644 index 0000000..3eca655 --- /dev/null +++ b/extend/Yzh/Model/Usercollect/GetUserCollectPhoneUrlResponse.php @@ -0,0 +1,33 @@ +data; + } + + /** + * 设置数据对象 + * @param array $data + * @return self + */ + public function setData($data) + { + $this->data = new GetUserCollectPhoneUrlResponseData($data); + return $this; + } +} diff --git a/extend/Yzh/Model/Usercollect/GetUserCollectPhoneUrlResponseData.php b/extend/Yzh/Model/Usercollect/GetUserCollectPhoneUrlResponseData.php new file mode 100644 index 0000000..7b51924 --- /dev/null +++ b/extend/Yzh/Model/Usercollect/GetUserCollectPhoneUrlResponseData.php @@ -0,0 +1,37 @@ +url = $url; + } + + /** + * 收集手机号码页面 URL + * @return string + */ + public function getUrl() + { + return $this->url; + } +} diff --git a/extend/Yzh/Model/Usercollect/NotifyUserCollectPhoneRequest.php b/extend/Yzh/Model/Usercollect/NotifyUserCollectPhoneRequest.php new file mode 100644 index 0000000..bfcefd0 --- /dev/null +++ b/extend/Yzh/Model/Usercollect/NotifyUserCollectPhoneRequest.php @@ -0,0 +1,32 @@ +{$property} = $params[$property]; + } + } + } +} diff --git a/extend/Yzh/RealNameServiceClient.php b/extend/Yzh/RealNameServiceClient.php new file mode 100644 index 0000000..a6af073 --- /dev/null +++ b/extend/Yzh/RealNameServiceClient.php @@ -0,0 +1,49 @@ +collectRealNameInfo request 必须是 Yzh\\Model\\Realname\\CollectRealNameInfoRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM); + } + return $this->send('POST', '/api/user/v1/collect/realname/info', $request, "Yzh\\Model\\Realname\\CollectRealNameInfoResponse", $option); + } + + /** + * 用户实名认证信息查询 + * @param QueryRealNameInfoRequest $request + * @param null $option + * @return QueryRealNameInfoResponse + */ + public function queryRealNameInfo($request, $option = null) + { + if (!$request instanceof QueryRealNameInfoRequest) { + throw new ConfigException("Realname->queryRealNameInfo request 必须是 Yzh\\Model\\Realname\\QueryRealNameInfoRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM); + } + return $this->send('GET', '/api/user/v1/query/realname/info', $request, "Yzh\\Model\\Realname\\QueryRealNameInfoResponse", $option); + } +} \ No newline at end of file diff --git a/extend/Yzh/UserCollectServiceClient.php b/extend/Yzh/UserCollectServiceClient.php new file mode 100644 index 0000000..3654476 --- /dev/null +++ b/extend/Yzh/UserCollectServiceClient.php @@ -0,0 +1,49 @@ +getUserCollectPhoneStatus request 必须是 Yzh\\Model\\UserCollect\\GetUserCollectPhoneStatusRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM); + } + return $this->send('GET', '/api/user/v1/collect/phone/status', $request, "Yzh\\Model\\UserCollect\\GetUserCollectPhoneStatusResponse", $option); + } + + /** + * 获取收集手机号码页面 + * @param GetUserCollectPhoneUrlRequest $request + * @param null $option + * @return GetUserCollectPhoneUrlResponse + */ + public function getUserCollectPhoneUrl($request, $option = null) + { + if (!$request instanceof GetUserCollectPhoneUrlRequest) { + throw new ConfigException("UserCollect->getUserCollectPhoneUrl request 必须是 Yzh\\Model\\UserCollect\\GetUserCollectPhoneUrlRequest 实例", ExceptionCode::CONFIG_ERROR_WRONG_PARAM); + } + return $this->send('GET', '/api/user/v1/collect/phone/url', $request, "Yzh\\Model\\UserCollect\\GetUserCollectPhoneUrlResponse", $option); + } +} \ No newline at end of file diff --git a/vendor/adbario/php-dot-notation/LICENSE.md b/vendor/adbario/php-dot-notation/LICENSE.md new file mode 100644 index 0000000..fe01323 --- /dev/null +++ b/vendor/adbario/php-dot-notation/LICENSE.md @@ -0,0 +1,21 @@ +# The MIT License (MIT) + +Copyright (c) 2016-2019 Riku Särkinen + +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. diff --git a/vendor/adbario/php-dot-notation/composer.json b/vendor/adbario/php-dot-notation/composer.json new file mode 100644 index 0000000..cea7126 --- /dev/null +++ b/vendor/adbario/php-dot-notation/composer.json @@ -0,0 +1,29 @@ +{ + "name": "adbario/php-dot-notation", + "description": "PHP dot notation access to arrays", + "keywords": ["dotnotation", "arrayaccess"], + "homepage": "https://github.com/adbario/php-dot-notation", + "license": "MIT", + "authors": [ + { + "name": "Riku Särkinen", + "email": "riku@adbar.io" + } + ], + "require": { + "php": "^5.5 || ^7.0 || ^8.0", + "ext-json": "*" + }, + "require-dev": { + "phpunit/phpunit": "^4.8|^5.7|^6.6|^7.5|^8.5|^9.5", + "squizlabs/php_codesniffer": "^3.6" + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Adbar\\": "src" + } + } +} diff --git a/vendor/adbario/php-dot-notation/src/Dot.php b/vendor/adbario/php-dot-notation/src/Dot.php new file mode 100644 index 0000000..3cd1c50 --- /dev/null +++ b/vendor/adbario/php-dot-notation/src/Dot.php @@ -0,0 +1,623 @@ + + * @link https://github.com/adbario/php-dot-notation + * @license https://github.com/adbario/php-dot-notation/blob/2.x/LICENSE.md (MIT License) + */ +namespace Adbar; + +use Countable; +use ArrayAccess; +use ArrayIterator; +use JsonSerializable; +use IteratorAggregate; + +/** + * Dot + * + * This class provides a dot notation access and helper functions for + * working with arrays of data. Inspired by Laravel Collection. + */ +class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable +{ + /** + * The stored items + * + * @var array + */ + protected $items = []; + + + /** + * The delimiter (alternative to a '.') to be used. + * + * @var string + */ + protected $delimiter = '.'; + + + /** + * Create a new Dot instance + * + * @param mixed $items + * @param string $delimiter + */ + public function __construct($items = [], $delimiter = '.') + { + $this->items = $this->getArrayItems($items); + $this->delimiter = strlen($delimiter) ? $delimiter : '.'; + } + + /** + * Set a given key / value pair or pairs + * if the key doesn't exist already + * + * @param array|int|string $keys + * @param mixed $value + */ + public function add($keys, $value = null) + { + if (is_array($keys)) { + foreach ($keys as $key => $value) { + $this->add($key, $value); + } + } elseif (is_null($this->get($keys))) { + $this->set($keys, $value); + } + } + + /** + * Return all the stored items + * + * @return array + */ + public function all() + { + return $this->items; + } + + /** + * Delete the contents of a given key or keys + * + * @param array|int|string|null $keys + */ + public function clear($keys = null) + { + if (is_null($keys)) { + $this->items = []; + + return; + } + + $keys = (array) $keys; + + foreach ($keys as $key) { + $this->set($key, []); + } + } + + /** + * Delete the given key or keys + * + * @param array|int|string $keys + */ + public function delete($keys) + { + $keys = (array) $keys; + + foreach ($keys as $key) { + if ($this->exists($this->items, $key)) { + unset($this->items[$key]); + + continue; + } + + $items = &$this->items; + $segments = explode($this->delimiter, $key); + $lastSegment = array_pop($segments); + + foreach ($segments as $segment) { + if (!isset($items[$segment]) || !is_array($items[$segment])) { + continue 2; + } + + $items = &$items[$segment]; + } + + unset($items[$lastSegment]); + } + } + + /** + * Checks if the given key exists in the provided array. + * + * @param array $array Array to validate + * @param int|string $key The key to look for + * + * @return bool + */ + protected function exists($array, $key) + { + return array_key_exists($key, $array); + } + + /** + * Flatten an array with the given character as a key delimiter + * + * @param string $delimiter + * @param array|null $items + * @param string $prepend + * @return array + */ + public function flatten($delimiter = '.', $items = null, $prepend = '') + { + $flatten = []; + + if (is_null($items)) { + $items = $this->items; + } + + if (!func_num_args()) { + $delimiter = $this->delimiter; + } + + foreach ($items as $key => $value) { + if (is_array($value) && !empty($value)) { + $flatten = array_merge( + $flatten, + $this->flatten($delimiter, $value, $prepend.$key.$delimiter) + ); + } else { + $flatten[$prepend.$key] = $value; + } + } + + return $flatten; + } + + /** + * Return the value of a given key + * + * @param int|string|null $key + * @param mixed $default + * @return mixed + */ + public function get($key = null, $default = null) + { + if (is_null($key)) { + return $this->items; + } + + if ($this->exists($this->items, $key)) { + return $this->items[$key]; + } + + if (strpos($key, $this->delimiter) === false) { + return $default; + } + + $items = $this->items; + + foreach (explode($this->delimiter, $key) as $segment) { + if (!is_array($items) || !$this->exists($items, $segment)) { + return $default; + } + + $items = &$items[$segment]; + } + + return $items; + } + + /** + * Return the given items as an array + * + * @param mixed $items + * @return array + */ + protected function getArrayItems($items) + { + if (is_array($items)) { + return $items; + } elseif ($items instanceof self) { + return $items->all(); + } + + return (array) $items; + } + + /** + * Check if a given key or keys exists + * + * @param array|int|string $keys + * @return bool + */ + public function has($keys) + { + $keys = (array) $keys; + + if (!$this->items || $keys === []) { + return false; + } + + foreach ($keys as $key) { + $items = $this->items; + + if ($this->exists($items, $key)) { + continue; + } + + foreach (explode($this->delimiter, $key) as $segment) { + if (!is_array($items) || !$this->exists($items, $segment)) { + return false; + } + + $items = $items[$segment]; + } + } + + return true; + } + + /** + * Check if a given key or keys are empty + * + * @param array|int|string|null $keys + * @return bool + */ + public function isEmpty($keys = null) + { + if (is_null($keys)) { + return empty($this->items); + } + + $keys = (array) $keys; + + foreach ($keys as $key) { + if (!empty($this->get($key))) { + return false; + } + } + + return true; + } + + /** + * Merge a given array or a Dot object with the given key + * or with the whole Dot object + * + * @param array|string|self $key + * @param array|self $value + */ + public function merge($key, $value = []) + { + if (is_array($key)) { + $this->items = array_merge($this->items, $key); + } elseif (is_string($key)) { + $items = (array) $this->get($key); + $value = array_merge($items, $this->getArrayItems($value)); + + $this->set($key, $value); + } elseif ($key instanceof self) { + $this->items = array_merge($this->items, $key->all()); + } + } + + /** + * Recursively merge a given array or a Dot object with the given key + * or with the whole Dot object. + * + * Duplicate keys are converted to arrays. + * + * @param array|string|self $key + * @param array|self $value + */ + public function mergeRecursive($key, $value = []) + { + if (is_array($key)) { + $this->items = array_merge_recursive($this->items, $key); + } elseif (is_string($key)) { + $items = (array) $this->get($key); + $value = array_merge_recursive($items, $this->getArrayItems($value)); + + $this->set($key, $value); + } elseif ($key instanceof self) { + $this->items = array_merge_recursive($this->items, $key->all()); + } + } + + /** + * Recursively merge a given array or a Dot object with the given key + * or with the whole Dot object. + * + * Instead of converting duplicate keys to arrays, the value from + * given array will replace the value in Dot object. + * + * @param array|string|self $key + * @param array|self $value + */ + public function mergeRecursiveDistinct($key, $value = []) + { + if (is_array($key)) { + $this->items = $this->arrayMergeRecursiveDistinct($this->items, $key); + } elseif (is_string($key)) { + $items = (array) $this->get($key); + $value = $this->arrayMergeRecursiveDistinct($items, $this->getArrayItems($value)); + + $this->set($key, $value); + } elseif ($key instanceof self) { + $this->items = $this->arrayMergeRecursiveDistinct($this->items, $key->all()); + } + } + + /** + * Merges two arrays recursively. In contrast to array_merge_recursive, + * duplicate keys are not converted to arrays but rather overwrite the + * value in the first array with the duplicate value in the second array. + * + * @param array $array1 Initial array to merge + * @param array $array2 Array to recursively merge + * @return array + */ + protected function arrayMergeRecursiveDistinct(array $array1, array $array2) + { + $merged = &$array1; + + foreach ($array2 as $key => $value) { + if (is_array($value) && isset($merged[$key]) && is_array($merged[$key])) { + $merged[$key] = $this->arrayMergeRecursiveDistinct($merged[$key], $value); + } else { + $merged[$key] = $value; + } + } + + return $merged; + } + + /** + * Return the value of a given key and + * delete the key + * + * @param int|string|null $key + * @param mixed $default + * @return mixed + */ + public function pull($key = null, $default = null) + { + if (is_null($key)) { + $value = $this->all(); + $this->clear(); + + return $value; + } + + $value = $this->get($key, $default); + $this->delete($key); + + return $value; + } + + /** + * Push a given value to the end of the array + * in a given key + * + * @param mixed $key + * @param mixed $value + */ + public function push($key, $value = null) + { + if (is_null($value)) { + $this->items[] = $key; + + return; + } + + $items = $this->get($key); + + if (is_array($items) || is_null($items)) { + $items[] = $value; + $this->set($key, $items); + } + } + + /** + * Replace all values or values within the given key + * with an array or Dot object + * + * @param array|string|self $key + * @param array|self $value + */ + public function replace($key, $value = []) + { + if (is_array($key)) { + $this->items = array_replace($this->items, $key); + } elseif (is_string($key)) { + $items = (array) $this->get($key); + $value = array_replace($items, $this->getArrayItems($value)); + + $this->set($key, $value); + } elseif ($key instanceof self) { + $this->items = array_replace($this->items, $key->all()); + } + } + + /** + * Set a given key / value pair or pairs + * + * @param array|int|string $keys + * @param mixed $value + */ + public function set($keys, $value = null) + { + if (is_array($keys)) { + foreach ($keys as $key => $value) { + $this->set($key, $value); + } + + return; + } + + $items = &$this->items; + + foreach (explode($this->delimiter, $keys) as $key) { + if (!isset($items[$key]) || !is_array($items[$key])) { + $items[$key] = []; + } + + $items = &$items[$key]; + } + + $items = $value; + } + + /** + * Replace all items with a given array + * + * @param mixed $items + */ + public function setArray($items) + { + $this->items = $this->getArrayItems($items); + } + + /** + * Replace all items with a given array as a reference + * + * @param array $items + */ + public function setReference(array &$items) + { + $this->items = &$items; + } + + /** + * Return the value of a given key or all the values as JSON + * + * @param mixed $key + * @param int $options + * @return string + */ + public function toJson($key = null, $options = 0) + { + if (is_string($key)) { + return json_encode($this->get($key), $options); + } + + $options = $key === null ? 0 : $key; + + return json_encode($this->items, $options); + } + + /* + * -------------------------------------------------------------- + * ArrayAccess interface + * -------------------------------------------------------------- + */ + + /** + * Check if a given key exists + * + * @param int|string $key + * @return bool + */ + #[\ReturnTypeWillChange] + public function offsetExists($key) + { + return $this->has($key); + } + + /** + * Return the value of a given key + * + * @param int|string $key + * @return mixed + */ + #[\ReturnTypeWillChange] + public function offsetGet($key) + { + return $this->get($key); + } + + /** + * Set a given value to the given key + * + * @param int|string|null $key + * @param mixed $value + */ + #[\ReturnTypeWillChange] + public function offsetSet($key, $value) + { + if (is_null($key)) { + $this->items[] = $value; + + return; + } + + $this->set($key, $value); + } + + /** + * Delete the given key + * + * @param int|string $key + */ + #[\ReturnTypeWillChange] + public function offsetUnset($key) + { + $this->delete($key); + } + + /* + * -------------------------------------------------------------- + * Countable interface + * -------------------------------------------------------------- + */ + + /** + * Return the number of items in a given key + * + * @param int|string|null $key + * @return int + */ + #[\ReturnTypeWillChange] + public function count($key = null) + { + return count($this->get($key)); + } + + /* + * -------------------------------------------------------------- + * IteratorAggregate interface + * -------------------------------------------------------------- + */ + + /** + * Get an iterator for the stored items + * + * @return \ArrayIterator + */ + #[\ReturnTypeWillChange] + public function getIterator() + { + return new ArrayIterator($this->items); + } + + /* + * -------------------------------------------------------------- + * JsonSerializable interface + * -------------------------------------------------------------- + */ + + /** + * Return items for JSON serialization + * + * @return array + */ + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + return $this->items; + } +} diff --git a/vendor/adbario/php-dot-notation/src/helpers.php b/vendor/adbario/php-dot-notation/src/helpers.php new file mode 100644 index 0000000..bebb952 --- /dev/null +++ b/vendor/adbario/php-dot-notation/src/helpers.php @@ -0,0 +1,24 @@ + + * @link https://github.com/adbario/php-dot-notation + * @license https://github.com/adbario/php-dot-notation/blob/2.x/LICENSE.md (MIT License) + */ + +use Adbar\Dot; + +if (! function_exists('dot')) { + /** + * Create a new Dot object with the given items and optional delimiter + * + * @param mixed $items + * @param string $delimiter + * @return \Adbar\Dot + */ + function dot($items, $delimiter = '.') + { + return new Dot($items, $delimiter); + } +} diff --git a/vendor/alibabacloud/credentials/CHANGELOG.md b/vendor/alibabacloud/credentials/CHANGELOG.md new file mode 100644 index 0000000..703a558 --- /dev/null +++ b/vendor/alibabacloud/credentials/CHANGELOG.md @@ -0,0 +1,18 @@ +# CHANGELOG + +## 1.2.0 - 2024-10-17 + +- Refactor all credentials providers. + +## 1.1.3 - 2020-12-24 + +- Require guzzle ^6.3|^7.0 + +## 1.0.2 - 2020-02-14 +- Update Tea. + +## 1.0.1 - 2019-12-30 +- Supported get `Role Name` automatically. + +## 1.0.0 - 2019-09-01 +- Initial release of the Alibaba Cloud Credentials for PHP Version 1.0.0 on Packagist See for more information. diff --git a/vendor/alibabacloud/credentials/CONTRIBUTING.md b/vendor/alibabacloud/credentials/CONTRIBUTING.md new file mode 100644 index 0000000..8ed9330 --- /dev/null +++ b/vendor/alibabacloud/credentials/CONTRIBUTING.md @@ -0,0 +1,30 @@ +# CONTRIBUTING + +We work hard to provide a high-quality and useful SDK for Alibaba Cloud, and +we greatly value feedback and contributions from our community. Please submit +your [issues][issues] or [pull requests][pull-requests] through GitHub. + +## Tips + +- The SDK is released under the [Apache license][license]. Any code you submit + will be released under that license. For substantial contributions, we may + ask you to sign a [Alibaba Documentation Corporate Contributor License + Agreement (CLA)][cla]. +- We follow all of the relevant PSR recommendations from the [PHP Framework + Interop Group][php-fig]. Please submit code that follows these standards. + The [PHP CS Fixer][cs-fixer] tool can be helpful for formatting your code. + Your can use `composer fixer` to fix code. +- We maintain a high percentage of code coverage in our unit tests. If you make + changes to the code, please add, update, and/or remove tests as appropriate. +- If your code does not conform to the PSR standards, does not include adequate + tests, or does not contain a changelog document, we may ask you to update + your pull requests before we accept them. We also reserve the right to deny + any pull requests that do not align with our standards or goals. + +[issues]: https://github.com/aliyun/credentials-php/issues +[pull-requests]: https://github.com/aliyun/credentials-php/pulls +[license]: http://www.apache.org/licenses/LICENSE-2.0 +[cla]: https://alibaba-cla-2018.oss-cn-beijing.aliyuncs.com/Alibaba_Documentation_Open_Source_Corporate_CLA.pdf +[php-fig]: http://php-fig.org +[cs-fixer]: http://cs.sensiolabs.org/ +[docs-readme]: https://github.com/aliyun/credentials-php/blob/master/README.md diff --git a/vendor/alibabacloud/credentials/LICENSE.md b/vendor/alibabacloud/credentials/LICENSE.md new file mode 100644 index 0000000..ec13fcc --- /dev/null +++ b/vendor/alibabacloud/credentials/LICENSE.md @@ -0,0 +1,13 @@ +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vendor/alibabacloud/credentials/NOTICE.md b/vendor/alibabacloud/credentials/NOTICE.md new file mode 100644 index 0000000..97db193 --- /dev/null +++ b/vendor/alibabacloud/credentials/NOTICE.md @@ -0,0 +1,88 @@ +# NOTICE + + + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"). +You may not use this file except in compliance with the License. +A copy of the License is located at + + + +or in the "license" file accompanying this file. This file is distributed +on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +express or implied. See the License for the specific language governing +permissions and limitations under the License. + +# Guzzle + + + +Copyright (c) 2011-2018 Michael Dowling, https://github.com/mtdowling + +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. + +# jmespath.php + + + +Copyright (c) 2014 Michael Dowling, https://github.com/mtdowling + +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. + +# Dot + + + +Copyright (c) 2016-2019 Riku Särkinen + +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. diff --git a/vendor/alibabacloud/credentials/README-zh-CN.md b/vendor/alibabacloud/credentials/README-zh-CN.md new file mode 100644 index 0000000..5ef6ecd --- /dev/null +++ b/vendor/alibabacloud/credentials/README-zh-CN.md @@ -0,0 +1,423 @@ +[English](/README.md) | 简体中文 + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +# Alibaba Cloud Credentials for PHP + +[![PHP CI](https://github.com/aliyun/credentials-php/actions/workflows/ci.yml/badge.svg)](https://github.com/aliyun/credentials-php/actions/workflows/ci.yml) +[![codecov](https://codecov.io/gh/aliyun/credentials-php/graph/badge.svg?token=YIkSjtfKbB)](https://codecov.io/gh/aliyun/credentials-php) +[![Latest Stable Version](https://poser.pugx.org/alibabacloud/credentials/v/stable)](https://packagist.org/packages/alibabacloud/credentials) +[![composer.lock](https://poser.pugx.org/alibabacloud/credentials/composerlock)](https://packagist.org/packages/alibabacloud/credentials) +[![Total Downloads](https://poser.pugx.org/alibabacloud/credentials/downloads)](https://packagist.org/packages/alibabacloud/credentials) +[![License](https://poser.pugx.org/alibabacloud/credentials/license)](https://packagist.org/packages/alibabacloud/credentials) + +Alibaba Cloud Credentials for PHP 是帮助 PHP 开发者管理凭据的工具。 + +## 先决条件 + +您的系统需要满足[先决条件](/docs/zh-CN/0-Prerequisites.md),包括 PHP> = 5.6。 我们强烈建议使用cURL扩展,并使用TLS后端编译cURL 7.16.2+。 + +## 安装依赖 + +如果已在系统上[全局安装 Composer](https://getcomposer.org/doc/00-intro.md#globally),请直接在项目目录中运行以下内容来安装 Alibaba Cloud Credentials for PHP 作为依赖项: + +```sh +composer require alibabacloud/credentials +``` + +> 一些用户可能由于网络问题无法安装,可以使用[阿里云 Composer 全量镜像](https://developer.aliyun.com/composer)。 + +请看[安装](/docs/zh-CN/1-Installation.md)有关通过 Composer 和其他方式安装的详细信息。 + +## 快速使用 + +在您开始之前,您需要注册阿里云帐户并获取您的[凭证](https://usercenter.console.aliyun.com/#/manage/ak)。 + +### 凭证类型 + +#### 使用默认凭据链 +当您在初始化凭据客户端不传入任何参数时,Credentials工具会使用默认凭据链方式初始化客户端。默认凭据的读取逻辑请参见[默认凭据链](#默认凭证提供程序链)。 + +```php +getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### AccessKey + +通过[用户信息管理][ak]设置 access_key,它们具有该账户完全的权限,请妥善保管。有时出于安全考虑,您不能把具有完全访问权限的主账户 AccessKey 交于一个项目的开发者使用,您可以[创建RAM子账户][ram]并为子账户[授权][permissions],使用RAM子用户的 AccessKey 来进行API调用。 + +```php + 'access_key', + 'accessKeyId' => '', + 'accessKeySecret' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +``` + +#### STS + +通过安全令牌服务(Security Token Service,简称 STS),申请临时安全凭证(Temporary Security Credentials,简称 TSC),创建临时安全凭证。 + +```php + 'sts', + 'accessKeyId' => '', + 'accessKeySecret' => '', + 'securityToken' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### RamRoleArn + +通过指定RAM角色的ARN(Alibabacloud Resource Name),Credentials工具可以帮助开发者前往STS换取STS Token。您也可以通过为 `Policy` 赋值来限制RAM角色到一个更小的权限集合。 + +```php + 'ram_role_arn', + 'accessKeyId' => '', + 'accessKeySecret' => '', + // 要扮演的RAM角色ARN,示例值:acs:ram::123456789012****:role/adminrole,可以通过环境变量ALIBABA_CLOUD_ROLE_ARN设置role_arn + 'roleArn' => '', + // 角色会话名称,可以通过环境变量ALIBABA_CLOUD_ROLE_SESSION_NAME设置role_session_name + 'roleSessionName' => '', + // 设置更小的权限策略,非必填。示例值:{"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"} + 'policy' => '', + // 设置session过期时间,非必填。 + 'roleSessionExpiration' => 3600, +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### EcsRamRole + +ECS和ECI实例均支持绑定实例RAM角色,当在实例中使用Credentials工具时,将自动获取实例绑定的RAM角色,并通过访问元数据服务获取RAM角色的STS Token,以完成凭据客户端的初始化。 + +实例元数据服务器支持加固模式和普通模式两种访问方式,Credentials工具默认使用加固模式(IMDSv2)获取访问凭据。若使用加固模式时发生异常,您可以通过设置disableIMDSv1来执行不同的异常处理逻辑: + +- 当值为false(默认值)时,会使用普通模式继续获取访问凭据。 + +- 当值为true时,表示只能使用加固模式获取访问凭据,会抛出异常。 + +服务端是否支持IMDSv2,取决于您在服务器的配置。 + +```php + 'ecs_ram_role', + // 选填,该ECS角色的角色名称,不填会自动获取,但是建议加上以减少请求次数,可以通过环境变量ALIBABA_CLOUD_ECS_METADATA设置role_name + 'roleName' => '', + // 选填,是否强制关闭IMDSv1,即必须使用IMDSv2加固模式,可以通过环境变量ALIBABA_CLOUD_IMDSV1_DISABLED设置 + 'disableIMDSv1' => true, +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### OIDCRoleArn + +在容器服务 Kubernetes 版中设置了Worker节点RAM角色后,对应节点内的Pod中的应用也就可以像ECS上部署的应用一样,通过元数据服务(Meta Data Server)获取关联角色的STS Token。但如果容器集群上部署的是不可信的应用(比如部署您的客户提交的应用,代码也没有对您开放),您可能并不希望它们能通过元数据服务获取Worker节点关联实例RAM角色的STS Token。为了避免影响云上资源的安全,同时又能让这些不可信的应用安全地获取所需的 STS Token,实现应用级别的权限最小化,您可以使用RRSA(RAM Roles for Service Account)功能。阿里云容器集群会为不同的应用Pod创建和挂载相应的服务账户OIDC Token文件,并将相关配置信息注入到环境变量中,Credentials工具通过获取环境变量的配置信息,调用STS服务的AssumeRoleWithOIDC - OIDC角色SSO时获取扮演角色的临时身份凭证接口换取绑定角色的STS Token。详情请参见[通过RRSA配置ServiceAccount的RAM权限实现Pod权限隔离](https://help.aliyun.com/zh/ack/ack-managed-and-ack-dedicated/user-guide/use-rrsa-to-authorize-pods-to-access-different-cloud-services#task-2142941)。 + +```php + 'oidc_role_arn', + // OIDC提供商ARN,可以通过环境变量ALIBABA_CLOUD_OIDC_PROVIDER_ARN设置oidc_provider_arn + 'oidcProviderArn' => '', + // OIDC Token文件路径,可以通过环境变量ALIBABA_CLOUD_OIDC_TOKEN_FILE设置oidc_token_file_path + 'oidcTokenFilePath' => '', + // 要扮演的RAM角色ARN,示例值:acs:ram::123456789012****:role/adminrole,可以通过环境变量ALIBABA_CLOUD_ROLE_ARN设置role_arn + 'roleArn' => '', + // 角色会话名称,可以通过环境变量ALIBABA_CLOUD_ROLE_SESSION_NAME设置role_session_name + 'roleSessionName' => '', + // 设置更小的权限策略,非必填。示例值:{"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"} + 'policy' => '', + # 设置session过期时间 + 'roleSessionExpiration' => 3600, +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### Credentials URI + +通过指定提供凭证的自定义网络服务地址,让凭证自动申请维护 STS Token。 + +```php + 'credentials_uri', + // 凭证的 URI,格式为http://local_or_remote_uri/,可以通过环境变量ALIBABA_CLOUD_CREDENTIALS_URI设置credentials_uri + 'credentialsURI' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### Bearer Token + +目前只有云呼叫中心 CCC 这款产品支持 Bearer Token 的凭据初始化方式。 + +```php + 'bearer', + // 填入您的Bearer Token + 'bearerToken' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getBearerToken(); +``` + +## 默认凭证提供程序链 + +当您的程序开发环境和生产环境采用不同的凭据类型,常见做法是在代码中获取当前环境信息,编写获取不同凭据的分支代码。借助Credentials工具的默认凭据链,您可以用同一套代码,通过程序之外的配置来控制不同环境下的凭据获取方式。当您在不传入参数的情况下,直接使用$credential = new Credential();初始化凭据客户端时,阿里云SDK将会尝试按照如下顺序查找相关凭据信息。 + +### 1. 使用环境变量 + +Credentials工具会优先在环境变量中获取凭据信息。 + +- 如果系统环境变量 `ALIBABA_CLOUD_ACCESS_KEY_ID`(密钥Key) 和 `ALIBABA_CLOUD_ACCESS_KEY_SECRET`(密钥Value) 不为空,Credentials工具会优先使用它们作为默认凭据。 + +- 如果系统环境变量 `ALIBABA_CLOUD_ACCESS_KEY_ID`(密钥Key)、`ALIBABA_CLOUD_ACCESS_KEY_SECRET`(密钥Value)、`ALIBABA_CLOUD_SECURITY_TOKEN`(Token)均不为空,Credentials工具会优先使用STS Token作为默认凭据。 + +### 2. 使用OIDC RAM角色 +若不存在优先级更高的凭据信息,Credentials工具会在环境变量中获取如下内容: + +`ALIBABA_CLOUD_ROLE_ARN`:RAM角色名称ARN; + +`ALIBABA_CLOUD_OIDC_PROVIDER_ARN`:OIDC提供商ARN; + +`ALIBABA_CLOUD_OIDC_TOKEN_FILE`:OIDC Token文件路径; + +若以上三个环境变量都已设置内容,Credentials将会使用变量内容调用STS服务的[AssumeRoleWithOIDC - OIDC角色SSO时获取扮演角色的临时身份凭证](https://help.aliyun.com/zh/ram/developer-reference/api-sts-2015-04-01-assumerolewithoidc)接口换取STS Token作为默认凭据。 + +### 3. 使用 Aliyun CLI 工具的 config.json 配置文件 + +若不存在优先级更高的凭据信息,Credentials工具会优先在如下位置查找 `config.json` 文件是否存在: +Linux系统:`~/.aliyun/config.json` +Windows系统: `C:\Users\USER_NAME\.aliyun\config.json` +如果文件存在,程序将会使用配置文件中 `current` 指定的凭据信息初始化凭据客户端。当然,您也可以通过环境变量 `ALIBABA_CLOUD_PROFILE` 来指定凭据信息,例如设置 `ALIBABA_CLOUD_PROFILE` 的值为 `AK`。 + +在config.json配置文件中每个module的值代表了不同的凭据信息获取方式: + +- AK:使用用户的Access Key作为凭据信息; +- RamRoleArn:使用RAM角色的ARN来获取凭据信息; +- EcsRamRole:利用ECS绑定的RAM角色来获取凭据信息; +- OIDC:通过OIDC ARN和OIDC Token来获取凭据信息; +- ChainableRamRoleArn:采用角色链的方式,通过指定JSON文件中的其他凭据,以重新获取新的凭据信息。 + +配置示例信息如下: + +```json +{ + "current": "AK", + "profiles": [ + { + "name": "AK", + "mode": "AK", + "access_key_id": "access_key_id", + "access_key_secret": "access_key_secret" + }, + { + "name": "RamRoleArn", + "mode": "RamRoleArn", + "access_key_id": "access_key_id", + "access_key_secret": "access_key_secret", + "ram_role_arn": "ram_role_arn", + "ram_session_name": "ram_session_name", + "expired_seconds": 3600, + "sts_region": "cn-hangzhou" + }, + { + "name": "EcsRamRole", + "mode": "EcsRamRole", + "ram_role_name": "ram_role_name" + }, + { + "name": "OIDC", + "mode": "OIDC", + "ram_role_arn": "ram_role_arn", + "oidc_token_file": "path/to/oidc/file", + "oidc_provider_arn": "oidc_provider_arn", + "ram_session_name": "ram_session_name", + "expired_seconds": 3600, + "sts_region": "cn-hangzhou" + }, + { + "name": "ChainableRamRoleArn", + "mode": "ChainableRamRoleArn", + "source_profile": "AK", + "ram_role_arn": "ram_role_arn", + "ram_session_name": "ram_session_name", + "expired_seconds": 3600, + "sts_region": "cn-hangzhou" + } + ] +} +``` + +### 4. 使用配置文件 +> +> 如果用户主目录存在默认文件 `~/.alibabacloud/credentials` (Windows 为 `C:\Users\USER_NAME\.alibabacloud\credentials`),程序会自动创建指定类型和名称的凭证。您也可通过环境变量 `ALIBABA_CLOUD_CREDENTIALS_FILE` 指定配置文件路径。如果文件存在,程序将会使用配置文件中 default 指定的凭据信息初始化凭据客户端。当然,您也可以通过环境变量 `ALIBABA_CLOUD_PROFILE` 来指定凭据信息,例如设置 `ALIBABA_CLOUD_PROFILE` 的值为 `client1`。 + +配置示例信息如下: + +```ini +[default] +type = access_key # 认证方式为 access_key +access_key_id = foo # Key +access_key_secret = bar # Secret + +[project1] +type = ecs_ram_role # 认证方式为 ecs_ram_role +role_name = EcsRamRoleTest # Role Name,非必填,不填则自动获取,建议设置,可以减少网络请求。 + +[project2] +type = ram_role_arn # 认证方式为 ram_role_arn +access_key_id = foo +access_key_secret = bar +role_arn = role_arn +role_session_name = session_name + +[project3] +type=oidc_role_arn # 认证方式为 oidc_role_arn +oidc_provider_arn=oidc_provider_arn +oidc_token_file_path=oidc_token_file_path +role_arn=role_arn +role_session_name=session_name +``` + +### 5. 使用 ECS 实例RAM角色 + +若不存在优先级更高的凭据信息,Credentials工具将通过环境变量获取ALIBABA_CLOUD_ECS_METADATA(ECS实例RAM角色名称)的值。若该变量的值存在,程序将采用加固模式(IMDSv2)访问ECS的元数据服务(Meta Data Server),以获取ECS实例RAM角色的STS Token作为默认凭据信息。在使用加固模式时若发生异常,将使用普通模式兜底来获取访问凭据。您也可以通过设置环境变量ALIBABA_CLOUD_IMDSV1_DISABLED,执行不同的异常处理逻辑: + +- 当值为false时,会使用普通模式继续获取访问凭据。 + +- 当值为true时,表示只能使用加固模式获取访问凭据,会抛出异常。 + +服务端是否支持IMDSv2,取决于您在服务器的配置。 + +### 6. 使用外部服务 Credentials URI + +若不存在优先级更高的凭据信息,Credentials工具会在环境变量中获取ALIBABA_CLOUD_CREDENTIALS_URI,若存在,程序将请求该URI地址,获取临时安全凭证作为默认凭据信息。 + +外部服务响应结构应如下: + +```json +{ + "Code": "Success", + "AccessKeyId": "AccessKeyId", + "AccessKeySecret": "AccessKeySecret", + "SecurityToken": "SecurityToken", + "Expiration": "2024-10-26T03:46:38Z" +} +``` + +## 文档 + +* [先决条件](/docs/zh-CN/0-Prerequisites.md) +* [安装](/docs/zh-CN/1-Installation.md) + +## 问题 + +[提交 Issue](https://github.com/aliyun/credentials-php/issues/new/choose),不符合指南的问题可能会立即关闭。 + +## 发行说明 + +每个版本的详细更改记录在[发行说明](/CHANGELOG.md)中。 + +## 贡献 + +提交 Pull Request 之前请阅读[贡献指南](/CONTRIBUTING.md)。 + +## 相关 + +* [OpenAPI 开发者门户][open-api] +* [Packagist][packagist] +* [Composer][composer] +* [Guzzle中文文档][guzzle-docs] +* [最新源码][latest-release] + +## 许可证 + +[Apache-2.0](/LICENSE.md) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + +[open-api]: https://api.aliyun.com +[latest-release]: https://github.com/aliyun/credentials-php +[guzzle-docs]: https://guzzle-cn.readthedocs.io/zh_CN/latest/request-options.html +[composer]: https://getcomposer.org +[packagist]: https://packagist.org/packages/alibabacloud/credentials diff --git a/vendor/alibabacloud/credentials/README.md b/vendor/alibabacloud/credentials/README.md new file mode 100644 index 0000000..e646999 --- /dev/null +++ b/vendor/alibabacloud/credentials/README.md @@ -0,0 +1,422 @@ +English | [简体中文](/README-zh-CN.md) + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +# Alibaba Cloud Credentials for PHP + +[![PHP CI](https://github.com/aliyun/credentials-php/actions/workflows/ci.yml/badge.svg)](https://github.com/aliyun/credentials-php/actions/workflows/ci.yml) +[![codecov](https://codecov.io/gh/aliyun/credentials-php/graph/badge.svg?token=YIkSjtfKbB)](https://codecov.io/gh/aliyun/credentials-php) +[![Latest Stable Version](https://poser.pugx.org/alibabacloud/credentials/v/stable)](https://packagist.org/packages/alibabacloud/credentials) +[![composer.lock](https://poser.pugx.org/alibabacloud/credentials/composerlock)](https://packagist.org/packages/alibabacloud/credentials) +[![Total Downloads](https://poser.pugx.org/alibabacloud/credentials/downloads)](https://packagist.org/packages/alibabacloud/credentials) +[![License](https://poser.pugx.org/alibabacloud/credentials/license)](https://packagist.org/packages/alibabacloud/credentials) + +Alibaba Cloud Credentials for PHP is a tool that helps PHP developers manage their credentials. + +## Prerequisites + +Your system needs to meet [Prerequisites](/docs/zh-CN/0-Prerequisites.md), including PHP> = 5.6. We strongly recommend using the cURL extension and compiling cURL 7.16.2+ using the TLS backend. + +## Installation + +If you have [Globally Install Composer](https://getcomposer.org/doc/00-intro.md#globally) on your system, install Alibaba Cloud Credentials for PHP as a dependency by running the following directly in the project directory: + +```sh +composer require alibabacloud/credentials +``` + +> Some users may not be able to install due to network problems, you can switch to the [Alibaba Cloud Composer Mirror](https://developer.aliyun.com/composer). + +See [Installation](/docs/zh-CN/1-Installation.md) for details on installing through Composer and other means. + +## Quick Examples + +Before you begin, you need to sign up for an Alibaba Cloud account and retrieve your [Credentials](https://usercenter.console.aliyun.com/#/manage/ak). + +### Credential Type + +#### Default credential provider chain + +If you do not specify a method to initialize a Credentials client, the default credential provider chain is used. For more information, see the Default credential provider chain section of this topic. + +```php +getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### AccessKey + +Setup access_key credential through [User Information Management][ak], it have full authority over the account, please keep it safe. Sometimes for security reasons, you cannot hand over a primary account AccessKey with full access to the developer of a project. You may create a sub-account [RAM Sub-account][ram] , grant its [authorization][permissions],and use the AccessKey of RAM Sub-account. + +```php + 'access_key', + 'accessKeyId' => '', + 'accessKeySecret' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +``` + +#### STS + +Create a temporary security credential by applying Temporary Security Credentials (TSC) through the Security Token Service (STS). + +```php + 'sts', + 'accessKeyId' => '', + 'accessKeySecret' => '', + 'securityToken' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### RamRoleArn + +By specifying [RAM Role][RAM Role], the credential will be able to automatically request maintenance of STS Token. If you want to limit the permissions([How to make a policy][policy]) of STS Token, you can assign value for `Policy`. + +```php + 'ram_role_arn', + 'accessKeyId' => '', + 'accessKeySecret' => '', + // Specify the ARN of the RAM role to be assumed. Example: acs:ram::123456789012****:role/adminrole. + 'roleArn' => '', + // Specify the name of the role session. + 'roleSessionName' => '', + // Optional. Specify limited permissions for the RAM role. Example: {"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"}. + 'policy' => '', + // Optional. Specify the expiration of the session + 'roleSessionExpiration' => 3600, +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### EcsRamRole + +Both ECS and ECI instances support binding instance RAM roles. When the Credentials tool is used in an instance, the RAM role bound to the instance will be automatically obtained, and the STS Token of the RAM role will be obtained by accessing the metadata service to complete the initialization of the credential client. + +The instance metadata server supports two access modes: hardened mode and normal mode. The Credentials tool uses hardened mode (IMDSv2) by default to obtain access credentials. If an exception occurs when using hardened mode, you can set disableIMDSv1 to perform different exception handling logic: + +- When the value is false (default value), the normal mode will continue to be used to obtain access credentials. + +- When the value is true, it means that only hardened mode can be used to obtain access credentials, and an exception will be thrown. + +Whether the server supports IMDSv2 depends on your configuration on the server. + +```php + 'ecs_ram_role', + // Optional. Specify the name of the RAM role of the ECS instance. If you do not specify this parameter, its value is automatically obtained. To reduce the number of requests, we recommend that you specify this parameter. + 'roleName' => '', + //Optional, whether to forcibly disable IMDSv1, that is, to use IMDSv2 hardening mode, which can be set by the environment variable ALIBABA_CLOUD_IMDSV1_DISABLED + 'disableIMDSv1' => true, +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### OIDCRoleArn + +After you attach a RAM role to a worker node in an Container Service for Kubernetes, applications in the pods on the worker node can use the metadata server to obtain an STS token the same way in which applications on ECS instances do. However, if an untrusted application is deployed on the worker node, such as an application that is submitted by your customer and whose code is unavailable to you, you may not want the application to use the metadata server to obtain an STS token of the RAM role attached to the worker node. To ensure the security of cloud resources and enable untrusted applications to securely obtain required STS tokens, you can use the RAM Roles for Service Accounts (RRSA) feature to grant minimum necessary permissions to an application. In this case, the ACK cluster creates a service account OpenID Connect (OIDC) token file, associates the token file with a pod, and then injects relevant environment variables into the pod. Then, the Credentials tool uses the environment variables to call the AssumeRoleWithOIDC operation of STS and obtains an STS token of the RAM role. For more information about the RRSA feature, see [Use RRSA to authorize different pods to access different cloud services](https://www.alibabacloud.com/help/en/ack/ack-managed-and-ack-dedicated/user-guide/use-rrsa-to-authorize-pods-to-access-different-cloud-services#task-2142941). + +```php + 'oidc_role_arn', + // Specify the ARN of the OIDC IdP by specifying the ALIBABA_CLOUD_OIDC_PROVIDER_ARN environment variable. + 'oidcProviderArn' => '', + // Specify the path of the OIDC token file by specifying the ALIBABA_CLOUD_OIDC_TOKEN_FILE environment variable. + 'oidcTokenFilePath' => '', + // Specify the ARN of the RAM role by specifying the ALIBABA_CLOUD_ROLE_ARN environment variable. + 'roleArn' => '', + // Specify the role session name by specifying the ALIBABA_CLOUD_ROLE_SESSION_NAME environment variable. + 'roleSessionName' => '', + // Optional. Specify limited permissions for the RAM role. Example: {"Statement": [{"Action": ["*"],"Effect": "Allow","Resource": ["*"]}],"Version":"1"}. + 'policy' => '', + // Optional. Specify the validity period of the session. + 'roleSessionExpiration' => 3600, +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### Credentials URI + +By specifying the url, the credential will be able to automatically request maintenance of STS Token. + +```php + 'credentials_uri', + // Format: http url. `credentialsURI` can be replaced by setting environment variable: ALIBABA_CLOUD_CREDENTIALS_URI + 'credentialsURI' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getAccessKeyId(); +$credential->getAccessKeySecret(); +$credential->getSecurityToken(); +``` + +#### Bearer Token + +If credential is required by the Cloud Call Centre (CCC), please apply for Bearer Token maintenance by yourself. + +```php + 'bearer', + 'bearerToken' => '', +]); +$client = new Credential($config); + +$credential = $client->getCredential(); +$credential->getBearerToken(); +``` + +## Default credential provider chain + +If you want to use different types of credentials in the development and production environments of your application, you generally need to obtain the environment information from the code and write code branches to obtain different credentials for the development and production environments. The default credential provider chain of the Credentials tool allows you to use the same code to obtain credentials for different environments based on configurations independent of the application. If you use $credential = new Credential(); to initialize a Credentials client without specifying an initialization method, the Credentials tool obtains the credential information in the following order: + +### 1. Environmental certificate + +Look for environment credentials in environment variable. +- If the `ALIBABA_CLOUD_ACCESS_KEY_ID` and `ALIBABA_CLOUD_ACCESS_KEY_SECRET` environment variables are defined and are not empty, the program will use them to create default credentials. +- If the `ALIBABA_CLOUD_ACCESS_KEY_ID`, `ALIBABA_CLOUD_ACCESS_KEY_SECRET` and `ALIBABA_CLOUD_SECURITY_TOKEN` environment variables are defined and are not empty, the program will use them to create temporary security credentials(STS). Note: This token has an expiration time, it is recommended to use it in a temporary environment. + +### 2. The RAM role of an OIDC IdP + +If no credentials are found in the previous step, the Credentials tool obtains the values of the following environment variables: + +`ALIBABA_CLOUD_ROLE_ARN`: the ARN of the RAM role. + +`ALIBABA_CLOUD_OIDC_PROVIDER_ARN`: the ARN of the OIDC IdP. + +`ALIBABA_CLOUD_OIDC_TOKEN_FILE`: the path of the OIDC token file. + +If the preceding three environment variables are specified, the Credentials tool uses the environment variables to call the [AssumeRoleWithOIDC](https://www.alibabacloud.com/help/en/ram/developer-reference/api-sts-2015-04-01-assumerolewithoidc) operation of STS to obtain an STS token as the default credential. + +### 3. Using the config.json Configuration File of Aliyun CLI Tool +If there is no higher-priority credential information, the Credentials tool will first check the following locations to see if the config.json file exists: + +Linux system: `~/.aliyun/config.json` +Windows system: `C:\Users\USER_NAME\.aliyun\config.json` +If the file exists, the program will use the credential information specified by `current` in the configuration file to initialize the credentials client. Of course, you can also use the environment variable `ALIBABA_CLOUD_PROFILE` to specify the credential information, for example by setting the value of `ALIBABA_CLOUD_PROFILE` to `AK`. + +In the config.json configuration file, the value of each module represents different ways to obtain credential information: + +- AK: Use the Access Key of the user as credential information; +- RamRoleArn: Use the ARN of the RAM role to obtain credential information; +- EcsRamRole: Use the RAM role bound to the ECS to obtain credential information; +- OIDC: Obtain credential information through OIDC ARN and OIDC Token; +- ChainableRamRoleArn: Use the role chaining method to obtain new credential information by specifying other credentials in the JSON file. + +The configuration example information is as follows: + +```json +{ + "current": "AK", + "profiles": [ + { + "name": "AK", + "mode": "AK", + "access_key_id": "access_key_id", + "access_key_secret": "access_key_secret" + }, + { + "name": "RamRoleArn", + "mode": "RamRoleArn", + "access_key_id": "access_key_id", + "access_key_secret": "access_key_secret", + "ram_role_arn": "ram_role_arn", + "ram_session_name": "ram_session_name", + "expired_seconds": 3600, + "sts_region": "cn-hangzhou" + }, + { + "name": "EcsRamRole", + "mode": "EcsRamRole", + "ram_role_name": "ram_role_name" + }, + { + "name": "OIDC", + "mode": "OIDC", + "ram_role_arn": "ram_role_arn", + "oidc_token_file": "path/to/oidc/file", + "oidc_provider_arn": "oidc_provider_arn", + "ram_session_name": "ram_session_name", + "expired_seconds": 3600, + "sts_region": "cn-hangzhou" + }, + { + "name": "ChainableRamRoleArn", + "mode": "ChainableRamRoleArn", + "source_profile": "AK", + "ram_role_arn": "ram_role_arn", + "ram_session_name": "ram_session_name", + "expired_seconds": 3600, + "sts_region": "cn-hangzhou" + } + ] +} +``` + +### 4. Configuration file +> +> If the user's home directory has the default file `~/.alibabacloud/credentials` (Windows is `C:\Users\USER_NAME\.alibabacloud\credentials`), the program will automatically create credentials with the specified type and name. You can also specify the configuration file path by configuring the `ALIBABA_CLOUD_CREDENTIALS_FILE` environment variable. If the configuration file exists, the application initializes a Credentials client by using the credential information that is specified by default in the configuration file. You can also configure the `ALIBABA_CLOUD_PROFILE` environment variable to modify the default credential information that is read. + +Configuration example: +```ini +[default] +type = access_key # Authentication method is access_key +access_key_id = foo # Key +access_key_secret = bar # Secret + +[project1] +type = ecs_ram_role # Authentication method is ecs_ram_role +role_name = EcsRamRoleTest # Role name, optional. It will be retrieved automatically if not set. It is highly recommended to set it up to reduce requests. + +[project2] +type = ram_role_arn # Authentication method is ram_role_arn +access_key_id = foo +access_key_secret = bar +role_arn = role_arn +role_session_name = session_name + +[project3] +type=oidc_role_arn # Authentication method is oidc_role_arn +oidc_provider_arn=oidc_provider_arn +oidc_token_file_path=oidc_token_file_path +role_arn=role_arn +role_session_name=session_name +``` + +### 5. Instance RAM role + +If there is no credential information with a higher priority, the Credentials tool will obtain the value of ALIBABA_CLOUD_ECS_METADATA (ECS instance RAM role name) through the environment variable. If the value of this variable exists, the program will use the hardened mode (IMDSv2) to access the metadata service (Meta Data Server) of ECS to obtain the STS Token of the ECS instance RAM role as the default credential information. If an exception occurs when using the hardened mode, the normal mode will be used as a fallback to obtain access credentials. You can also set the environment variable ALIBABA_CLOUD_IMDSV1_DISABLED to perform different exception handling logic: + +- When the value is false, the normal mode will continue to obtain access credentials. + +- When the value is true, it means that only the hardened mode can be used to obtain access credentials, and an exception will be thrown. + +Whether the server supports IMDSv2 depends on your configuration on the server. + +### 6. Using External Service Credentials URI + +If there are no higher-priority credential information, the Credentials tool will obtain the `ALIBABA_CLOUD_CREDENTIALS_URI` from the environment variables. If it exists, the program will request the URI address to obtain temporary security credentials as the default credential information. + +The external service response structure should be as follows: + +```json +{ + "Code": "Success", + "AccessKeyId": "AccessKeyId", + "AccessKeySecret": "AccessKeySecret", + "SecurityToken": "SecurityToken", + "Expiration": "2024-10-26T03:46:38Z" +} +``` + +## Documentation + +* [Prerequisites](/docs/zh-CN/0-Prerequisites.md) +* [Installation](/docs/zh-CN/1-Installation.md) + +## Issue + +[Submit Issue](https://github.com/aliyun/credentials-php/issues/new/choose), Problems that do not meet the guidelines may close immediately. + +## Release notes + +Detailed changes for each version are recorded in the [Release Notes](/CHANGELOG.md). + +## Contribution + +Please read the [Contribution Guide](/CONTRIBUTING.md) before submitting a Pull Request. + +## Related + +* [OpenAPI Developer Portal][open-api] +* [Packagist][packagist] +* [Composer][composer] +* [Guzzle Doc][guzzle-docs] +* [Latest Release][latest-release] + +## License + +[Apache-2.0](/LICENSE.md) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + +[open-api]: https://api.alibabacloud.com +[latest-release]: https://github.com/aliyun/credentials-php +[guzzle-docs]: http://docs.guzzlephp.org/en/stable/request-options.html +[composer]: https://getcomposer.org +[packagist]: https://packagist.org/packages/alibabacloud/credentials diff --git a/vendor/alibabacloud/credentials/SECURITY.md b/vendor/alibabacloud/credentials/SECURITY.md new file mode 100644 index 0000000..034e848 --- /dev/null +++ b/vendor/alibabacloud/credentials/SECURITY.md @@ -0,0 +1,21 @@ +# Security Policy + +## Supported Versions + +Use this section to tell people about which versions of your project are +currently being supported with security updates. + +| Version | Supported | +| ------- | ------------------ | +| 5.1.x | :white_check_mark: | +| 5.0.x | :x: | +| 4.0.x | :white_check_mark: | +| < 4.0 | :x: | + +## Reporting a Vulnerability + +Use this section to tell people how to report a vulnerability. + +Tell them where to go, how often they can expect to get an update on a +reported vulnerability, what to expect if the vulnerability is accepted or +declined, etc. diff --git a/vendor/alibabacloud/credentials/UPGRADING.md b/vendor/alibabacloud/credentials/UPGRADING.md new file mode 100644 index 0000000..f084ed6 --- /dev/null +++ b/vendor/alibabacloud/credentials/UPGRADING.md @@ -0,0 +1,6 @@ +Upgrading Guide +=============== + +1.x +----------------------- +- This is the first version. See for more information. diff --git a/vendor/alibabacloud/credentials/composer.json b/vendor/alibabacloud/credentials/composer.json new file mode 100644 index 0000000..81f9745 --- /dev/null +++ b/vendor/alibabacloud/credentials/composer.json @@ -0,0 +1,107 @@ +{ + "name": "alibabacloud/credentials", + "homepage": "https://www.alibabacloud.com/", + "description": "Alibaba Cloud Credentials for PHP", + "keywords": [ + "sdk", + "tool", + "cloud", + "client", + "aliyun", + "library", + "alibaba", + "Credentials", + "alibabacloud" + ], + "type": "library", + "license": "Apache-2.0", + "support": { + "source": "https://github.com/aliyun/credentials-php", + "issues": "https://github.com/aliyun/credentials-php/issues" + }, + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com", + "homepage": "http://www.alibabacloud.com" + } + ], + "require": { + "php": ">=5.6", + "ext-curl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-openssl": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", + "ext-xmlwriter": "*", + "guzzlehttp/guzzle": "^6.3|^7.0", + "adbario/php-dot-notation": "^2.2", + "alibabacloud/tea": "^3.0" + }, + "require-dev": { + "ext-spl": "*", + "ext-dom": "*", + "ext-pcre": "*", + "psr/cache": "^1.0", + "ext-sockets": "*", + "drupal/coder": "^8.3", + "symfony/dotenv": "^3.4", + "phpunit/phpunit": "^5.7|^6.6|^9.3", + "monolog/monolog": "^1.24", + "composer/composer": "^1.8", + "mikey179/vfsstream": "^1.6", + "symfony/var-dumper": "^3.4" + }, + "suggest": { + "ext-sockets": "To use client-side monitoring" + }, + "autoload": { + "psr-4": { + "AlibabaCloud\\Credentials\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "AlibabaCloud\\Credentials\\Tests\\": "tests/" + } + }, + "config": { + "preferred-install": "dist", + "optimize-autoloader": true, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + }, + "minimum-stability": "dev", + "prefer-stable": true, + "scripts-descriptions": { + "cs": "Tokenizes PHP, JavaScript and CSS files to detect violations of a defined coding standard.", + "cbf": "Automatically correct coding standard violations.", + "fixer": "Fixes code to follow standards.", + "test": "Run all tests.", + "unit": "Run Unit tests.", + "feature": "Run Feature tests.", + "clearCache": "Clear cache like coverage.", + "coverage": "Show Coverage html.", + "endpoints": "Update endpoints from OSS." + }, + "scripts": { + "cs": "phpcs --standard=PSR2 -n ./", + "cbf": "phpcbf --standard=PSR2 -n ./", + "fixer": "php-cs-fixer fix ./", + "test": [ + "phpunit --colors=always" + ], + "unit": [ + "@clearCache", + "phpunit --testsuite=Unit --colors=always" + ], + "feature": [ + "@clearCache", + "phpunit --testsuite=Feature --colors=always" + ], + "coverage": "open cache/coverage/index.html", + "clearCache": "rm -rf cache/*" + } +} diff --git a/vendor/alibabacloud/credentials/src/AccessKeyCredential.php b/vendor/alibabacloud/credentials/src/AccessKeyCredential.php new file mode 100644 index 0000000..05a0132 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/AccessKeyCredential.php @@ -0,0 +1,86 @@ +accessKeyId = $access_key_id; + $this->accessKeySecret = $access_key_secret; + } + + /** + * @return string + */ + public function getAccessKeyId() + { + return $this->accessKeyId; + } + + /** + * @return string + */ + public function getAccessKeySecret() + { + return $this->accessKeySecret; + } + + /** + * @return string + */ + public function __toString() + { + return "$this->accessKeyId#$this->accessKeySecret"; + } + + /** + * @return ShaHmac1Signature + */ + public function getSignature() + { + return new ShaHmac1Signature(); + } + + public function getSecurityToken() + { + return ''; + } + /** + * @inheritDoc + */ + public function getCredential() + { + return new CredentialModel([ + 'accessKeyId' => $this->accessKeyId, + 'accessKeySecret' => $this->accessKeySecret, + 'type' => 'access_key', + ]); + } +} diff --git a/vendor/alibabacloud/credentials/src/BearerTokenCredential.php b/vendor/alibabacloud/credentials/src/BearerTokenCredential.php new file mode 100644 index 0000000..34fab6f --- /dev/null +++ b/vendor/alibabacloud/credentials/src/BearerTokenCredential.php @@ -0,0 +1,67 @@ +bearerToken = $bearer_token; + } + + /** + * @return string + */ + public function getBearerToken() + { + return $this->bearerToken; + } + + /** + * @return string + */ + public function __toString() + { + return "bearerToken#$this->bearerToken"; + } + + /** + * @return BearerTokenSignature + */ + public function getSignature() + { + return new BearerTokenSignature(); + } + + /** + * @inheritDoc + */ + public function getCredential() + { + return new CredentialModel([ + 'bearerToken' => $this->bearerToken, + 'type' => 'bearer', + ]); + } + +} diff --git a/vendor/alibabacloud/credentials/src/Credential.php b/vendor/alibabacloud/credentials/src/Credential.php new file mode 100644 index 0000000..fb89018 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Credential.php @@ -0,0 +1,268 @@ +config = null; + } else { + $this->config = new Config($this->parseConfig($config)); + } + } else { + $this->config = $config; + } + $this->credential = $this->getCredentials($this->config); + } + + /** + * @param array $config + * + * @return array + */ + private function parseConfig($config) + { + $res = []; + foreach (\array_change_key_case($config) as $key => $value) { + $res[Helper::snakeToCamelCase($key)] = $value; + } + return $res; + } + + + + /** + * Credentials getter. + * + * @param Config $config + * @return CredentialsInterface + * + */ + private function getCredentials($config) + { + if (is_null($config)) { + return new CredentialsProviderWrap('default', new DefaultCredentialsProvider()); + } + switch ($config->type) { + case 'access_key': + $provider = new StaticAKCredentialsProvider([ + 'accessKeyId' => $config->accessKeyId, + 'accessKeySecret' => $config->accessKeySecret, + ]); + return new CredentialsProviderWrap('access_key', $provider); + case 'sts': + $provider = new StaticSTSCredentialsProvider([ + 'accessKeyId' => $config->accessKeyId, + 'accessKeySecret' => $config->accessKeySecret, + 'securityToken' => $config->securityToken, + ]); + return new CredentialsProviderWrap('sts', $provider); + case 'bearer': + return new BearerTokenCredential($config->bearerToken); + case 'ram_role_arn': + if (!is_null($config->securityToken) && $config->securityToken !== '') { + $innerProvider = new StaticSTSCredentialsProvider([ + 'accessKeyId' => $config->accessKeyId, + 'accessKeySecret' => $config->accessKeySecret, + 'securityToken' => $config->securityToken, + ]); + } else { + $innerProvider = new StaticAKCredentialsProvider([ + 'accessKeyId' => $config->accessKeyId, + 'accessKeySecret' => $config->accessKeySecret, + ]); + } + $provider = new RamRoleArnCredentialsProvider([ + 'credentialsProvider' => $innerProvider, + 'roleArn' => $config->roleArn, + 'roleSessionName' => $config->roleSessionName, + 'policy' => $config->policy, + 'durationSeconds' => $config->roleSessionExpiration, + 'externalId' => $config->externalId, + 'stsEndpoint' => $config->STSEndpoint, + ], [ + 'connectTimeout' => $config->connectTimeout, + 'readTimeout' => $config->readTimeout, + ]); + return new CredentialsProviderWrap('ram_role_arn', $provider); + case 'rsa_key_pair': + $provider = new RsaKeyPairCredentialsProvider([ + 'publicKeyId' => $config->publicKeyId, + 'privateKeyFile' => $config->privateKeyFile, + 'durationSeconds' => $config->roleSessionExpiration, + 'stsEndpoint' => $config->STSEndpoint, + ], [ + 'connectTimeout' => $config->connectTimeout, + 'readTimeout' => $config->readTimeout, + ]); + return new CredentialsProviderWrap('rsa_key_pair', $provider); + case 'ecs_ram_role': + $provider = new EcsRamRoleCredentialsProvider([ + 'roleName' => $config->roleName, + 'disableIMDSv1' => $config->disableIMDSv1, + ], [ + 'connectTimeout' => $config->connectTimeout, + 'readTimeout' => $config->readTimeout, + ]); + return new CredentialsProviderWrap('ecs_ram_role', $provider); + case 'oidc_role_arn': + $provider = new OIDCRoleArnCredentialsProvider([ + 'roleArn' => $config->roleArn, + 'oidcProviderArn' => $config->oidcProviderArn, + 'oidcTokenFilePath' => $config->oidcTokenFilePath, + 'roleSessionName' => $config->roleSessionName, + 'policy' => $config->policy, + 'durationSeconds' => $config->roleSessionExpiration, + 'stsEndpoint' => $config->STSEndpoint, + ], [ + 'connectTimeout' => $config->connectTimeout, + 'readTimeout' => $config->readTimeout, + ]); + return new CredentialsProviderWrap('oidc_role_arn', $provider); + case "credentials_uri": + $provider = new URLCredentialsProvider([ + 'credentialsURI' => $config->credentialsURI, + ], [ + 'connectTimeout' => $config->connectTimeout, + 'readTimeout' => $config->readTimeout, + ]); + return new CredentialsProviderWrap('credentials_uri', $provider); + default: + throw new InvalidArgumentException('Unsupported credential type option: ' . $config->type . ', support: access_key, sts, bearer, ecs_ram_role, ram_role_arn, rsa_key_pair, oidc_role_arn, credentials_uri'); + } + } + + /** + * @return CredentialModel + * @throws RuntimeException + * @throws GuzzleException + */ + public function getCredential() + { + return $this->credential->getCredential(); + } + + /** + * @return array + */ + public function getConfig() + { + return $this->config->toMap(); + } + + /** + * @deprecated use getCredential() instead + * + * @return string + * @throws RuntimeException + * @throws GuzzleException + */ + public function getType() + { + return $this->credential->getCredential()->getType(); + } + + /** + * @deprecated use getCredential() instead + * + * @return string + * @throws RuntimeException + * @throws GuzzleException + */ + public function getAccessKeyId() + { + return $this->credential->getCredential()->getAccessKeyId(); + } + + /** + * @deprecated use getCredential() instead + * + * @return string + * @throws RuntimeException + * @throws GuzzleException + */ + public function getAccessKeySecret() + { + return $this->credential->getCredential()->getAccessKeySecret(); + } + + /** + * @deprecated use getCredential() instead + * + * @return string + * @throws RuntimeException + * @throws GuzzleException + */ + public function getSecurityToken() + { + return $this->credential->getCredential()->getSecurityToken(); + } + + /** + * @deprecated use getCredential() instead + * + * @return string + * @throws RuntimeException + * @throws GuzzleException + */ + public function getBearerToken() + { + return $this->credential->getCredential()->getBearerToken(); + } + + /** + * @param string $name + * @param array $arguments + * + * @return mixed + */ + public function __call($name, $arguments) + { + return $this->credential->$name($arguments); + } +} diff --git a/vendor/alibabacloud/credentials/src/Credential/Config.php b/vendor/alibabacloud/credentials/src/Credential/Config.php new file mode 100644 index 0000000..1fb57e3 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Credential/Config.php @@ -0,0 +1,270 @@ +accessKeyId) { + $res['accessKeyId'] = $this->accessKeyId; + } + if (null !== $this->accessKeySecret) { + $res['accessKeySecret'] = $this->accessKeySecret; + } + if (null !== $this->securityToken) { + $res['securityToken'] = $this->securityToken; + } + if (null !== $this->bearerToken) { + $res['bearerToken'] = $this->bearerToken; + } + if (null !== $this->durationSeconds) { + $res['durationSeconds'] = $this->durationSeconds; + } + if (null !== $this->roleArn) { + $res['roleArn'] = $this->roleArn; + } + if (null !== $this->policy) { + $res['policy'] = $this->policy; + } + if (null !== $this->roleSessionExpiration) { + $res['roleSessionExpiration'] = $this->roleSessionExpiration; + } + if (null !== $this->roleSessionName) { + $res['roleSessionName'] = $this->roleSessionName; + } + if (null !== $this->publicKeyId) { + $res['publicKeyId'] = $this->publicKeyId; + } + if (null !== $this->privateKeyFile) { + $res['privateKeyFile'] = $this->privateKeyFile; + } + if (null !== $this->roleName) { + $res['roleName'] = $this->roleName; + } + if (null !== $this->credentialsURI) { + $res['credentialsURI'] = $this->credentialsURI; + } + if (null !== $this->type) { + $res['type'] = $this->type; + } + if (null !== $this->STSEndpoint) { + $res['STSEndpoint'] = $this->STSEndpoint; + } + if (null !== $this->externalId) { + $res['externalId'] = $this->externalId; + } + return $res; + } + /** + * @param array $map + * @return Config + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['accessKeyId'])) { + $model->accessKeyId = $map['accessKeyId']; + } + if (isset($map['accessKeySecret'])) { + $model->accessKeySecret = $map['accessKeySecret']; + } + if (isset($map['securityToken'])) { + $model->securityToken = $map['securityToken']; + } + if (isset($map['bearerToken'])) { + $model->bearerToken = $map['bearerToken']; + } + if (isset($map['durationSeconds'])) { + $model->durationSeconds = $map['durationSeconds']; + } + if (isset($map['roleArn'])) { + $model->roleArn = $map['roleArn']; + } + if (isset($map['policy'])) { + $model->policy = $map['policy']; + } + if (isset($map['roleSessionExpiration'])) { + $model->roleSessionExpiration = $map['roleSessionExpiration']; + } + if (isset($map['roleSessionName'])) { + $model->roleSessionName = $map['roleSessionName']; + } + if (isset($map['publicKeyId'])) { + $model->publicKeyId = $map['publicKeyId']; + } + if (isset($map['privateKeyFile'])) { + $model->privateKeyFile = $map['privateKeyFile']; + } + if (isset($map['roleName'])) { + $model->roleName = $map['roleName']; + } + if (isset($map['credentialsURI'])) { + $model->credentialsURI = $map['credentialsURI']; + } + if (isset($map['type'])) { + $model->type = $map['type']; + } + if (isset($map['STSEndpoint'])) { + $model->STSEndpoint = $map['STSEndpoint']; + } + if (isset($map['externalId'])) { + $model->externalId = $map['externalId']; + } + return $model; + } + /** + * @description credential type + * @example access_key + * @var string + */ + public $type = 'default'; + + /** + * @description accesskey id + * @var string + */ + public $accessKeyId; + + /** + * @description accesskey secret + * @var string + */ + public $accessKeySecret; + + /** + * @description security token + * @var string + */ + public $securityToken; + + /** + * @description bearer token + * @var string + */ + public $bearerToken; + + /** + * @description role name + * @var string + */ + public $roleName; + + /** + * @description role arn + * @var string + */ + public $roleArn; + + /** + * @description oidc provider arn + * @var string + */ + public $oidcProviderArn; + + /** + * @description oidc token file path + * @var string + */ + public $oidcTokenFilePath; + + /** + * @description role session expiration + * @example 3600 + * @var int + */ + public $roleSessionExpiration; + + /** + * @description role session name + * @var string + */ + public $roleSessionName; + + /** + * @description role arn policy + * @var string + */ + public $policy; + + /** + * @description external id for ram role arn + * @var string + */ + public $externalId; + + /** + * @description sts endpoint + * @var string + */ + public $STSEndpoint; + + public $publicKeyId; + + public $privateKeyFile; + + /** + * @description read timeout + * @var int + */ + public $readTimeout; + + /** + * @description connection timeout + * @var int + */ + public $connectTimeout; + + /** + * @description disable IMDS v1 + * @var bool + */ + public $disableIMDSv1; + + /** + * @description credentials URI + * @var string + */ + public $credentialsURI; + + /** + * @deprecated + */ + public $metadataTokenDuration; + + /** + * @deprecated + */ + public $durationSeconds; + + /** + * @deprecated + */ + public $host; + + /** + * @deprecated + */ + public $expiration; + + /** + * @deprecated + */ + public $certFile = ""; + + /** + * @deprecated + */ + public $certPassword = ""; + + /** + * @internal + */ + public $proxy; +} diff --git a/vendor/alibabacloud/credentials/src/Credential/CredentialModel.php b/vendor/alibabacloud/credentials/src/Credential/CredentialModel.php new file mode 100644 index 0000000..8d516d9 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Credential/CredentialModel.php @@ -0,0 +1,143 @@ +accessKeyId) { + $res['accessKeyId'] = $this->accessKeyId; + } + if (null !== $this->accessKeySecret) { + $res['accessKeySecret'] = $this->accessKeySecret; + } + if (null !== $this->securityToken) { + $res['securityToken'] = $this->securityToken; + } + if (null !== $this->bearerToken) { + $res['bearerToken'] = $this->bearerToken; + } + if (null !== $this->type) { + $res['type'] = $this->type; + } + if (null !== $this->providerName) { + $res['providerName'] = $this->providerName; + } + return $res; + } + /** + * @param array $map + * @return CredentialModel + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['accessKeyId'])) { + $model->accessKeyId = $map['accessKeyId']; + } + if (isset($map['accessKeySecret'])) { + $model->accessKeySecret = $map['accessKeySecret']; + } + if (isset($map['securityToken'])) { + $model->securityToken = $map['securityToken']; + } + if (isset($map['bearerToken'])) { + $model->bearerToken = $map['bearerToken']; + } + if (isset($map['type'])) { + $model->type = $map['type']; + } + if(isset($map['providerName'])){ + $model->providerName = $map['providerName']; + } + return $model; + } + /** + * @description accesskey id + * @var string + */ + public $accessKeyId; + + /** + * @description accesskey secret + * @var string + */ + public $accessKeySecret; + + /** + * @description security token + * @var string + */ + public $securityToken; + + /** + * @description bearer token + * @var string + */ + public $bearerToken; + + /** + * @description type + * @example access_key + * @var string + */ + public $type; + + /** + * @description provider name + * @example cli_profile/static_ak + * @var string + */ + public $providerName; + + /** + * @return string + */ + public function getAccessKeyId() + { + return $this->accessKeyId; + } + + /** + * @return string + */ + public function getAccessKeySecret() + { + return $this->accessKeySecret; + } + + /** + * @return string + */ + public function getSecurityToken() + { + return $this->securityToken; + } + + /** + * @return string + */ + public function getBearerToken() + { + return $this->bearerToken; + } + + public function getType() + { + return $this->type; + } + + public function getProviderName() + { + return $this->providerName; + } + +} diff --git a/vendor/alibabacloud/credentials/src/Credential/RefreshResult.php b/vendor/alibabacloud/credentials/src/Credential/RefreshResult.php new file mode 100644 index 0000000..af1c202 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Credential/RefreshResult.php @@ -0,0 +1,97 @@ +credentials = $credentials; + $this->staleTime = $staleTime; + $this->prefetchTime = $prefetchTime; + } + public function validate() {} + public function toMap() + { + $res = []; + if (null !== $this->staleTime) { + $res['staleTime'] = $this->staleTime; + } + if (null !== $this->prefetchTime) { + $res['prefetchTime'] = $this->prefetchTime; + } + if (null !== $this->credentials) { + $res['credentials'] = $this->credentials; + } + return $res; + } + /** + * @param array $map + * @return RefreshResult + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['staleTime'])) { + $model->staleTime = $map['staleTime']; + } + if (isset($map['prefetchTime'])) { + $model->staleTime = $map['prefetchTime']; + } + if (isset($map['credentials'])) { + $model->staleTime = $map['credentials']; + } + return $model; + } + /** + * @description staleTime + * @var int + */ + public $staleTime; + + /** + * @description prefetchTime + * @var int + */ + public $prefetchTime; + + /** + * @description credentials + * @var Credentials + */ + public $credentials; + + + /** + * @return Credentials + */ + public function credentials() + { + return $this->credentials; + } + + /** + * @var int + */ + public function staleTime() + { + return $this->staleTime; + } + + /** + * @var int + */ + public function prefetchTime() + { + return $this->prefetchTime; + } +} diff --git a/vendor/alibabacloud/credentials/src/Credentials.php b/vendor/alibabacloud/credentials/src/Credentials.php new file mode 100644 index 0000000..f064b86 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Credentials.php @@ -0,0 +1,104 @@ +typeName = $typeName; + $this->credentialsProvider = $credentialsProvider; + } + + /** + * @inheritDoc + */ + public function getCredential() + { + $credentials = $this->credentialsProvider->getCredentials(); + return new CredentialModel([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'type' => $this->typeName, + 'providerName' => $credentials->getProviderName(), + ]); + } + + /** + * @param string $name + * @param array $arguments + * + * @return mixed + */ + public function __call($name, $arguments) + { + return $this->credentialsProvider->$name($arguments); + } + + public function __toString() + { + return "credentialsProviderWrap#$this->typeName"; + } + + /** + * @return ShaHmac1Signature + */ + public function getSignature() + { + return null; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/credentials/src/EcsRamRoleCredential.php b/vendor/alibabacloud/credentials/src/EcsRamRoleCredential.php new file mode 100644 index 0000000..ba66c0d --- /dev/null +++ b/vendor/alibabacloud/credentials/src/EcsRamRoleCredential.php @@ -0,0 +1,199 @@ +roleName = $role_name; + + Filter::disableIMDSv1($disable_imdsv1); + + $this->disableIMDSv1 = $disable_imdsv1; + + $this->metadataTokenDuration = $metadata_token_duration; + } + + /** + * @return string + * @throws GuzzleException + * @throws Exception + */ + public function getRoleName() + { + if ($this->roleName !== null) { + return $this->roleName; + } + + $this->roleName = $this->getRoleNameFromMeta(); + + return $this->roleName; + } + + /** + * @return string + * @throws Exception + */ + public function getRoleNameFromMeta() + { + $options = [ + 'http_errors' => false, + 'timeout' => 1, + 'connect_timeout' => 1, + ]; + + $result = Request::createClient()->request( + 'GET', + 'http://100.100.100.200/latest/meta-data/ram/security-credentials/', + $options + ); + + if ($result->getStatusCode() === 404) { + throw new InvalidArgumentException('The role name was not found in the instance'); + } + + if ($result->getStatusCode() !== 200) { + throw new RuntimeException('Error retrieving credentials from result: ' . $result->getBody()); + } + + $role_name = (string) $result; + if (!$role_name) { + throw new RuntimeException('Error retrieving credentials from result is empty'); + } + + return $role_name; + } + + /** + * @return string + */ + public function __toString() + { + return "roleName#$this->roleName"; + } + + /** + * @return ShaHmac1Signature + */ + public function getSignature() + { + return new ShaHmac1Signature(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getAccessKeyId() + { + return $this->getSessionCredential()->getAccessKeyId(); + } + + /** + * @return AlibabaCloud\Credentials\Providers\Credentials + * @throws Exception + * @throws GuzzleException + */ + protected function getSessionCredential() + { + $params = [ + "roleName" => $this->roleName, + 'disableIMDSv1' => $this->disableIMDSv1, + 'metadataTokenDuration' => $this->metadataTokenDuration, + ]; + return (new EcsRamRoleCredentialsProvider($params))->getCredentials(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getAccessKeySecret() + { + return $this->getSessionCredential()->getAccessKeySecret(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getSecurityToken() + { + return $this->getSessionCredential()->getSecurityToken(); + } + + /** + * @return int + * @throws Exception + * @throws GuzzleException + */ + public function getExpiration() + { + return $this->getSessionCredential()->getExpiration(); + } + + /** + * @return bool + */ + public function isDisableIMDSv1() + { + return $this->disableIMDSv1; + } + + /** + * @inheritDoc + */ + public function getCredential() + { + $credentials = $this->getSessionCredential(); + return new CredentialModel([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'type' => 'ecs_ram_role', + ]); + } + +} diff --git a/vendor/alibabacloud/credentials/src/Providers/CLIProfileCredentialsProvider.php b/vendor/alibabacloud/credentials/src/Providers/CLIProfileCredentialsProvider.php new file mode 100644 index 0000000..1d73396 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Providers/CLIProfileCredentialsProvider.php @@ -0,0 +1,193 @@ +filterProfileName($params); + } + + private function filterProfileName(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_PROFILE')) { + $this->profileName = Helper::env('ALIBABA_CLOUD_PROFILE'); + } + + if (isset($params['profileName'])) { + $this->profileName = $params['profileName']; + } + } + + /** + * @return bool + */ + private function shouldReloadCredentialsProvider() + { + if (is_null($this->credentialsProvider)) { + return true; + } + + return false; + } + + /** + * @return CredentialsProvider + */ + protected function reloadCredentialsProvider($profileFile, $profileName) + { + if (!Helper::inOpenBasedir($profileFile)) { + throw new RuntimeException('Unable to open credentials file: ' . $profileFile); + } + + if (!\is_readable($profileFile) || !\is_file($profileFile)) { + throw new RuntimeException('Credentials file is not readable: ' . $profileFile); + } + + $jsonContent = \file_get_contents($profileFile); + $fileArray = json_decode($jsonContent, true); + + if (\is_array($fileArray) && !empty($fileArray)) { + if (is_null($profileName) || $profileName === '') { + $profileName = $fileArray['current']; + } + if (isset($fileArray['profiles'])) { + foreach ($fileArray['profiles'] as $profile) { + if (Helper::unsetReturnNull($profile, 'name') === $profileName) { + switch (Helper::unsetReturnNull($profile, 'mode')) { + case 'AK': + return new StaticAKCredentialsProvider([ + 'accessKeyId' => Helper::unsetReturnNull($profile, 'access_key_id'), + 'accessKeySecret' => Helper::unsetReturnNull($profile, 'access_key_secret'), + ]); + case 'StsToken': + return new StaticSTSCredentialsProvider([ + 'accessKeyId' => Helper::unsetReturnNull($profile, 'access_key_id'), + 'accessKeySecret' => Helper::unsetReturnNull($profile, 'access_key_secret'), + 'securityToken' => Helper::unsetReturnNull($profile, 'sts_token'), + ]); + case 'RamRoleArn': + $innerProvider = new StaticAKCredentialsProvider([ + 'accessKeyId' => Helper::unsetReturnNull($profile, 'access_key_id'), + 'accessKeySecret' => Helper::unsetReturnNull($profile, 'access_key_secret'), + ]); + return new RamRoleArnCredentialsProvider([ + 'credentialsProvider' => $innerProvider, + 'roleArn' => Helper::unsetReturnNull($profile, 'ram_role_arn'), + 'roleSessionName' => Helper::unsetReturnNull($profile, 'ram_session_name'), + 'durationSeconds' => Helper::unsetReturnNull($profile, 'expired_seconds'), + 'policy' => Helper::unsetReturnNull($profile, 'policy'), + 'externalId' => Helper::unsetReturnNull($profile, 'external_id'), + 'stsRegionId' => Helper::unsetReturnNull($profile, 'sts_region'), + 'enableVpc' => Helper::unsetReturnNull($profile, 'enable_vpc'), + ]); + case 'EcsRamRole': + return new EcsRamRoleCredentialsProvider([ + 'roleName' => Helper::unsetReturnNull($profile, 'ram_role_name'), + ]); + case 'OIDC': + return new OIDCRoleArnCredentialsProvider([ + 'roleArn' => Helper::unsetReturnNull($profile, 'ram_role_arn'), + 'oidcProviderArn' => Helper::unsetReturnNull($profile, 'oidc_provider_arn'), + 'oidcTokenFilePath' => Helper::unsetReturnNull($profile, 'oidc_token_file'), + 'roleSessionName' => Helper::unsetReturnNull($profile, 'ram_session_name'), + 'durationSeconds' => Helper::unsetReturnNull($profile, 'expired_seconds'), + 'policy' => Helper::unsetReturnNull($profile, 'policy'), + 'stsRegionId' => Helper::unsetReturnNull($profile, 'sts_region'), + 'enableVpc' => Helper::unsetReturnNull($profile, 'enable_vpc'), + ]); + case 'ChainableRamRoleArn': + $previousProvider = $this->reloadCredentialsProvider($profileFile, Helper::unsetReturnNull($profile, 'source_profile')); + return new RamRoleArnCredentialsProvider([ + 'credentialsProvider' => $previousProvider, + 'roleArn' => Helper::unsetReturnNull($profile, 'ram_role_arn'), + 'roleSessionName' => Helper::unsetReturnNull($profile, 'ram_session_name'), + 'durationSeconds' => Helper::unsetReturnNull($profile, 'expired_seconds'), + 'policy' => Helper::unsetReturnNull($profile, 'policy'), + 'externalId' => Helper::unsetReturnNull($profile, 'external_id'), + 'stsRegionId' => Helper::unsetReturnNull($profile, 'sts_region'), + 'enableVpc' => Helper::unsetReturnNull($profile, 'enable_vpc'), + ]); + default: + throw new RuntimeException('Unsupported credential mode from CLI credentials file: ' . Helper::unsetReturnNull($profile, 'mode')); + } + } + } + } + } + throw new RuntimeException('Failed to get credential from CLI credentials file: ' . $profileFile); + } + /** + * Get credential. + * + * @return Credentials + * @throws RuntimeException + */ + public function getCredentials() + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_CLI_PROFILE_DISABLED') && Helper::env('ALIBABA_CLOUD_CLI_PROFILE_DISABLED') === true) { + throw new RuntimeException('CLI credentials file is disabled'); + } + $cliProfileFile = self::getDefaultFile(); + if ($this->shouldReloadCredentialsProvider()) { + $this->credentialsProvider = $this->reloadCredentialsProvider($cliProfileFile, $this->profileName); + } + + $credentials = $this->credentialsProvider->getCredentials(); + return new Credentials([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'providerName' => $this->getProviderName() . '/' . $this->credentialsProvider->getProviderName(), + ]); + } + + /** + * Get the default credential file. + * + * @return string + */ + private function getDefaultFile() + { + return Helper::getHomeDirectory() . + DIRECTORY_SEPARATOR . + '.aliyun' . + DIRECTORY_SEPARATOR . + 'config.json'; + } + + /** + * @return string + */ + public function getProviderName() + { + return 'cli_profile'; + } +} diff --git a/vendor/alibabacloud/credentials/src/Providers/ChainProvider.php b/vendor/alibabacloud/credentials/src/Providers/ChainProvider.php new file mode 100644 index 0000000..d6c1540 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Providers/ChainProvider.php @@ -0,0 +1,188 @@ + 'access_key', + 'access_key_id' => $accessKeyId, + 'access_key_secret' => $accessKeySecret, + ] + ); + } + }; + } + + /** + * @return string + */ + public static function getDefaultName() + { + $name = Helper::envNotEmpty('ALIBABA_CLOUD_PROFILE'); + + if ($name) { + return $name; + } + + return 'default'; + } + + /** + * @return Closure + */ + public static function ini() + { + return static function () { + $filename = Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_FILE'); + if (!$filename) { + $filename = self::getDefaultFile(); + } + + if (!Helper::inOpenBasedir($filename)) { + return; + } + + if ($filename !== self::getDefaultFile() && (!\is_readable($filename) || !\is_file($filename))) { + throw new RuntimeException( + 'Credentials file is not readable: ' . $filename + ); + } + + $file_array = \parse_ini_file($filename, true); + + if (\is_array($file_array) && !empty($file_array)) { + foreach (\array_change_key_case($file_array) as $name => $configures) { + Credentials::set($name, $configures); + } + } + }; + } + + /** + * Get the default credential file. + * + * @return string + */ + public static function getDefaultFile() + { + return Helper::getHomeDirectory() . + DIRECTORY_SEPARATOR . + '.alibabacloud' . + DIRECTORY_SEPARATOR . + 'credentials'; + } + + /** + * @return Closure + */ + public static function instance() + { + return static function () { + $instance = Helper::envNotEmpty('ALIBABA_CLOUD_ECS_METADATA'); + if ($instance) { + Credentials::set( + self::getDefaultName(), + [ + 'type' => 'ecs_ram_role', + 'role_name' => $instance, + ] + ); + } + }; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/credentials/src/Providers/Credentials.php b/vendor/alibabacloud/credentials/src/Providers/Credentials.php new file mode 100644 index 0000000..bfd4fe3 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Providers/Credentials.php @@ -0,0 +1,87 @@ + $v) { + $this->{$k} = $v; + } + } + } + + /** + * @return string + */ + public function getAccessKeyId() + { + return $this->accessKeyId; + } + + /** + * @return string + */ + public function getAccessKeySecret() + { + return $this->accessKeySecret; + } + + /** + * @return string + */ + public function getSecurityToken() + { + return $this->securityToken; + } + + /** + * @return int + */ + public function getExpiration() + { + return $this->expiration; + } + + /** + * @return string + */ + public function getProviderName() + { + return $this->providerName; + } +} diff --git a/vendor/alibabacloud/credentials/src/Providers/CredentialsProvider.php b/vendor/alibabacloud/credentials/src/Providers/CredentialsProvider.php new file mode 100644 index 0000000..ddbd1a1 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Providers/CredentialsProvider.php @@ -0,0 +1,24 @@ +filterReuseLastProviderEnabled($params); + $this->createDefaultChain(); + Filter::reuseLastProviderEnabled($this->reuseLastProviderEnabled); + } + + private function filterReuseLastProviderEnabled(array $params) + { + $this->reuseLastProviderEnabled = true; + if (isset($params['reuseLastProviderEnabled'])) { + $this->reuseLastProviderEnabled = $params['reuseLastProviderEnabled']; + } + } + + private function createDefaultChain() + { + self::$defaultProviders = [ + new EnvironmentVariableCredentialsProvider(), + ]; + if ( + Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_ARN') + && Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_PROVIDER_ARN') + && Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_TOKEN_FILE') + ) { + array_push( + self::$defaultProviders, + new OIDCRoleArnCredentialsProvider() + ); + } + array_push( + self::$defaultProviders, + new CLIProfileCredentialsProvider() + ); + array_push( + self::$defaultProviders, + new ProfileCredentialsProvider() + ); + array_push( + self::$defaultProviders, + new EcsRamRoleCredentialsProvider() + ); + if (Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_URI')) { + array_push( + self::$defaultProviders, + new URLCredentialsProvider() + ); + } + } + + /** + * @param CredentialsProvider ...$providers + */ + public static function set(...$providers) + { + if (empty($providers)) { + throw new InvalidArgumentException('No providers in chain'); + } + + foreach ($providers as $provider) { + if (!$provider instanceof CredentialsProvider) { + throw new InvalidArgumentException('Providers must all be CredentialsProvider'); + } + } + + self::$customChain = $providers; + } + + /** + * @return bool + */ + public static function hasCustomChain() + { + return (bool) self::$customChain; + } + + public static function flush() + { + self::$customChain = []; + } + + /** + * Get credential. + * + * @return Credentials + * @throws RuntimeException + */ + public function getCredentials() + { + if ($this->reuseLastProviderEnabled && !is_null($this->lastUsedCredentialsProvider)) { + $credentials = $this->lastUsedCredentialsProvider->getCredentials(); + return new Credentials([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'providerName' => $this->getProviderName() . '/' . $this->lastUsedCredentialsProvider->getProviderName(), + ]); + } + + $providerChain = array_merge( + self::$customChain, + self::$defaultProviders + ); + + $exceptionMessages = []; + + foreach ($providerChain as $provider) { + try { + $credentials = $provider->getCredentials(); + $this->lastUsedCredentialsProvider = $provider; + return new Credentials([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'providerName' => $this->getProviderName() . '/' . $provider->getProviderName(), + ]); + } catch (Exception $exception) { + array_push($exceptionMessages, basename(str_replace('\\', '/', get_class($provider))) . ': ' . $exception->getMessage()); + } + } + throw new RuntimeException('Unable to load credentials from any of the providers in the chain: ' . implode(', ', $exceptionMessages)); + + } + + /** + * @inheritDoc + */ + public function getProviderName() + { + return "default"; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/credentials/src/Providers/EcsRamRoleCredentialsProvider.php b/vendor/alibabacloud/credentials/src/Providers/EcsRamRoleCredentialsProvider.php new file mode 100644 index 0000000..8dffb50 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Providers/EcsRamRoleCredentialsProvider.php @@ -0,0 +1,276 @@ +filterOptions($options); + $this->filterRoleName($params); + $this->filterDisableECSIMDSv1($params); + Filter::roleName($this->roleName); + Filter::disableIMDSv1($this->disableIMDSv1); + } + + private function filterOptions(array $options) + { + if (isset($options['connectTimeout'])) { + $this->connectTimeout = $options['connectTimeout']; + } + + if (isset($options['readTimeout'])) { + $this->readTimeout = $options['readTimeout']; + } + + Filter::timeout($this->connectTimeout, $this->readTimeout); + } + + private function filterRoleName(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ECS_METADATA')) { + $this->roleName = Helper::env('ALIBABA_CLOUD_ECS_METADATA'); + } + + if (isset($params['roleName'])) { + $this->roleName = $params['roleName']; + } + } + + private function filterDisableECSIMDSv1($params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_IMDSV1_DISABLED')) { + $this->disableIMDSv1 = Helper::env('ALIBABA_CLOUD_IMDSV1_DISABLED') === true ? true : false; + } + + if (isset($params['disableIMDSv1'])) { + $this->disableIMDSv1 = $params['disableIMDSv1']; + } + } + + /** + * Get credentials by request. + * + * @return RefreshResult + * @throws InvalidArgumentException + * @throws RuntimeException + * @throws GuzzleException + */ + public function refreshCredentials() + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ECS_METADATA_DISABLED') && Helper::env('ALIBABA_CLOUD_ECS_METADATA_DISABLED') === true) { + throw new RuntimeException('IMDS credentials is disabled'); + } + + if (is_null($this->roleName) || $this->roleName === '') { + $this->roleName = $this->getRoleNameFromMeta(); + } + + $url = $this->metadataHost . $this->ecsUri . $this->roleName; + $options = Request::commonOptions(); + $options['read_timeout'] = $this->readTimeout; + $options['connect_timeout'] = $this->connectTimeout; + + $metadataToken = $this->getMetadataToken(); + if (!is_null($metadataToken)) { + $options['headers']['X-aliyun-ecs-metadata-token'] = $metadataToken; + } + + $result = Request::createClient()->request('GET', $url, $options); + + if ($result->getStatusCode() === 404) { + throw new InvalidArgumentException('The role was not found in the instance' . (string) $result); + } + + if ($result->getStatusCode() !== 200) { + throw new RuntimeException('Error refreshing credentials from IMDS, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result); + } + + $credentials = $result->toArray(); + + if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken'])) { + throw new RuntimeException('Error retrieving credentials from IMDS result:' . $result->toJson()); + } + + if (!isset($credentials['Code']) || $credentials['Code'] !== 'Success') { + throw new RuntimeException('Error retrieving credentials from IMDS result, Code is not Success:' . $result->toJson()); + } + + return new RefreshResult(new Credentials([ + 'accessKeyId' => $credentials['AccessKeyId'], + 'accessKeySecret' => $credentials['AccessKeySecret'], + 'securityToken' => $credentials['SecurityToken'], + 'expiration' => \strtotime($credentials['Expiration']), + 'providerName' => $this->getProviderName(), + ]), $this->getStaleTime(strtotime($credentials["Expiration"])), $this->getPrefetchTime(strtotime($credentials["Expiration"]))); + } + + /** + * @return string + * @throws InvalidArgumentException + * @throws RuntimeException + * @throws GuzzleException + */ + private function getRoleNameFromMeta() + { + $options = Request::commonOptions(); + $options['read_timeout'] = $this->readTimeout; + $options['connect_timeout'] = $this->connectTimeout; + + $metadataToken = $this->getMetadataToken(); + if (!is_null($metadataToken)) { + $options['headers']['X-aliyun-ecs-metadata-token'] = $metadataToken; + } + + $result = Request::createClient()->request( + 'GET', + 'http://100.100.100.200/latest/meta-data/ram/security-credentials/', + $options + ); + + if ($result->getStatusCode() === 404) { + throw new InvalidArgumentException('The role name was not found in the instance' . (string) $result); + } + + if ($result->getStatusCode() !== 200) { + throw new RuntimeException('Error retrieving role name from result: ' . (string) $result); + } + + $role_name = (string) $result; + if (!$role_name) { + throw new RuntimeException('Error retrieving role name from result is empty'); + } + + return $role_name; + } + + /** + * Get metadata token by request. + * + * @return string + * @throws RuntimeException + * @throws GuzzleException + */ + private function getMetadataToken() + { + $url = $this->metadataHost . $this->metadataTokenUri; + $options = Request::commonOptions(); + $options['read_timeout'] = $this->readTimeout; + $options['connect_timeout'] = $this->connectTimeout; + $options['headers']['X-aliyun-ecs-metadata-token-ttl-seconds'] = $this->metadataTokenDuration; + + $result = Request::createClient()->request('PUT', $url, $options); + + if ($result->getStatusCode() != 200) { + if ($this->disableIMDSv1) { + throw new RuntimeException('Failed to get token from ECS Metadata Service. HttpCode= ' . $result->getStatusCode()); + } + return null; + } + return (string) $result; + } + + /** + * @var int + */ + public function getPrefetchTime($expiration) + { + return $expiration <= 0 ? + time() + (5 * 60) : + time() + (60 * 60); + } + + /** + * @return string + */ + public function key() + { + return 'ecs_ram_role#roleName#' . $this->roleName; + } + + /** + * @return string + */ + public function getProviderName() + { + return 'ecs_ram_role'; + } + + /** + * @return string + */ + public function getRoleName() + { + return $this->roleName; + } + + /** + * @return bool + */ + public function isDisableIMDSv1() + { + return $this->disableIMDSv1; + } +} diff --git a/vendor/alibabacloud/credentials/src/Providers/EnvironmentVariableCredentialsProvider.php b/vendor/alibabacloud/credentials/src/Providers/EnvironmentVariableCredentialsProvider.php new file mode 100644 index 0000000..b6dd579 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Providers/EnvironmentVariableCredentialsProvider.php @@ -0,0 +1,65 @@ + $accessKeyId, + 'accessKeySecret' => $accessKeySecret, + 'securityToken' => $securityToken, + 'providerName' => $this->getProviderName(), + ]); + } + + return new Credentials([ + 'accessKeyId' => $accessKeyId, + 'accessKeySecret' => $accessKeySecret, + 'providerName' => $this->getProviderName(), + ]); + } + + /** + * @inheritDoc + */ + public function getProviderName() + { + return "env"; + } +} diff --git a/vendor/alibabacloud/credentials/src/Providers/OIDCRoleArnCredentialsProvider.php b/vendor/alibabacloud/credentials/src/Providers/OIDCRoleArnCredentialsProvider.php new file mode 100644 index 0000000..18fe6ec --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Providers/OIDCRoleArnCredentialsProvider.php @@ -0,0 +1,268 @@ +filterOptions($options); + $this->filterRoleArn($params); + $this->filterOIDCProviderArn($params); + $this->filterOIDCTokenFilePath($params); + $this->filterRoleSessionName($params); + $this->filterDurationSeconds($params); + $this->filterPolicy($params); + $this->filterSTSEndpoint($params); + } + + private function filterRoleArn(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_ARN')) { + $this->roleArn = Helper::env('ALIBABA_CLOUD_ROLE_ARN'); + } + + if (isset($params['roleArn'])) { + $this->roleArn = $params['roleArn']; + } + + Filter::roleArn($this->roleArn); + } + + private function filterOIDCProviderArn(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_PROVIDER_ARN')) { + $this->oidcProviderArn = Helper::env('ALIBABA_CLOUD_OIDC_PROVIDER_ARN'); + } + + if (isset($params['oidcProviderArn'])) { + $this->oidcProviderArn = $params['oidcProviderArn']; + } + + Filter::oidcProviderArn($this->oidcProviderArn); + } + + private function filterOIDCTokenFilePath(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_OIDC_TOKEN_FILE')) { + $this->oidcTokenFilePath = Helper::env('ALIBABA_CLOUD_OIDC_TOKEN_FILE'); + } + + if (isset($params['oidcTokenFilePath'])) { + $this->oidcTokenFilePath = $params['oidcTokenFilePath']; + } + + Filter::oidcTokenFilePath($this->oidcTokenFilePath); + } + + private function filterRoleSessionName(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_SESSION_NAME')) { + $this->roleSessionName = Helper::env('ALIBABA_CLOUD_ROLE_SESSION_NAME'); + } + + if (isset($params['roleSessionName'])) { + $this->roleSessionName = $params['roleSessionName']; + } + + if (is_null($this->roleSessionName) || $this->roleSessionName === '') { + $this->roleSessionName = 'phpSdkRoleSessionName'; + } + } + + private function filterDurationSeconds(array $params) + { + if (isset($params['durationSeconds'])) { + if (is_int($params['durationSeconds'])) { + $this->durationSeconds = $params['durationSeconds']; + } + } + if ($this->durationSeconds < 900) { + throw new InvalidArgumentException('Role session expiration should be in the range of 900s - max session duration'); + } + } + + private function filterPolicy(array $params) + { + if (isset($params['policy'])) { + if (is_string($params['policy'])) { + $this->policy = $params['policy']; + } + + if (is_array($params['policy'])) { + $this->policy = json_encode($params['policy']); + } + } + } + + private function filterSTSEndpoint(array $params) + { + $prefix = 'sts'; + if (Helper::envNotEmpty('ALIBABA_CLOUD_VPC_ENDPOINT_ENABLED') || (isset($params['enableVpc']) && $params['enableVpc'] === true)) { + $prefix = 'sts-vpc'; + } + if (Helper::envNotEmpty('ALIBABA_CLOUD_STS_REGION')) { + $this->stsEndpoint = $prefix . '.' . Helper::env('ALIBABA_CLOUD_STS_REGION') . '.aliyuncs.com'; + } + + if (isset($params['stsRegionId'])) { + $this->stsEndpoint = $prefix . '.' . $params['stsRegionId'] . '.aliyuncs.com'; + } + + if (isset($params['stsEndpoint'])) { + $this->stsEndpoint = $params['stsEndpoint']; + } + + if (is_null($this->stsEndpoint) || $this->stsEndpoint === '') { + $this->stsEndpoint = 'sts.aliyuncs.com'; + } + } + + private function filterOptions(array $options) + { + if (isset($options['connectTimeout'])) { + $this->connectTimeout = $options['connectTimeout']; + } + + if (isset($options['readTimeout'])) { + $this->readTimeout = $options['readTimeout']; + } + + Filter::timeout($this->connectTimeout, $this->readTimeout); + } + + /** + * Get credentials by request. + * + * @return RefreshResult + * @throws RuntimeException + * @throws GuzzleException + */ + public function refreshCredentials() + { + $options = Request::commonOptions(); + $options['read_timeout'] = $this->readTimeout; + $options['connect_timeout'] = $this->connectTimeout; + + $options['query']['Action'] = 'AssumeRoleWithOIDC'; + $options['query']['Version'] = '2015-04-01'; + $options['query']['Format'] = 'JSON'; + $options['query']['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); + $options['query']['RoleArn'] = $this->roleArn; + $options['query']['OIDCProviderArn'] = $this->oidcProviderArn; + try { + $oidcToken = file_get_contents($this->oidcTokenFilePath); + $options['query']['OIDCToken'] = $oidcToken; + } catch (Exception $exception) { + throw new InvalidArgumentException($exception->getMessage()); + } + $options['query']['RoleSessionName'] = $this->roleSessionName; + $options['query']['DurationSeconds'] = (string) $this->durationSeconds; + if (!is_null($this->policy)) { + $options['query']['Policy'] = $this->policy; + } + + $url = (new Uri())->withScheme('https')->withHost($this->stsEndpoint); + + $result = Request::createClient()->request('POST', $url, $options); + + if ($result->getStatusCode() !== 200) { + throw new RuntimeException('Error refreshing credentials from OIDC, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result); + } + + $json = $result->toArray(); + $credentials = $json['Credentials']; + + if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken'])) { + throw new RuntimeException('Error retrieving credentials from OIDC result:' . $result->toJson()); + } + + return new RefreshResult(new Credentials([ + 'accessKeyId' => $credentials['AccessKeyId'], + 'accessKeySecret' => $credentials['AccessKeySecret'], + 'securityToken' => $credentials['SecurityToken'], + 'expiration' => \strtotime($credentials['Expiration']), + 'providerName' => $this->getProviderName(), + ]), $this->getStaleTime(strtotime($credentials['Expiration']))); + } + + public function key() + { + return 'oidc_role_arn#roleArn#' . $this->roleArn . '#oidcProviderArn#' . $this->oidcProviderArn . '#roleSessionName#' . $this->roleSessionName; + } + + public function getProviderName() + { + return 'oidc_role_arn'; + } +} diff --git a/vendor/alibabacloud/credentials/src/Providers/ProfileCredentialsProvider.php b/vendor/alibabacloud/credentials/src/Providers/ProfileCredentialsProvider.php new file mode 100644 index 0000000..ab07efe --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Providers/ProfileCredentialsProvider.php @@ -0,0 +1,188 @@ +filterProfileName($params); + $this->filterProfileFile(); + } + + private function filterProfileName(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_PROFILE')) { + $this->profileName = Helper::env('ALIBABA_CLOUD_PROFILE'); + } + + if (isset($params['profileName'])) { + $this->profileName = $params['profileName']; + } + + if (is_null($this->profileName) || $this->profileName === '') { + $this->profileName = 'default'; + } + } + + private function filterProfileFile() + { + $this->profileFile = Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_FILE'); + + if (!$this->profileFile) { + $this->profileFile = self::getDefaultFile(); + } + } + + /** + * @return bool + */ + private function shouldReloadCredentialsProvider() + { + if (is_null($this->credentialsProvider)) { + return true; + } + + return false; + } + + /** + * @return CredentialsProvider + */ + private function reloadCredentialsProvider($profileFile, $profileName) + { + if (!Helper::inOpenBasedir($profileFile)) { + throw new RuntimeException('Unable to open credentials file: ' . $profileFile); + } + + if (!\is_readable($profileFile) || !\is_file($profileFile)) { + throw new RuntimeException('Credentials file is not readable: ' . $profileFile); + } + + $fileArray = \parse_ini_file($profileFile, true); + + if (\is_array($fileArray) && !empty($fileArray)) { + $credentialsConfigures = []; + foreach (\array_change_key_case($fileArray) as $name => $configures) { + if ($name === $profileName) { + $credentialsConfigures = $configures; + break; + } + } + if (\is_array($credentialsConfigures) && !empty($credentialsConfigures)) { + switch (Helper::unsetReturnNull($credentialsConfigures, 'type')) { + case 'access_key': + return new StaticAKCredentialsProvider([ + 'accessKeyId' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_id'), + 'accessKeySecret' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_secret'), + ]); + case 'ram_role_arn': + $innerProvider = new StaticAKCredentialsProvider([ + 'accessKeyId' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_id'), + 'accessKeySecret' => Helper::unsetReturnNull($credentialsConfigures, 'access_key_secret'), + ]); + return new RamRoleArnCredentialsProvider([ + 'credentialsProvider' => $innerProvider, + 'roleArn' => Helper::unsetReturnNull($credentialsConfigures, 'role_arn'), + 'roleSessionName' => Helper::unsetReturnNull($credentialsConfigures, 'role_session_name'), + 'policy' => Helper::unsetReturnNull($credentialsConfigures, 'policy'), + ]); + case 'ecs_ram_role': + return new EcsRamRoleCredentialsProvider([ + 'roleName' => Helper::unsetReturnNull($credentialsConfigures, 'role_name'), + ]); + case 'oidc_role_arn': + return new OIDCRoleArnCredentialsProvider([ + 'roleArn' => Helper::unsetReturnNull($credentialsConfigures, 'role_arn'), + 'oidcProviderArn' => Helper::unsetReturnNull($credentialsConfigures, 'oidc_provider_arn'), + 'oidcTokenFilePath' => Helper::unsetReturnNull($credentialsConfigures, 'oidc_token_file_path'), + 'roleSessionName' => Helper::unsetReturnNull($credentialsConfigures, 'role_session_name'), + 'policy' => Helper::unsetReturnNull($credentialsConfigures, 'policy'), + ]); + case 'rsa_key_pair': + return new RsaKeyPairCredentialsProvider([ + 'publicKeyId' => Helper::unsetReturnNull($credentialsConfigures, 'public_key_id'), + 'privateKeyFile' => Helper::unsetReturnNull($credentialsConfigures, 'private_key_file'), + ]); + default: + throw new RuntimeException('Unsupported credential type from credentials file: ' . Helper::unsetReturnNull($credentialsConfigures, 'type')); + } + } + } + throw new RuntimeException('Failed to get credential from credentials file: ' . $profileFile); + } + /** + * Get credential. + * + * @return Credentials + * @throws RuntimeException + */ + public function getCredentials() + { + if ($this->shouldReloadCredentialsProvider()) { + $this->credentialsProvider = $this->reloadCredentialsProvider($this->profileFile, $this->profileName); + } + + $credentials = $this->credentialsProvider->getCredentials(); + return new Credentials([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'providerName' => $this->getProviderName() . '/' . $this->credentialsProvider->getProviderName(), + ]); + + } + + /** + * Get the default credential file. + * + * @return string + */ + private function getDefaultFile() + { + return Helper::getHomeDirectory() . + DIRECTORY_SEPARATOR . + '.alibabacloud' . + DIRECTORY_SEPARATOR . + 'credentials'; + } + + /** + * @return string + */ + public function getProviderName() + { + return 'profile'; + } +} diff --git a/vendor/alibabacloud/credentials/src/Providers/RamRoleArnCredentialsProvider.php b/vendor/alibabacloud/credentials/src/Providers/RamRoleArnCredentialsProvider.php new file mode 100644 index 0000000..b69f6c5 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Providers/RamRoleArnCredentialsProvider.php @@ -0,0 +1,321 @@ +filterOptions($options); + $this->filterCredentials($params); + $this->filterRoleArn($params); + $this->filterRoleSessionName($params); + $this->filterDurationSeconds($params); + $this->filterPolicy($params); + $this->filterExternalId($params); + $this->filterSTSEndpoint($params); + } + + private function filterRoleArn(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_ARN')) { + $this->roleArn = Helper::env('ALIBABA_CLOUD_ROLE_ARN'); + } + + if (isset($params['roleArn'])) { + $this->roleArn = $params['roleArn']; + } + + Filter::roleArn($this->roleArn); + } + + private function filterRoleSessionName(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ROLE_SESSION_NAME')) { + $this->roleSessionName = Helper::env('ALIBABA_CLOUD_ROLE_SESSION_NAME'); + } + + if (isset($params['roleSessionName'])) { + $this->roleSessionName = $params['roleSessionName']; + } + + if (is_null($this->roleSessionName) || $this->roleSessionName === '') { + $this->roleSessionName = 'phpSdkRoleSessionName'; + } + } + + private function filterDurationSeconds(array $params) + { + if (isset($params['durationSeconds'])) { + if (is_int($params['durationSeconds'])) { + $this->durationSeconds = $params['durationSeconds']; + } + } + if ($this->durationSeconds < 900) { + throw new InvalidArgumentException('Role session expiration should be in the range of 900s - max session duration'); + } + } + + private function filterPolicy(array $params) + { + if (isset($params['policy'])) { + if (is_string($params['policy'])) { + $this->policy = $params['policy']; + } + + if (is_array($params['policy'])) { + $this->policy = json_encode($params['policy']); + } + } + } + + private function filterExternalId(array $params) + { + if (isset($params['externalId'])) { + if (is_string($params['externalId'])) { + $this->externalId = $params['externalId']; + } + } + } + + private function filterSTSEndpoint(array $params) + { + $prefix = 'sts'; + if (Helper::envNotEmpty('ALIBABA_CLOUD_VPC_ENDPOINT_ENABLED') || (isset($params['enableVpc']) && $params['enableVpc'] === true)) { + $prefix = 'sts-vpc'; + } + if (Helper::envNotEmpty('ALIBABA_CLOUD_STS_REGION')) { + $this->stsEndpoint = $prefix . '.' . Helper::env('ALIBABA_CLOUD_STS_REGION') . '.aliyuncs.com'; + } + + if (isset($params['stsRegionId'])) { + $this->stsEndpoint = $prefix . '.' . $params['stsRegionId'] . '.aliyuncs.com'; + } + + if (isset($params['stsEndpoint'])) { + $this->stsEndpoint = $params['stsEndpoint']; + } + + if (is_null($this->stsEndpoint) || $this->stsEndpoint === '') { + $this->stsEndpoint = 'sts.aliyuncs.com'; + } + } + + private function filterCredentials(array $params) + { + if (isset($params['credentialsProvider'])) { + if (!($params['credentialsProvider'] instanceof CredentialsProvider)) { + throw new InvalidArgumentException('Invalid credentialsProvider option for ram_role_arn'); + } + $this->credentialsProvider = $params['credentialsProvider']; + } else if (isset($params['accessKeyId']) && isset($params['accessKeySecret']) && isset($params['securityToken'])) { + Filter::accessKey($params['accessKeyId'], $params['accessKeySecret']); + Filter::securityToken($params['securityToken']); + $this->credentialsProvider = new StaticSTSCredentialsProvider($params); + } else if (isset($params['accessKeyId']) && isset($params['accessKeySecret'])) { + Filter::accessKey($params['accessKeyId'], $params['accessKeySecret']); + $this->credentialsProvider = new StaticAKCredentialsProvider($params); + } else { + throw new InvalidArgumentException('Missing required credentials option for ram_role_arn'); + } + } + + private function filterOptions(array $options) + { + if (isset($options['connectTimeout'])) { + $this->connectTimeout = $options['connectTimeout']; + } + + if (isset($options['readTimeout'])) { + $this->readTimeout = $options['readTimeout']; + } + + Filter::timeout($this->connectTimeout, $this->readTimeout); + } + + /** + * Get credentials by request. + * + * @return RefreshResult + * @throws RuntimeException + * @throws GuzzleException + */ + public function refreshCredentials() + { + $options = Request::commonOptions(); + $options['read_timeout'] = $this->readTimeout; + $options['connect_timeout'] = $this->connectTimeout; + + $options['query']['Action'] = 'AssumeRole'; + $options['query']['Version'] = '2015-04-01'; + $options['query']['Format'] = 'JSON'; + $options['query']['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); + $options['query']['SignatureMethod'] = 'HMAC-SHA1'; + $options['query']['SignatureVersion'] = '1.0'; + $options['query']['SignatureNonce'] = Request::uuid(json_encode($options['query'])); + $options['query']['RoleArn'] = $this->roleArn; + $options['query']['RoleSessionName'] = $this->roleSessionName; + $options['query']['DurationSeconds'] = (string) $this->durationSeconds; + if (!is_null($this->policy) && $this->policy !== '') { + $options['query']['Policy'] = $this->policy; + } + if (!is_null($this->externalId) && $this->externalId !== '') { + $options['query']['ExternalId'] = $this->externalId; + } + + $sessionCredentials = $this->credentialsProvider->getCredentials(); + $options['query']['AccessKeyId'] = $sessionCredentials->getAccessKeyId(); + if (!is_null($sessionCredentials->getSecurityToken())) { + $options['query']['SecurityToken'] = $sessionCredentials->getSecurityToken(); + } + $options['query']['Signature'] = Request::shaHmac1sign( + Request::signString('GET', $options['query']), + $sessionCredentials->getAccessKeySecret() . '&' + ); + + $url = (new Uri())->withScheme('https')->withHost($this->stsEndpoint); + + $result = Request::createClient()->request('GET', $url, $options); + + if ($result->getStatusCode() !== 200) { + throw new RuntimeException('Error refreshing credentials from RamRoleArn, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result); + } + + $json = $result->toArray(); + $credentials = $json['Credentials']; + + if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken'])) { + throw new RuntimeException('Error retrieving credentials from RamRoleArn result:' . $result->toJson()); + } + + return new RefreshResult(new Credentials([ + 'accessKeyId' => $credentials['AccessKeyId'], + 'accessKeySecret' => $credentials['AccessKeySecret'], + 'securityToken' => $credentials['SecurityToken'], + 'expiration' => \strtotime($credentials['Expiration']), + 'providerName' => $this->getProviderName(), + ]), $this->getStaleTime(strtotime($credentials['Expiration']))); + } + + public function key() + { + $credentials = $this->credentialsProvider->getCredentials(); + return 'ram_role_arn#credential#' . $credentials->getAccessKeyId() . '#roleArn#' . $this->roleArn . '#roleSessionName#' . $this->roleSessionName; + } + + public function getProviderName() + { + return 'ram_role_arn/' . $this->credentialsProvider->getProviderName(); + } + + /** + * @return string + */ + public function getRoleArn() + { + return $this->roleArn; + } + + /** + * @return string + */ + public function getRoleSessionName() + { + return $this->roleSessionName; + } + + /** + * @return string + */ + public function getPolicy() + { + return $this->policy; + } + + /** + * @deprecated + * @return string + */ + public function getOriginalAccessKeyId() + { + return $this->credentialsProvider->getCredentials()->getAccessKeyId(); + } + + /** + * @deprecated + * @return string + */ + public function getOriginalAccessKeySecret() + { + return $this->credentialsProvider->getCredentials()->getAccessKeySecret(); + } +} diff --git a/vendor/alibabacloud/credentials/src/Providers/RsaKeyPairCredentialsProvider.php b/vendor/alibabacloud/credentials/src/Providers/RsaKeyPairCredentialsProvider.php new file mode 100644 index 0000000..8c85db6 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Providers/RsaKeyPairCredentialsProvider.php @@ -0,0 +1,200 @@ +filterOptions($options); + $this->filterDurationSeconds($params); + $this->filterSTSEndpoint($params); + $this->publicKeyId = isset($params['publicKeyId']) ? $params['publicKeyId'] : null; + $privateKeyFile = isset($params['privateKeyFile']) ? $params['privateKeyFile'] : null; + Filter::publicKeyId($this->publicKeyId); + Filter::privateKeyFile($privateKeyFile); + + try { + $this->privateKey = file_get_contents($privateKeyFile); + } catch (Exception $exception) { + throw new InvalidArgumentException($exception->getMessage()); + } + } + + private function filterOptions(array $options) + { + if (isset($options['connectTimeout'])) { + $this->connectTimeout = $options['connectTimeout']; + } + + if (isset($options['readTimeout'])) { + $this->readTimeout = $options['readTimeout']; + } + + Filter::timeout($this->connectTimeout, $this->readTimeout); + } + + private function filterDurationSeconds(array $params) + { + if (isset($params['durationSeconds'])) { + if (is_int($params['durationSeconds'])) { + $this->durationSeconds = $params['durationSeconds']; + } + } + if ($this->durationSeconds < 900) { + throw new InvalidArgumentException('Role session expiration should be in the range of 900s - max session duration'); + } + } + + private function filterSTSEndpoint(array $params) + { + if (isset($params['stsEndpoint'])) { + $this->stsEndpoint = $params['stsEndpoint']; + } + + if (is_null($this->stsEndpoint) || $this->stsEndpoint === '') { + $this->stsEndpoint = 'sts.ap-northeast-1.aliyuncs.com'; + } + } + + + /** + * Get credentials by request. + * + * @return RefreshResult + * @throws RuntimeException + * @throws GuzzleException + */ + public function refreshCredentials() + { + $options = Request::commonOptions(); + $options['read_timeout'] = $this->readTimeout; + $options['connect_timeout'] = $this->connectTimeout; + + $options['query']['Action'] = 'GenerateSessionAccessKey'; + $options['query']['Version'] = '2015-04-01'; + $options['query']['Format'] = 'JSON'; + $options['query']['Timestamp'] = gmdate('Y-m-d\TH:i:s\Z'); + $options['query']['SignatureMethod'] = 'SHA256withRSA'; + $options['query']['SignatureType'] = 'PRIVATEKEY'; + $options['query']['SignatureVersion'] = '1.0'; + $options['query']['SignatureNonce'] = Request::uuid(json_encode($options['query'])); + $options['query']['DurationSeconds'] = (string) $this->durationSeconds; + $options['query']['AccessKeyId'] = $this->publicKeyId; + $options['query']['Signature'] = Request::shaHmac256WithRsasign( + Request::signString('GET', $options['query']), + $this->privateKey + ); + + $url = (new Uri())->withScheme('https')->withHost($this->stsEndpoint); + + $result = Request::createClient()->request('GET', $url, $options); + + if ($result->getStatusCode() !== 200) { + throw new RuntimeException('Error refreshing credentials from RsaKeyPair, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result); + } + + $json = $result->toArray(); + + if (!isset($json['SessionAccessKey']['SessionAccessKeyId']) || !isset($json['SessionAccessKey']['SessionAccessKeySecret'])) { + throw new RuntimeException('Error retrieving credentials from RsaKeyPair result:' . $result->toJson()); + } + + $credentials = []; + $credentials['AccessKeyId'] = $json['SessionAccessKey']['SessionAccessKeyId']; + $credentials['AccessKeySecret'] = $json['SessionAccessKey']['SessionAccessKeySecret']; + $credentials['Expiration'] = $json['SessionAccessKey']['Expiration']; + $credentials['SecurityToken'] = null; + + + return new RefreshResult(new Credentials([ + 'accessKeyId' => $credentials['AccessKeyId'], + 'accessKeySecret' => $credentials['AccessKeySecret'], + 'securityToken' => $credentials['SecurityToken'], + 'expiration' => \strtotime($credentials['Expiration']), + 'providerName' => $this->getProviderName(), + ]), $this->getStaleTime(strtotime($credentials['Expiration']))); + } + + public function key() + { + return 'rsa_key_pair#publicKeyId#' . $this->publicKeyId; + } + + public function getProviderName() + { + return 'rsa_key_pair'; + } + + /** + * @return string + */ + public function getPublicKeyId() + { + return $this->publicKeyId; + } + + /** + * @return mixed + */ + public function getPrivateKey() + { + return $this->privateKey; + } +} diff --git a/vendor/alibabacloud/credentials/src/Providers/SessionCredentialsProvider.php b/vendor/alibabacloud/credentials/src/Providers/SessionCredentialsProvider.php new file mode 100644 index 0000000..60b92de --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Providers/SessionCredentialsProvider.php @@ -0,0 +1,161 @@ +key()])) { + $result = self::$credentialsCache[$this->key()]; + return $result; + } + return null; + } + + /** + * Cache credentials. + * + * @param RefreshResult $credential + */ + protected function cache(RefreshResult $credential) + { + self::$credentialsCache[$this->key()] = $credential; + } + + /** + * Get credential. + * + * @return Credentials + */ + public function getCredentials() + { + if ($this->cacheIsStale() || $this->shouldInitiateCachePrefetch()) { + $result = $this->refreshCache(); + $this->cache($result); + } + + $result = $this->getCredentialsInCache(); + + return $result->credentials(); + } + + /** + * @return RefreshResult + */ + protected function refreshCache() + { + try { + return $this->handleFetchedSuccess($this->refreshCredentials()); + } catch (\Exception $e) { + return $this->handleFetchedFailure($e); + } + } + + /** + * @return RefreshResult + * @throws \Exception + */ + protected function handleFetchedFailure(\Exception $e) + { + $currentCachedValue = $this->getCredentialsInCache(); + if (is_null($currentCachedValue)) { + throw $e; + } + + if (time() < $currentCachedValue->staleTime()) { + return $currentCachedValue; + } + + throw $e; + } + /** + * @return RefreshResult + */ + protected function handleFetchedSuccess(RefreshResult $value) + { + $now = time(); + // 过期时间大于15分钟,不用管 + if ($now < $value->staleTime()) { + return $value; + } + // 不足或等于15分钟,但未过期,下次会再次刷新 + if ($now < $value->staleTime() + 15 * 60) { + $value->staleTime = $now; + return $value; + } + // 已过期,看缓存,缓存若大于15分钟,返回缓存,若小于15分钟,则稍后重试 + if (is_null($this->getCredentialsInCache())) { + throw new \Exception("The fetched credentials have expired and no cache is available."); + } else if ($now < $this->getCredentialsInCache()->staleTime()) { + return $this->getCredentialsInCache(); + } else { + // 返回成功,延长有效期 1 分钟 + $expectation = mt_rand(50, 70); + $value->staleTime = time() + $expectation; + return $value; + } + } + + /** + * @return bool + */ + protected function cacheIsStale() + { + return is_null($this->getCredentialsInCache()) || time() >= $this->getCredentialsInCache()->staleTime(); + } + + /** + * @return bool + */ + protected function shouldInitiateCachePrefetch() + { + return is_null($this->getCredentialsInCache()) || time() >= $this->getCredentialsInCache()->prefetchTime(); + } + + /** + * @return int + */ + public function getStaleTime($expiration) + { + return $expiration <= 0 ? + time() + (60 * 60) : + $expiration - (15 * 60); + } + + /** + * @return RefreshResult + */ + abstract function refreshCredentials(); + + /** + * Get the toString of the credentials provider as the key. + * + * @return string + */ + abstract function key(); +} diff --git a/vendor/alibabacloud/credentials/src/Providers/StaticAKCredentialsProvider.php b/vendor/alibabacloud/credentials/src/Providers/StaticAKCredentialsProvider.php new file mode 100644 index 0000000..7e73cd0 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Providers/StaticAKCredentialsProvider.php @@ -0,0 +1,78 @@ +filterAK($params); + } + + private function filterAK(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_ID')) { + $this->accessKeyId = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_ID'); + } + + if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_SECRET')) { + $this->accessKeySecret = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_SECRET'); + } + + if (isset($params['accessKeyId'])) { + $this->accessKeyId = $params['accessKeyId']; + } + if (isset($params['accessKeySecret'])) { + $this->accessKeySecret = $params['accessKeySecret']; + } + + Filter::accessKey($this->accessKeyId, $this->accessKeySecret); + } + + /** + * Get credential. + * + * @return Credentials + */ + public function getCredentials() + { + return new Credentials([ + 'accessKeyId' => $this->accessKeyId, + 'accessKeySecret' => $this->accessKeySecret, + 'providerName' => $this->getProviderName(), + ]); + } + + /** + * @inheritDoc + */ + public function getProviderName() + { + return "static_ak"; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/credentials/src/Providers/StaticSTSCredentialsProvider.php b/vendor/alibabacloud/credentials/src/Providers/StaticSTSCredentialsProvider.php new file mode 100644 index 0000000..957b25d --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Providers/StaticSTSCredentialsProvider.php @@ -0,0 +1,92 @@ +filterSTS($params); + } + + private function filterSTS(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_ID')) { + $this->accessKeyId = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_ID'); + } + + if (Helper::envNotEmpty('ALIBABA_CLOUD_ACCESS_KEY_SECRET')) { + $this->accessKeySecret = Helper::env('ALIBABA_CLOUD_ACCESS_KEY_SECRET'); + } + + if (Helper::envNotEmpty('ALIBABA_CLOUD_SECURITY_TOKEN')) { + $this->securityToken = Helper::env('ALIBABA_CLOUD_SECURITY_TOKEN'); + } + + if (isset($params['accessKeyId'])) { + $this->accessKeyId = $params['accessKeyId']; + } + if (isset($params['accessKeySecret'])) { + $this->accessKeySecret = $params['accessKeySecret']; + } + if (isset($params['securityToken'])) { + $this->securityToken = $params['securityToken']; + } + + Filter::accessKey($this->accessKeyId, $this->accessKeySecret); + Filter::securityToken($this->securityToken); + } + + /** + * Get credential. + * + * @return Credentials + */ + public function getCredentials() + { + return new Credentials([ + 'accessKeyId' => $this->accessKeyId, + 'accessKeySecret' => $this->accessKeySecret, + 'securityToken' => $this->securityToken, + 'providerName' => $this->getProviderName(), + ]); + } + + /** + * @inheritDoc + */ + public function getProviderName() + { + return "static_sts"; + } +} \ No newline at end of file diff --git a/vendor/alibabacloud/credentials/src/Providers/URLCredentialsProvider.php b/vendor/alibabacloud/credentials/src/Providers/URLCredentialsProvider.php new file mode 100644 index 0000000..617c19f --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Providers/URLCredentialsProvider.php @@ -0,0 +1,126 @@ +filterOptions($options); + $this->filterCredentialsURI($params); + } + + private function filterOptions(array $options) + { + if (isset($options['connectTimeout'])) { + $this->connectTimeout = $options['connectTimeout']; + } + + if (isset($options['readTimeout'])) { + $this->readTimeout = $options['readTimeout']; + } + + Filter::timeout($this->connectTimeout, $this->readTimeout); + } + + private function filterCredentialsURI(array $params) + { + if (Helper::envNotEmpty('ALIBABA_CLOUD_CREDENTIALS_URI')) { + $this->credentialsURI = Helper::env('ALIBABA_CLOUD_CREDENTIALS_URI'); + } + + if (isset($params['credentialsURI'])) { + $this->credentialsURI = $params['credentialsURI']; + } + + Filter::credentialsURI($this->credentialsURI); + } + + /** + * Get credentials by request. + * + * @return RefreshResult + * @throws InvalidArgumentException + * @throws RuntimeException + * @throws GuzzleException + */ + public function refreshCredentials() + { + $options = Request::commonOptions(); + $options['read_timeout'] = $this->readTimeout; + $options['connect_timeout'] = $this->connectTimeout; + + $result = Request::createClient()->request('GET', $this->credentialsURI, $options); + + if ($result->getStatusCode() !== 200) { + throw new RuntimeException('Error refreshing credentials from credentialsURI, statusCode: ' . $result->getStatusCode() . ', result: ' . (string) $result); + } + + $credentials = $result->toArray(); + + if (!isset($credentials['AccessKeyId']) || !isset($credentials['AccessKeySecret']) || !isset($credentials['SecurityToken']) || !isset($credentials['Expiration'])) { + throw new RuntimeException('Error retrieving credentials from credentialsURI result:' . $result->toJson()); + } + + return new RefreshResult(new Credentials([ + 'accessKeyId' => $credentials['AccessKeyId'], + 'accessKeySecret' => $credentials['AccessKeySecret'], + 'securityToken' => $credentials['SecurityToken'], + 'expiration' => \strtotime($credentials['Expiration']), + 'providerName' => $this->getProviderName(), + ]), $this->getStaleTime(strtotime($credentials['Expiration']))); + } + + + /** + * @return string + */ + public function key() + { + return 'credential_uri#' . $this->credentialsURI; + } + + /** + * @return string + */ + public function getProviderName() + { + return 'credential_uri'; + } +} diff --git a/vendor/alibabacloud/credentials/src/RamRoleArnCredential.php b/vendor/alibabacloud/credentials/src/RamRoleArnCredential.php new file mode 100644 index 0000000..ed75640 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/RamRoleArnCredential.php @@ -0,0 +1,242 @@ +filterParameters($credential); + $this->filterPolicy($credential); + + Filter::accessKey($credential['access_key_id'], $credential['access_key_secret']); + + $this->config = $config; + $this->accessKeyId = $credential['access_key_id']; + $this->accessKeySecret = $credential['access_key_secret']; + $this->roleArn = $credential['role_arn']; + $this->roleSessionName = $credential['role_session_name']; + } + + /** + * @param array $credential + */ + private function filterParameters(array $credential) + { + if (!isset($credential['access_key_id'])) { + throw new InvalidArgumentException('Missing required access_key_id option in config for ram_role_arn'); + } + + if (!isset($credential['access_key_secret'])) { + throw new InvalidArgumentException('Missing required access_key_secret option in config for ram_role_arn'); + } + + if (!isset($credential['role_arn'])) { + throw new InvalidArgumentException('Missing required role_arn option in config for ram_role_arn'); + } + + if (!isset($credential['role_session_name'])) { + throw new InvalidArgumentException('Missing required role_session_name option in config for ram_role_arn'); + } + } + + /** + * @param array $credential + */ + private function filterPolicy(array $credential) + { + if (isset($credential['policy'])) { + if (is_string($credential['policy'])) { + $this->policy = $credential['policy']; + } + + if (is_array($credential['policy'])) { + $this->policy = json_encode($credential['policy']); + } + } + } + + /** + * @return array + */ + public function getConfig() + { + return $this->config; + } + + /** + * @return string + */ + public function getRoleArn() + { + return $this->roleArn; + } + + /** + * @return string + */ + public function getRoleSessionName() + { + return $this->roleSessionName; + } + + /** + * @return string + */ + public function getPolicy() + { + return $this->policy; + } + + /** + * @return string + */ + public function __toString() + { + return "$this->accessKeyId#$this->accessKeySecret#$this->roleArn#$this->roleSessionName"; + } + + /** + * @return ShaHmac1Signature + */ + public function getSignature() + { + return new ShaHmac1Signature(); + } + + /** + * @return string + */ + public function getOriginalAccessKeyId() + { + return $this->accessKeyId; + } + + /** + * @return string + */ + public function getOriginalAccessKeySecret() + { + return $this->accessKeySecret; + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getAccessKeyId() + { + return $this->getSessionCredential()->getAccessKeyId(); + } + + /** + * @return AlibabaCloud\Credentials\Providers\Credentials + * @throws Exception + * @throws GuzzleException + */ + protected function getSessionCredential() + { + $params = [ + 'accessKeyId' => $this->accessKeyId, + 'accessKeySecret' => $this->accessKeyId, + 'roleArn' => $this->roleArn, + 'roleSessionName' => $this->roleSessionName, + 'policy' => $this->policy, + ]; + return (new RamRoleArnCredentialsProvider($params))->getCredentials(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getAccessKeySecret() + { + return $this->getSessionCredential()->getAccessKeySecret(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getSecurityToken() + { + return $this->getSessionCredential()->getSecurityToken(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getExpiration() + { + return $this->getSessionCredential()->getExpiration(); + } + + /** + * @inheritDoc + */ + public function getCredential() + { + $credentials = $this->getSessionCredential(); + return new CredentialModel([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'type' => 'ram_role_arn', + ]); + } +} diff --git a/vendor/alibabacloud/credentials/src/Request/Request.php b/vendor/alibabacloud/credentials/src/Request/Request.php new file mode 100644 index 0000000..f0ba62f --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Request/Request.php @@ -0,0 +1,167 @@ + $value) { + $canonicalized .= '&' . self::percentEncode($key) . '=' . self::percentEncode($value); + } + + return $method . '&%2F&' . self::percentEncode(substr($canonicalized, 1)); + } + + /** + * @param string $string + * @param string $accessKeySecret + * + * @return string + */ + public static function shaHmac1sign($string, $accessKeySecret) + { + return base64_encode(hash_hmac('sha1', $string, $accessKeySecret, true)); + } + + /** + * @param string $string + * @param string $accessKeySecret + * + * @return string + */ + public static function shaHmac256sign($string, $accessKeySecret) + { + return base64_encode(hash_hmac('sha256', $string, $accessKeySecret, true)); + } + + /** + * @param string $string + * @param string $privateKey + * + * @return string + */ + public static function shaHmac256WithRsasign($string, $privateKey) + { + $binarySignature = ''; + try { + openssl_sign( + $string, + $binarySignature, + $privateKey, + \OPENSSL_ALGO_SHA256 + ); + } catch (Exception $exception) { + throw new InvalidArgumentException( + $exception->getMessage() + ); + } + + return base64_encode($binarySignature); + } + + /** + * @param string $string + * + * @return null|string|string[] + */ + private static function percentEncode($string) + { + $result = rawurlencode($string); + $result = str_replace(['+', '*'], ['%20', '%2A'], $result); + $result = preg_replace('/%7E/', '~', $result); + + return $result; + } + + /** + * @return Client + * @throws Exception + */ + public static function createClient() + { + if (Credentials::hasMock()) { + $stack = HandlerStack::create(Credentials::getMock()); + $history = Credentials::getHandlerHistory(); + $stack->push($history); + } else { + $stack = HandlerStack::create(); + } + + $stack->push(Middleware::mapResponse(static function (ResponseInterface $response) { + return new Response($response); + })); + + self::$config['handler'] = $stack; + + return new Client(self::$config); + } +} diff --git a/vendor/alibabacloud/credentials/src/RsaKeyPairCredential.php b/vendor/alibabacloud/credentials/src/RsaKeyPairCredential.php new file mode 100644 index 0000000..12e719e --- /dev/null +++ b/vendor/alibabacloud/credentials/src/RsaKeyPairCredential.php @@ -0,0 +1,185 @@ +publicKeyId = $public_key_id; + $this->privateKeyFile = $private_key_file; + $this->config = $config; + try { + $this->privateKey = file_get_contents($private_key_file); + } catch (Exception $exception) { + throw new InvalidArgumentException($exception->getMessage()); + } + } + + /** + * @return array + */ + public function getConfig() + { + return $this->config; + } + + /** + * @return string + */ + public function getOriginalAccessKeyId() + { + return $this->getPublicKeyId(); + } + + /** + * @return string + */ + public function getPublicKeyId() + { + return $this->publicKeyId; + } + + /** + * @return string + */ + public function getOriginalAccessKeySecret() + { + return $this->getPrivateKey(); + } + + /** + * @return mixed + */ + public function getPrivateKey() + { + return $this->privateKey; + } + + /** + * @return string + */ + public function __toString() + { + return "publicKeyId#$this->publicKeyId"; + } + + /** + * @return ShaHmac1Signature + */ + public function getSignature() + { + return new ShaHmac1Signature(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getAccessKeyId() + { + return $this->getSessionCredential()->getAccessKeyId(); + } + + /** + * @return AlibabaCloud\Credentials\Providers\Credentials + * @throws Exception + * @throws GuzzleException + */ + protected function getSessionCredential() + { + $params = [ + 'publicKeyId' => $this->publicKeyId, + 'privateKeyFile' => $this->privateKeyFile, + ]; + return (new RsaKeyPairCredentialsProvider($params))->getCredentials(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getAccessKeySecret() + { + return $this->getSessionCredential()->getAccessKeySecret(); + } + + /** + * @return string + * @throws Exception + * @throws GuzzleException + */ + public function getSecurityToken() + { + return $this->getSessionCredential()->getSecurityToken(); + } + + /** + * @return int + * @throws Exception + * @throws GuzzleException + */ + public function getExpiration() + { + return $this->getSessionCredential()->getExpiration(); + } + + /** + * @inheritDoc + */ + public function getCredential() + { + $credentials = $this->getSessionCredential(); + return new CredentialModel([ + 'accessKeyId' => $credentials->getAccessKeyId(), + 'accessKeySecret' => $credentials->getAccessKeySecret(), + 'securityToken' => $credentials->getSecurityToken(), + 'type' => 'rsa_key_pair', + ]); + } +} diff --git a/vendor/alibabacloud/credentials/src/Signature/BearerTokenSignature.php b/vendor/alibabacloud/credentials/src/Signature/BearerTokenSignature.php new file mode 100644 index 0000000..1d67a80 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Signature/BearerTokenSignature.php @@ -0,0 +1,47 @@ +getMessage() + ); + } + + return base64_encode($binarySignature); + } +} diff --git a/vendor/alibabacloud/credentials/src/Signature/SignatureInterface.php b/vendor/alibabacloud/credentials/src/Signature/SignatureInterface.php new file mode 100644 index 0000000..9dfb73b --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Signature/SignatureInterface.php @@ -0,0 +1,34 @@ +accessKeyId = $access_key_id; + $this->accessKeySecret = $access_key_secret; + $this->expiration = $expiration; + $this->securityToken = $security_token; + } + + /** + * @return int + */ + public function getExpiration() + { + return $this->expiration; + } + + /** + * @return string + */ + public function getAccessKeyId() + { + return $this->accessKeyId; + } + + /** + * @return string + */ + public function getAccessKeySecret() + { + return $this->accessKeySecret; + } + + /** + * @return string + */ + public function getSecurityToken() + { + return $this->securityToken; + } + + /** + * @return string + */ + public function __toString() + { + return "$this->accessKeyId#$this->accessKeySecret#$this->securityToken"; + } + + /** + * @return ShaHmac1Signature + */ + public function getSignature() + { + return new ShaHmac1Signature(); + } + + /** + * @inheritDoc + */ + public function getCredential() + { + return new CredentialModel([ + 'accessKeyId' => $this->accessKeyId, + 'accessKeySecret' => $this->accessKeySecret, + 'securityToken' => $this->securityToken, + 'type' => 'sts', + ]); + } + +} diff --git a/vendor/alibabacloud/credentials/src/Utils/Filter.php b/vendor/alibabacloud/credentials/src/Utils/Filter.php new file mode 100644 index 0000000..959fd8f --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Utils/Filter.php @@ -0,0 +1,233 @@ + $value) { + if (is_int($key)) { + $result[] = $value; + continue; + } + + if (isset($result[$key]) && is_array($result[$key])) { + $result[$key] = self::merge( + [$result[$key], $value] + ); + continue; + } + + $result[$key] = $value; + } + } + + return $result; + } + + /** + * @param $filename + * + * @return bool + */ + public static function inOpenBasedir($filename) + { + $open_basedir = ini_get('open_basedir'); + if (!$open_basedir) { + return true; + } + if (0 === strpos($filename, vfsStream::SCHEME)) { + // 虚拟文件忽略 + return true; + } + + $dirs = explode(PATH_SEPARATOR, $open_basedir); + + return empty($dirs) || self::inDir($filename, $dirs); + } + + /** + * @param string $filename + * @param array $dirs + * + * @return bool + */ + public static function inDir($filename, array $dirs) + { + foreach ($dirs as $dir) { + if ($dir[strlen($dir) - 1] !== DIRECTORY_SEPARATOR) { + $dir .= DIRECTORY_SEPARATOR; + } + + if (0 === strpos($filename, $dir)) { + return true; + } + } + + return false; + } + + /** + * @return bool + */ + public static function isWindows() + { + return PATH_SEPARATOR === ';'; + } + + /** + * @param $key + * + * @return bool|mixed + */ + public static function envNotEmpty($key) + { + $value = self::env($key, false); + if ($value) { + return $value; + } + + return false; + } + + /** + * Gets the value of an environment variable. + * + * @param string $key + * @param mixed $default + * + * @return mixed + */ + public static function env($key, $default = null) + { + $value = getenv($key); + + if ($value === false) { + return self::value($default); + } + + if (self::envSubstr($value)) { + return substr($value, 1, -1); + } + + return self::envConversion($value); + } + + /** + * Return the default value of the given value. + * + * @param mixed $value + * + * @return mixed + */ + public static function value($value) + { + return $value instanceof Closure ? $value() : $value; + } + + /** + * @param $value + * + * @return bool + */ + public static function envSubstr($value) + { + return ($valueLength = strlen($value)) > 1 + && strpos($value, '"') === 0 + && $value[$valueLength - 1] === '"'; + } + + /** + * @param $value + * + * @return bool|string|null + */ + public static function envConversion($value) + { + $key = strtolower($value); + + if ($key === 'null' || $key === '(null)') { + return null; + } + + $list = [ + 'true' => true, + '(true)' => true, + 'false' => false, + '(false)' => false, + 'empty' => '', + '(empty)' => '', + ]; + + return isset($list[$key]) ? $list[$key] : $value; + } + + /** + * Gets the environment's HOME directory. + * + * @return null|string + */ + public static function getHomeDirectory() + { + if (getenv('HOME')) { + return getenv('HOME'); + } + + return (getenv('HOMEDRIVE') && getenv('HOMEPATH')) + ? getenv('HOMEDRIVE') . getenv('HOMEPATH') + : null; + } + + /** + * @param mixed ...$parameters + * + * @codeCoverageIgnore + */ + public static function dd(...$parameters) + { + dump(...$parameters); + exit; + } + + /** + * Snake to camel case. + * + * @param string $str + * + * @return string + */ + public static function snakeToCamelCase($str) + { + $components = explode('_', $str); + $camelCaseStr = $components[0]; + for ($i = 1; $i < count($components); $i++) { + $camelCaseStr .= ucfirst($components[$i]); + } + return $camelCaseStr; + } + + /** + * Get user agent. + * + * @param string $userAgent + * + * @return string + */ + public static function getUserAgent() + { + return sprintf('AlibabaCloud (%s; %s) PHP/%s Credentials/%s TeaDSL/1', PHP_OS, \PHP_SAPI, PHP_VERSION, Credential::VERSION); + } + + /** + * @param array $arrays + * @param string $key + * + * @return mix + */ + public static function unsetReturnNull(array $arrays, $key) + { + if(isset($arrays[$key])) { + return $arrays[$key]; + } + return null; + } +} diff --git a/vendor/alibabacloud/credentials/src/Utils/MockTrait.php b/vendor/alibabacloud/credentials/src/Utils/MockTrait.php new file mode 100644 index 0000000..cc07119 --- /dev/null +++ b/vendor/alibabacloud/credentials/src/Utils/MockTrait.php @@ -0,0 +1,120 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/alibabacloud/darabonba-openapi/README-CN.md b/vendor/alibabacloud/darabonba-openapi/README-CN.md new file mode 100644 index 0000000..b70255c --- /dev/null +++ b/vendor/alibabacloud/darabonba-openapi/README-CN.md @@ -0,0 +1,31 @@ +[English](README.md) | 简体中文 + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud OpenApi Client + +## 安装 + +### Composer + +```bash +composer require alibabacloud/darabonba-openapi +``` + +## 问题 + +[提交 Issue](https://github.com/aliyun/darabonba-openapi/issues/new),不符合指南的问题可能会立即关闭。 + +## 发行说明 + +每个版本的详细更改记录在[发行说明](./ChangeLog.txt)中。 + +## 相关 + +* [最新源码](https://github.com/aliyun/darabonba-openapi) + +## 许可证 + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/alibabacloud/darabonba-openapi/README.md b/vendor/alibabacloud/darabonba-openapi/README.md new file mode 100644 index 0000000..9770627 --- /dev/null +++ b/vendor/alibabacloud/darabonba-openapi/README.md @@ -0,0 +1,31 @@ +English | [简体中文](README-CN.md) + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud OpenApi Client + +## Installation + +### Composer + +```bash +composer require alibabacloud/darabonba-openapi +``` + +## Issues + +[Opening an Issue](https://github.com/aliyun/darabonba-openapi/issues/new), Issues not conforming to the guidelines may be closed immediately. + +## Changelog + +Detailed changes for each release are documented in the [release notes](./ChangeLog.txt). + +## References + +* [Latest Release](https://github.com/aliyun/darabonba-openapi) + +## License + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/alibabacloud/darabonba-openapi/autoload.php b/vendor/alibabacloud/darabonba-openapi/autoload.php new file mode 100644 index 0000000..526c188 --- /dev/null +++ b/vendor/alibabacloud/darabonba-openapi/autoload.php @@ -0,0 +1,15 @@ +5.5", + "alibabacloud/tea-utils": "^0.2.21", + "alibabacloud/credentials": "^1.2.2", + "alibabacloud/openapi-util": "^0.1.10|^0.2.1", + "alibabacloud/gateway-spi": "^1", + "alibabacloud/tea-xml": "^0.2" + }, + "autoload": { + "psr-4": { + "Darabonba\\OpenApi\\": "src" + } + }, + "scripts": { + "fixer": "php-cs-fixer fix ./" + }, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "optimize-autoloader": true + }, + "prefer-stable": true +} \ No newline at end of file diff --git a/vendor/alibabacloud/darabonba-openapi/phpunit.xml b/vendor/alibabacloud/darabonba-openapi/phpunit.xml new file mode 100644 index 0000000..796384a --- /dev/null +++ b/vendor/alibabacloud/darabonba-openapi/phpunit.xml @@ -0,0 +1,31 @@ + + + + + + tests + + + ./tests/Unit + + + + + + integration + + + + + + + + + + + ./src + + + diff --git a/vendor/alibabacloud/darabonba-openapi/src/Models/Config.php b/vendor/alibabacloud/darabonba-openapi/src/Models/Config.php new file mode 100644 index 0000000..7976310 --- /dev/null +++ b/vendor/alibabacloud/darabonba-openapi/src/Models/Config.php @@ -0,0 +1,463 @@ + '', + 'accessKeySecret' => '', + 'securityToken' => '', + 'bearerToken' => '', + 'protocol' => 'http', + 'method' => '', + 'regionId' => '', + 'readTimeout' => '', + 'connectTimeout' => '', + 'httpProxy' => '', + 'httpsProxy' => '', + 'credential' => '', + 'endpoint' => '', + 'noProxy' => '', + 'maxIdleConns' => '', + 'network' => '', + 'userAgent' => '', + 'suffix' => '', + 'socks5Proxy' => '', + 'socks5NetWork' => '', + 'endpointType' => '', + 'openPlatformEndpoint' => '', + 'type' => '', + 'signatureVersion' => '', + 'signatureAlgorithm' => '', + 'key' => '', + 'cert' => '', + 'ca' => '', + 'tlsMinVersion' => '', + ]; + public function validate() {} + public function toMap() + { + $res = []; + if (null !== $this->accessKeyId) { + $res['accessKeyId'] = $this->accessKeyId; + } + if (null !== $this->accessKeySecret) { + $res['accessKeySecret'] = $this->accessKeySecret; + } + if (null !== $this->securityToken) { + $res['securityToken'] = $this->securityToken; + } + if (null !== $this->bearerToken) { + $res['bearerToken'] = $this->bearerToken; + } + if (null !== $this->protocol) { + $res['protocol'] = $this->protocol; + } + if (null !== $this->method) { + $res['method'] = $this->method; + } + if (null !== $this->regionId) { + $res['regionId'] = $this->regionId; + } + if (null !== $this->readTimeout) { + $res['readTimeout'] = $this->readTimeout; + } + if (null !== $this->connectTimeout) { + $res['connectTimeout'] = $this->connectTimeout; + } + if (null !== $this->httpProxy) { + $res['httpProxy'] = $this->httpProxy; + } + if (null !== $this->httpsProxy) { + $res['httpsProxy'] = $this->httpsProxy; + } + if (null !== $this->credential) { + $res['credential'] = null !== $this->credential ? $this->credential->toMap() : null; + } + if (null !== $this->endpoint) { + $res['endpoint'] = $this->endpoint; + } + if (null !== $this->noProxy) { + $res['noProxy'] = $this->noProxy; + } + if (null !== $this->maxIdleConns) { + $res['maxIdleConns'] = $this->maxIdleConns; + } + if (null !== $this->network) { + $res['network'] = $this->network; + } + if (null !== $this->userAgent) { + $res['userAgent'] = $this->userAgent; + } + if (null !== $this->suffix) { + $res['suffix'] = $this->suffix; + } + if (null !== $this->socks5Proxy) { + $res['socks5Proxy'] = $this->socks5Proxy; + } + if (null !== $this->socks5NetWork) { + $res['socks5NetWork'] = $this->socks5NetWork; + } + if (null !== $this->endpointType) { + $res['endpointType'] = $this->endpointType; + } + if (null !== $this->openPlatformEndpoint) { + $res['openPlatformEndpoint'] = $this->openPlatformEndpoint; + } + if (null !== $this->type) { + $res['type'] = $this->type; + } + if (null !== $this->signatureVersion) { + $res['signatureVersion'] = $this->signatureVersion; + } + if (null !== $this->signatureAlgorithm) { + $res['signatureAlgorithm'] = $this->signatureAlgorithm; + } + if (null !== $this->globalParameters) { + $res['globalParameters'] = null !== $this->globalParameters ? $this->globalParameters->toMap() : null; + } + if (null !== $this->key) { + $res['key'] = $this->key; + } + if (null !== $this->cert) { + $res['cert'] = $this->cert; + } + if (null !== $this->ca) { + $res['ca'] = $this->ca; + } + if (null !== $this->disableHttp2) { + $res['disableHttp2'] = $this->disableHttp2; + } + if (null !== $this->tlsMinVersion) { + $res['tlsMinVersion'] = $this->tlsMinVersion; + } + return $res; + } + /** + * @param array $map + * @return Config + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['accessKeyId'])) { + $model->accessKeyId = $map['accessKeyId']; + } + if (isset($map['accessKeySecret'])) { + $model->accessKeySecret = $map['accessKeySecret']; + } + if (isset($map['securityToken'])) { + $model->securityToken = $map['securityToken']; + } + if (isset($map['bearerToken'])) { + $model->bearerToken = $map['bearerToken']; + } + if (isset($map['protocol'])) { + $model->protocol = $map['protocol']; + } + if (isset($map['method'])) { + $model->method = $map['method']; + } + if (isset($map['regionId'])) { + $model->regionId = $map['regionId']; + } + if (isset($map['readTimeout'])) { + $model->readTimeout = $map['readTimeout']; + } + if (isset($map['connectTimeout'])) { + $model->connectTimeout = $map['connectTimeout']; + } + if (isset($map['httpProxy'])) { + $model->httpProxy = $map['httpProxy']; + } + if (isset($map['httpsProxy'])) { + $model->httpsProxy = $map['httpsProxy']; + } + if (isset($map['credential'])) { + $model->credential = Credential::fromMap($map['credential']); + } + if (isset($map['endpoint'])) { + $model->endpoint = $map['endpoint']; + } + if (isset($map['noProxy'])) { + $model->noProxy = $map['noProxy']; + } + if (isset($map['maxIdleConns'])) { + $model->maxIdleConns = $map['maxIdleConns']; + } + if (isset($map['network'])) { + $model->network = $map['network']; + } + if (isset($map['userAgent'])) { + $model->userAgent = $map['userAgent']; + } + if (isset($map['suffix'])) { + $model->suffix = $map['suffix']; + } + if (isset($map['socks5Proxy'])) { + $model->socks5Proxy = $map['socks5Proxy']; + } + if (isset($map['socks5NetWork'])) { + $model->socks5NetWork = $map['socks5NetWork']; + } + if (isset($map['endpointType'])) { + $model->endpointType = $map['endpointType']; + } + if (isset($map['openPlatformEndpoint'])) { + $model->openPlatformEndpoint = $map['openPlatformEndpoint']; + } + if (isset($map['type'])) { + $model->type = $map['type']; + } + if (isset($map['signatureVersion'])) { + $model->signatureVersion = $map['signatureVersion']; + } + if (isset($map['signatureAlgorithm'])) { + $model->signatureAlgorithm = $map['signatureAlgorithm']; + } + if (isset($map['globalParameters'])) { + $model->globalParameters = GlobalParameters::fromMap($map['globalParameters']); + } + if (isset($map['key'])) { + $model->key = $map['key']; + } + if (isset($map['cert'])) { + $model->cert = $map['cert']; + } + if (isset($map['ca'])) { + $model->ca = $map['ca']; + } + if (isset($map['disableHttp2'])) { + $model->disableHttp2 = $map['disableHttp2']; + } + if (isset($map['tlsMinVersion'])) { + $model->tlsMinVersion = $map['tlsMinVersion']; + } + return $model; + } + /** + * @description accesskey id + * @var string + */ + public $accessKeyId; + + /** + * @description accesskey secret + * @var string + */ + public $accessKeySecret; + + /** + * @description security token + * @example a.txt + * @var string + */ + public $securityToken; + + /** + * @description bearer token + * @example the-bearer-token + * @var string + */ + public $bearerToken; + + /** + * @description http protocol + * @example http + * @var string + */ + public $protocol; + + /** + * @description http method + * @example GET + * @var string + */ + public $method; + + /** + * @description region id + * @example cn-hangzhou + * @var string + */ + public $regionId; + + /** + * @description read timeout + * @example 10 + * @var int + */ + public $readTimeout; + + /** + * @description connect timeout + * @example 10 + * @var int + */ + public $connectTimeout; + + /** + * @description http proxy + * @example http://localhost + * @var string + */ + public $httpProxy; + + /** + * @description https proxy + * @example https://localhost + * @var string + */ + public $httpsProxy; + + /** + * @description credential + * @example + * @var Credential + */ + public $credential; + + /** + * @description endpoint + * @example cs.aliyuncs.com + * @var string + */ + public $endpoint; + + /** + * @description proxy white list + * @example http://localhost + * @var string + */ + public $noProxy; + + /** + * @description max idle conns + * @example 3 + * @var int + */ + public $maxIdleConns; + + /** + * @description network for endpoint + * @example public + * @var string + */ + public $network; + + /** + * @description user agent + * @example Alibabacloud/1 + * @var string + */ + public $userAgent; + + /** + * @description suffix for endpoint + * @example aliyun + * @var string + */ + public $suffix; + + /** + * @description socks5 proxy + * @var string + */ + public $socks5Proxy; + + /** + * @description socks5 network + * @example TCP + * @var string + */ + public $socks5NetWork; + + /** + * @description endpoint type + * @example internal + * @var string + */ + public $endpointType; + + /** + * @description OpenPlatform endpoint + * @example openplatform.aliyuncs.com + * @var string + */ + public $openPlatformEndpoint; + + /** + * @description credential type + * @example access_key + * @deprecated + * @var string + */ + public $type; + + /** + * @description Signature Version + * @example v1 + * @var string + */ + public $signatureVersion; + + /** + * @description Signature Algorithm + * @example ACS3-HMAC-SHA256 + * @var string + */ + public $signatureAlgorithm; + + /** + * @description Global Parameters + * @var GlobalParameters + */ + public $globalParameters; + + /** + * @description privite key for client certificate + * @example MIIEvQ + * @var string + */ + public $key; + + /** + * @description client certificate + * @example -----BEGIN CERTIFICATE----- +xxx-----END CERTIFICATE----- + * @var string + */ + public $cert; + + /** + * @description server certificate + * @example -----BEGIN CERTIFICATE----- +xxx-----END CERTIFICATE----- + * @var string + */ + public $ca; + + /** + * @description disable HTTP/2 + * @example false + * @var bool + */ + public $disableHttp2; + + /** + * @description TLS Minimum Version + * @example TLSv1, TLSv1.1, TLSv1.2, TLSv1.3 + * @var string + */ + public $tlsMinVersion; +} diff --git a/vendor/alibabacloud/darabonba-openapi/src/Models/GlobalParameters.php b/vendor/alibabacloud/darabonba-openapi/src/Models/GlobalParameters.php new file mode 100644 index 0000000..d0d5fa3 --- /dev/null +++ b/vendor/alibabacloud/darabonba-openapi/src/Models/GlobalParameters.php @@ -0,0 +1,40 @@ +headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->queries) { + $res['queries'] = $this->queries; + } + return $res; + } + /** + * @param array $map + * @return GlobalParameters + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['queries'])) { + $model->queries = $map['queries']; + } + return $model; + } + public $headers; + + public $queries; +} diff --git a/vendor/alibabacloud/darabonba-openapi/src/Models/OpenApiRequest.php b/vendor/alibabacloud/darabonba-openapi/src/Models/OpenApiRequest.php new file mode 100644 index 0000000..5ffe1bb --- /dev/null +++ b/vendor/alibabacloud/darabonba-openapi/src/Models/OpenApiRequest.php @@ -0,0 +1,72 @@ +headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->query) { + $res['query'] = $this->query; + } + if (null !== $this->body) { + $res['body'] = $this->body; + } + if (null !== $this->stream) { + $res['stream'] = $this->stream; + } + if (null !== $this->hostMap) { + $res['hostMap'] = $this->hostMap; + } + if (null !== $this->endpointOverride) { + $res['endpointOverride'] = $this->endpointOverride; + } + return $res; + } + /** + * @param array $map + * @return OpenApiRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['query'])) { + $model->query = $map['query']; + } + if (isset($map['body'])) { + $model->body = $map['body']; + } + if (isset($map['stream'])) { + $model->stream = $map['stream']; + } + if (isset($map['hostMap'])) { + $model->hostMap = $map['hostMap']; + } + if (isset($map['endpointOverride'])) { + $model->endpointOverride = $map['endpointOverride']; + } + return $model; + } + public $headers; + + public $query; + + public $body; + + public $stream; + + public $hostMap; + + public $endpointOverride; +} diff --git a/vendor/alibabacloud/darabonba-openapi/src/Models/Params.php b/vendor/alibabacloud/darabonba-openapi/src/Models/Params.php new file mode 100644 index 0000000..3838659 --- /dev/null +++ b/vendor/alibabacloud/darabonba-openapi/src/Models/Params.php @@ -0,0 +1,130 @@ +action, true); + Model::validateRequired('version', $this->version, true); + Model::validateRequired('protocol', $this->protocol, true); + Model::validateRequired('pathname', $this->pathname, true); + Model::validateRequired('method', $this->method, true); + Model::validateRequired('authType', $this->authType, true); + Model::validateRequired('bodyType', $this->bodyType, true); + Model::validateRequired('reqBodyType', $this->reqBodyType, true); + } + public function toMap() + { + $res = []; + if (null !== $this->action) { + $res['action'] = $this->action; + } + if (null !== $this->version) { + $res['version'] = $this->version; + } + if (null !== $this->protocol) { + $res['protocol'] = $this->protocol; + } + if (null !== $this->pathname) { + $res['pathname'] = $this->pathname; + } + if (null !== $this->method) { + $res['method'] = $this->method; + } + if (null !== $this->authType) { + $res['authType'] = $this->authType; + } + if (null !== $this->bodyType) { + $res['bodyType'] = $this->bodyType; + } + if (null !== $this->reqBodyType) { + $res['reqBodyType'] = $this->reqBodyType; + } + if (null !== $this->style) { + $res['style'] = $this->style; + } + return $res; + } + /** + * @param array $map + * @return Params + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['action'])) { + $model->action = $map['action']; + } + if (isset($map['version'])) { + $model->version = $map['version']; + } + if (isset($map['protocol'])) { + $model->protocol = $map['protocol']; + } + if (isset($map['pathname'])) { + $model->pathname = $map['pathname']; + } + if (isset($map['method'])) { + $model->method = $map['method']; + } + if (isset($map['authType'])) { + $model->authType = $map['authType']; + } + if (isset($map['bodyType'])) { + $model->bodyType = $map['bodyType']; + } + if (isset($map['reqBodyType'])) { + $model->reqBodyType = $map['reqBodyType']; + } + if (isset($map['style'])) { + $model->style = $map['style']; + } + return $model; + } + /** + * @var string + */ + public $action; + + /** + * @var string + */ + public $version; + + /** + * @var string + */ + public $protocol; + + /** + * @var string + */ + public $pathname; + + /** + * @var string + */ + public $method; + + /** + * @var string + */ + public $authType; + + /** + * @var string + */ + public $bodyType; + + /** + * @var string + */ + public $reqBodyType; + + public $style; +} diff --git a/vendor/alibabacloud/darabonba-openapi/src/OpenApiClient.php b/vendor/alibabacloud/darabonba-openapi/src/OpenApiClient.php new file mode 100644 index 0000000..cfab565 --- /dev/null +++ b/vendor/alibabacloud/darabonba-openapi/src/OpenApiClient.php @@ -0,0 +1,1345 @@ + "ParameterMissing", + "message" => "'config' can not be unset" + ]); + } + if (!Utils::empty_($config->accessKeyId) && !Utils::empty_($config->accessKeySecret)) { + if (!Utils::empty_($config->securityToken)) { + $config->type = "sts"; + } else { + $config->type = "access_key"; + } + $credentialConfig = new Config([ + "accessKeyId" => $config->accessKeyId, + "type" => $config->type, + "accessKeySecret" => $config->accessKeySecret + ]); + $credentialConfig->securityToken = $config->securityToken; + $this->_credential = new Credential($credentialConfig); + } else if (!Utils::empty_($config->bearerToken)) { + $cc = new Config([ + "type" => "bearer", + "bearerToken" => $config->bearerToken + ]); + $this->_credential = new Credential($cc); + } else if (!Utils::isUnset($config->credential)) { + $this->_credential = $config->credential; + } + $this->_endpoint = $config->endpoint; + $this->_endpointType = $config->endpointType; + $this->_network = $config->network; + $this->_suffix = $config->suffix; + $this->_protocol = $config->protocol; + $this->_method = $config->method; + $this->_regionId = $config->regionId; + $this->_userAgent = $config->userAgent; + $this->_readTimeout = $config->readTimeout; + $this->_connectTimeout = $config->connectTimeout; + $this->_httpProxy = $config->httpProxy; + $this->_httpsProxy = $config->httpsProxy; + $this->_noProxy = $config->noProxy; + $this->_socks5Proxy = $config->socks5Proxy; + $this->_socks5NetWork = $config->socks5NetWork; + $this->_maxIdleConns = $config->maxIdleConns; + $this->_signatureVersion = $config->signatureVersion; + $this->_signatureAlgorithm = $config->signatureAlgorithm; + $this->_globalParameters = $config->globalParameters; + $this->_key = $config->key; + $this->_cert = $config->cert; + $this->_ca = $config->ca; + $this->_disableHttp2 = $config->disableHttp2; + $this->_tlsMinVersion = $config->tlsMinVersion; + } + + /** + * Encapsulate the request and invoke the network + * @param string $action api name + * @param string $version product version + * @param string $protocol http or https + * @param string $method e.g. GET + * @param string $authType authorization type e.g. AK + * @param string $bodyType response body type e.g. String + * @param OpenApiRequest $request object of OpenApiRequest + * @param RuntimeOptions $runtime which controls some details of call api, such as retry times + * @return array the response + * @throws TeaError + * @throws Exception + * @throws TeaUnableRetryError + */ + public function doRPCRequest($action, $version, $protocol, $method, $authType, $bodyType, $request, $runtime) + { + $request->validate(); + $runtime->validate(); + $_runtime = [ + "timeouted" => "retry", + "key" => Utils::defaultString($runtime->key, $this->_key), + "cert" => Utils::defaultString($runtime->cert, $this->_cert), + "ca" => Utils::defaultString($runtime->ca, $this->_ca), + "readTimeout" => Utils::defaultNumber($runtime->readTimeout, $this->_readTimeout), + "connectTimeout" => Utils::defaultNumber($runtime->connectTimeout, $this->_connectTimeout), + "httpProxy" => Utils::defaultString($runtime->httpProxy, $this->_httpProxy), + "httpsProxy" => Utils::defaultString($runtime->httpsProxy, $this->_httpsProxy), + "noProxy" => Utils::defaultString($runtime->noProxy, $this->_noProxy), + "socks5Proxy" => Utils::defaultString($runtime->socks5Proxy, $this->_socks5Proxy), + "socks5NetWork" => Utils::defaultString($runtime->socks5NetWork, $this->_socks5NetWork), + "maxIdleConns" => Utils::defaultNumber($runtime->maxIdleConns, $this->_maxIdleConns), + "retry" => [ + "retryable" => $runtime->autoretry, + "maxAttempts" => Utils::defaultNumber($runtime->maxAttempts, 3) + ], + "backoff" => [ + "policy" => Utils::defaultString($runtime->backoffPolicy, "no"), + "period" => Utils::defaultNumber($runtime->backoffPeriod, 1) + ], + "ignoreSSL" => $runtime->ignoreSSL, + "tlsMinVersion" => $this->_tlsMinVersion + ]; + $_lastRequest = null; + $_lastException = null; + $_now = time(); + $_retryTimes = 0; + while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) { + if ($_retryTimes > 0) { + $_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes); + if ($_backoffTime > 0) { + Tea::sleep($_backoffTime); + } + } + $_retryTimes = $_retryTimes + 1; + try { + $_request = new Request(); + $_request->protocol = Utils::defaultString($this->_protocol, $protocol); + $_request->method = $method; + $_request->pathname = "/"; + $globalQueries = []; + $globalHeaders = []; + if (!Utils::isUnset($this->_globalParameters)) { + $globalParams = $this->_globalParameters; + if (!Utils::isUnset($globalParams->queries)) { + $globalQueries = $globalParams->queries; + } + if (!Utils::isUnset($globalParams->headers)) { + $globalHeaders = $globalParams->headers; + } + } + $extendsHeaders = []; + $extendsQueries = []; + if (!Utils::isUnset($runtime->extendsParameters)) { + $extendsParameters = $runtime->extendsParameters; + if (!Utils::isUnset($extendsParameters->headers)) { + $extendsHeaders = $extendsParameters->headers; + } + if (!Utils::isUnset($extendsParameters->queries)) { + $extendsQueries = $extendsParameters->queries; + } + } + $_request->query = Tea::merge([ + "Action" => $action, + "Format" => "json", + "Version" => $version, + "Timestamp" => OpenApiUtilClient::getTimestamp(), + "SignatureNonce" => Utils::getNonce() + ], $globalQueries, $extendsQueries, $request->query); + $headers = $this->getRpcHeaders(); + if (Utils::isUnset($headers)) { + // endpoint is setted in product client + $_request->headers = Tea::merge([ + "host" => $this->_endpoint, + "x-acs-version" => $version, + "x-acs-action" => $action, + "user-agent" => $this->getUserAgent() + ], $globalHeaders, $extendsHeaders, $request->headers); + } else { + $_request->headers = Tea::merge([ + "host" => $this->_endpoint, + "x-acs-version" => $version, + "x-acs-action" => $action, + "user-agent" => $this->getUserAgent() + ], $globalHeaders, $extendsHeaders, $request->headers, $headers); + } + if (!Utils::isUnset($request->body)) { + $m = Utils::assertAsMap($request->body); + $tmp = Utils::anyifyMapValue(OpenApiUtilClient::query($m)); + $_request->body = Utils::toFormString($tmp); + $_request->headers["content-type"] = "application/x-www-form-urlencoded"; + } + if (!Utils::equalString($authType, "Anonymous")) { + if (Utils::isUnset($this->_credential)) { + throw new TeaError([ + "code" => "InvalidCredentials", + "message" => "Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details." + ]); + } + $credentialModel = $this->_credential->getCredential(); + if (!Utils::empty_($credentialModel->providerName)) { + $_request->headers["x-acs-credentials-provider"] = $credentialModel->providerName; + } + $credentialType = $credentialModel->type; + if (Utils::equalString($credentialType, "bearer")) { + $bearerToken = $credentialModel->bearerToken; + $_request->query["BearerToken"] = $bearerToken; + $_request->query["SignatureType"] = "BEARERTOKEN"; + } else if (Utils::equalString($credentialType, "id_token")) { + $idToken = $credentialModel->securityToken; + $_request->headers["x-acs-zero-trust-idtoken"] = $idToken; + } else { + $accessKeyId = $credentialModel->accessKeyId; + $accessKeySecret = $credentialModel->accessKeySecret; + $securityToken = $credentialModel->securityToken; + if (!Utils::empty_($securityToken)) { + $_request->query["SecurityToken"] = $securityToken; + } + $_request->query["SignatureMethod"] = "HMAC-SHA1"; + $_request->query["SignatureVersion"] = "1.0"; + $_request->query["AccessKeyId"] = $accessKeyId; + $t = null; + if (!Utils::isUnset($request->body)) { + $t = Utils::assertAsMap($request->body); + } + $signedParam = Tea::merge($_request->query, OpenApiUtilClient::query($t)); + $_request->query["Signature"] = OpenApiUtilClient::getRPCSignature($signedParam, $_request->method, $accessKeySecret); + } + } + $_lastRequest = $_request; + $_response = Tea::send($_request, $_runtime); + if (Utils::is4xx($_response->statusCode) || Utils::is5xx($_response->statusCode)) { + $_res = Utils::readAsJSON($_response->body); + $err = Utils::assertAsMap($_res); + $requestId = self::defaultAny(@$err["RequestId"], @$err["requestId"]); + @$err["statusCode"] = $_response->statusCode; + throw new TeaError([ + "code" => "" . (string) (self::defaultAny(@$err["Code"], @$err["code"])) . "", + "message" => "code: " . (string) ($_response->statusCode) . ", " . (string) (self::defaultAny(@$err["Message"], @$err["message"])) . " request id: " . (string) ($requestId) . "", + "data" => $err, + "description" => "" . (string) (self::defaultAny(@$err["Description"], @$err["description"])) . "", + "accessDeniedDetail" => self::defaultAny(@$err["AccessDeniedDetail"], @$err["accessDeniedDetail"]) + ]); + } + if (Utils::equalString($bodyType, "binary")) { + $resp = [ + "body" => $_response->body, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + return $resp; + } else if (Utils::equalString($bodyType, "byte")) { + $byt = Utils::readAsBytes($_response->body); + return [ + "body" => $byt, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "string")) { + $str = Utils::readAsString($_response->body); + return [ + "body" => $str, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "json")) { + $obj = Utils::readAsJSON($_response->body); + $res = Utils::assertAsMap($obj); + return [ + "body" => $res, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "array")) { + $arr = Utils::readAsJSON($_response->body); + return [ + "body" => $arr, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else { + return [ + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } + } catch (Exception $e) { + if (!($e instanceof TeaError)) { + $e = new TeaError([], $e->getMessage(), $e->getCode(), $e); + } + if (Tea::isRetryable($e)) { + $_lastException = $e; + continue; + } + throw $e; + } + } + throw new TeaUnableRetryError($_lastRequest, $_lastException); + } + + /** + * Encapsulate the request and invoke the network + * @param string $action api name + * @param string $version product version + * @param string $protocol http or https + * @param string $method e.g. GET + * @param string $authType authorization type e.g. AK + * @param string $pathname pathname of every api + * @param string $bodyType response body type e.g. String + * @param OpenApiRequest $request object of OpenApiRequest + * @param RuntimeOptions $runtime which controls some details of call api, such as retry times + * @return array the response + * @throws TeaError + * @throws Exception + * @throws TeaUnableRetryError + */ + public function doROARequest($action, $version, $protocol, $method, $authType, $pathname, $bodyType, $request, $runtime) + { + $request->validate(); + $runtime->validate(); + $_runtime = [ + "timeouted" => "retry", + "key" => Utils::defaultString($runtime->key, $this->_key), + "cert" => Utils::defaultString($runtime->cert, $this->_cert), + "ca" => Utils::defaultString($runtime->ca, $this->_ca), + "readTimeout" => Utils::defaultNumber($runtime->readTimeout, $this->_readTimeout), + "connectTimeout" => Utils::defaultNumber($runtime->connectTimeout, $this->_connectTimeout), + "httpProxy" => Utils::defaultString($runtime->httpProxy, $this->_httpProxy), + "httpsProxy" => Utils::defaultString($runtime->httpsProxy, $this->_httpsProxy), + "noProxy" => Utils::defaultString($runtime->noProxy, $this->_noProxy), + "socks5Proxy" => Utils::defaultString($runtime->socks5Proxy, $this->_socks5Proxy), + "socks5NetWork" => Utils::defaultString($runtime->socks5NetWork, $this->_socks5NetWork), + "maxIdleConns" => Utils::defaultNumber($runtime->maxIdleConns, $this->_maxIdleConns), + "retry" => [ + "retryable" => $runtime->autoretry, + "maxAttempts" => Utils::defaultNumber($runtime->maxAttempts, 3) + ], + "backoff" => [ + "policy" => Utils::defaultString($runtime->backoffPolicy, "no"), + "period" => Utils::defaultNumber($runtime->backoffPeriod, 1) + ], + "ignoreSSL" => $runtime->ignoreSSL, + "tlsMinVersion" => $this->_tlsMinVersion + ]; + $_lastRequest = null; + $_lastException = null; + $_now = time(); + $_retryTimes = 0; + while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) { + if ($_retryTimes > 0) { + $_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes); + if ($_backoffTime > 0) { + Tea::sleep($_backoffTime); + } + } + $_retryTimes = $_retryTimes + 1; + try { + $_request = new Request(); + $_request->protocol = Utils::defaultString($this->_protocol, $protocol); + $_request->method = $method; + $_request->pathname = $pathname; + $globalQueries = []; + $globalHeaders = []; + if (!Utils::isUnset($this->_globalParameters)) { + $globalParams = $this->_globalParameters; + if (!Utils::isUnset($globalParams->queries)) { + $globalQueries = $globalParams->queries; + } + if (!Utils::isUnset($globalParams->headers)) { + $globalHeaders = $globalParams->headers; + } + } + $extendsHeaders = []; + $extendsQueries = []; + if (!Utils::isUnset($runtime->extendsParameters)) { + $extendsParameters = $runtime->extendsParameters; + if (!Utils::isUnset($extendsParameters->headers)) { + $extendsHeaders = $extendsParameters->headers; + } + if (!Utils::isUnset($extendsParameters->queries)) { + $extendsQueries = $extendsParameters->queries; + } + } + $_request->headers = Tea::merge([ + "date" => Utils::getDateUTCString(), + "host" => $this->_endpoint, + "accept" => "application/json", + "x-acs-signature-nonce" => Utils::getNonce(), + "x-acs-signature-method" => "HMAC-SHA1", + "x-acs-signature-version" => "1.0", + "x-acs-version" => $version, + "x-acs-action" => $action, + "user-agent" => Utils::getUserAgent($this->_userAgent) + ], $globalHeaders, $extendsHeaders, $request->headers); + if (!Utils::isUnset($request->body)) { + $_request->body = Utils::toJSONString($request->body); + $_request->headers["content-type"] = "application/json; charset=utf-8"; + } + $_request->query = Tea::merge($globalQueries, $extendsQueries); + if (!Utils::isUnset($request->query)) { + $_request->query = Tea::merge($_request->query, $request->query); + } + if (!Utils::equalString($authType, "Anonymous")) { + if (Utils::isUnset($this->_credential)) { + throw new TeaError([ + "code" => "InvalidCredentials", + "message" => "Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details." + ]); + } + $credentialModel = $this->_credential->getCredential(); + if (!Utils::empty_($credentialModel->providerName)) { + $_request->headers["x-acs-credentials-provider"] = $credentialModel->providerName; + } + $credentialType = $credentialModel->type; + if (Utils::equalString($credentialType, "bearer")) { + $bearerToken = $credentialModel->bearerToken; + $_request->headers["x-acs-bearer-token"] = $bearerToken; + $_request->headers["x-acs-signature-type"] = "BEARERTOKEN"; + } else if (Utils::equalString($credentialType, "id_token")) { + $idToken = $credentialModel->securityToken; + $_request->headers["x-acs-zero-trust-idtoken"] = $idToken; + } else { + $accessKeyId = $credentialModel->accessKeyId; + $accessKeySecret = $credentialModel->accessKeySecret; + $securityToken = $credentialModel->securityToken; + if (!Utils::empty_($securityToken)) { + $_request->headers["x-acs-accesskey-id"] = $accessKeyId; + $_request->headers["x-acs-security-token"] = $securityToken; + } + $stringToSign = OpenApiUtilClient::getStringToSign($_request); + $_request->headers["authorization"] = "acs " . $accessKeyId . ":" . OpenApiUtilClient::getROASignature($stringToSign, $accessKeySecret) . ""; + } + } + $_lastRequest = $_request; + $_response = Tea::send($_request, $_runtime); + if (Utils::equalNumber($_response->statusCode, 204)) { + return [ + "headers" => $_response->headers + ]; + } + if (Utils::is4xx($_response->statusCode) || Utils::is5xx($_response->statusCode)) { + $_res = Utils::readAsJSON($_response->body); + $err = Utils::assertAsMap($_res); + $requestId = self::defaultAny(@$err["RequestId"], @$err["requestId"]); + $requestId = self::defaultAny($requestId, @$err["requestid"]); + @$err["statusCode"] = $_response->statusCode; + throw new TeaError([ + "code" => "" . (string) (self::defaultAny(@$err["Code"], @$err["code"])) . "", + "message" => "code: " . (string) ($_response->statusCode) . ", " . (string) (self::defaultAny(@$err["Message"], @$err["message"])) . " request id: " . (string) ($requestId) . "", + "data" => $err, + "description" => "" . (string) (self::defaultAny(@$err["Description"], @$err["description"])) . "", + "accessDeniedDetail" => self::defaultAny(@$err["AccessDeniedDetail"], @$err["accessDeniedDetail"]) + ]); + } + if (Utils::equalString($bodyType, "binary")) { + $resp = [ + "body" => $_response->body, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + return $resp; + } else if (Utils::equalString($bodyType, "byte")) { + $byt = Utils::readAsBytes($_response->body); + return [ + "body" => $byt, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "string")) { + $str = Utils::readAsString($_response->body); + return [ + "body" => $str, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "json")) { + $obj = Utils::readAsJSON($_response->body); + $res = Utils::assertAsMap($obj); + return [ + "body" => $res, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "array")) { + $arr = Utils::readAsJSON($_response->body); + return [ + "body" => $arr, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else { + return [ + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } + } catch (Exception $e) { + if (!($e instanceof TeaError)) { + $e = new TeaError([], $e->getMessage(), $e->getCode(), $e); + } + if (Tea::isRetryable($e)) { + $_lastException = $e; + continue; + } + throw $e; + } + } + throw new TeaUnableRetryError($_lastRequest, $_lastException); + } + + /** + * Encapsulate the request and invoke the network with form body + * @param string $action api name + * @param string $version product version + * @param string $protocol http or https + * @param string $method e.g. GET + * @param string $authType authorization type e.g. AK + * @param string $pathname pathname of every api + * @param string $bodyType response body type e.g. String + * @param OpenApiRequest $request object of OpenApiRequest + * @param RuntimeOptions $runtime which controls some details of call api, such as retry times + * @return array the response + * @throws TeaError + * @throws Exception + * @throws TeaUnableRetryError + */ + public function doROARequestWithForm($action, $version, $protocol, $method, $authType, $pathname, $bodyType, $request, $runtime) + { + $request->validate(); + $runtime->validate(); + $_runtime = [ + "timeouted" => "retry", + "key" => Utils::defaultString($runtime->key, $this->_key), + "cert" => Utils::defaultString($runtime->cert, $this->_cert), + "ca" => Utils::defaultString($runtime->ca, $this->_ca), + "readTimeout" => Utils::defaultNumber($runtime->readTimeout, $this->_readTimeout), + "connectTimeout" => Utils::defaultNumber($runtime->connectTimeout, $this->_connectTimeout), + "httpProxy" => Utils::defaultString($runtime->httpProxy, $this->_httpProxy), + "httpsProxy" => Utils::defaultString($runtime->httpsProxy, $this->_httpsProxy), + "noProxy" => Utils::defaultString($runtime->noProxy, $this->_noProxy), + "socks5Proxy" => Utils::defaultString($runtime->socks5Proxy, $this->_socks5Proxy), + "socks5NetWork" => Utils::defaultString($runtime->socks5NetWork, $this->_socks5NetWork), + "maxIdleConns" => Utils::defaultNumber($runtime->maxIdleConns, $this->_maxIdleConns), + "retry" => [ + "retryable" => $runtime->autoretry, + "maxAttempts" => Utils::defaultNumber($runtime->maxAttempts, 3) + ], + "backoff" => [ + "policy" => Utils::defaultString($runtime->backoffPolicy, "no"), + "period" => Utils::defaultNumber($runtime->backoffPeriod, 1) + ], + "ignoreSSL" => $runtime->ignoreSSL, + "tlsMinVersion" => $this->_tlsMinVersion + ]; + $_lastRequest = null; + $_lastException = null; + $_now = time(); + $_retryTimes = 0; + while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) { + if ($_retryTimes > 0) { + $_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes); + if ($_backoffTime > 0) { + Tea::sleep($_backoffTime); + } + } + $_retryTimes = $_retryTimes + 1; + try { + $_request = new Request(); + $_request->protocol = Utils::defaultString($this->_protocol, $protocol); + $_request->method = $method; + $_request->pathname = $pathname; + $globalQueries = []; + $globalHeaders = []; + if (!Utils::isUnset($this->_globalParameters)) { + $globalParams = $this->_globalParameters; + if (!Utils::isUnset($globalParams->queries)) { + $globalQueries = $globalParams->queries; + } + if (!Utils::isUnset($globalParams->headers)) { + $globalHeaders = $globalParams->headers; + } + } + $extendsHeaders = []; + $extendsQueries = []; + if (!Utils::isUnset($runtime->extendsParameters)) { + $extendsParameters = $runtime->extendsParameters; + if (!Utils::isUnset($extendsParameters->headers)) { + $extendsHeaders = $extendsParameters->headers; + } + if (!Utils::isUnset($extendsParameters->queries)) { + $extendsQueries = $extendsParameters->queries; + } + } + $_request->headers = Tea::merge([ + "date" => Utils::getDateUTCString(), + "host" => $this->_endpoint, + "accept" => "application/json", + "x-acs-signature-nonce" => Utils::getNonce(), + "x-acs-signature-method" => "HMAC-SHA1", + "x-acs-signature-version" => "1.0", + "x-acs-version" => $version, + "x-acs-action" => $action, + "user-agent" => Utils::getUserAgent($this->_userAgent) + ], $globalHeaders, $extendsHeaders, $request->headers); + if (!Utils::isUnset($request->body)) { + $m = Utils::assertAsMap($request->body); + $_request->body = OpenApiUtilClient::toForm($m); + $_request->headers["content-type"] = "application/x-www-form-urlencoded"; + } + $_request->query = Tea::merge($globalQueries, $extendsQueries); + if (!Utils::isUnset($request->query)) { + $_request->query = Tea::merge($_request->query, $request->query); + } + if (!Utils::equalString($authType, "Anonymous")) { + if (Utils::isUnset($this->_credential)) { + throw new TeaError([ + "code" => "InvalidCredentials", + "message" => "Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details." + ]); + } + $credentialModel = $this->_credential->getCredential(); + if (!Utils::empty_($credentialModel->providerName)) { + $_request->headers["x-acs-credentials-provider"] = $credentialModel->providerName; + } + $credentialType = $credentialModel->type; + if (Utils::equalString($credentialType, "bearer")) { + $bearerToken = $credentialModel->bearerToken; + $_request->headers["x-acs-bearer-token"] = $bearerToken; + $_request->headers["x-acs-signature-type"] = "BEARERTOKEN"; + } else if (Utils::equalString($credentialType, "id_token")) { + $idToken = $credentialModel->securityToken; + $_request->headers["x-acs-zero-trust-idtoken"] = $idToken; + } else { + $accessKeyId = $credentialModel->accessKeyId; + $accessKeySecret = $credentialModel->accessKeySecret; + $securityToken = $credentialModel->securityToken; + if (!Utils::empty_($securityToken)) { + $_request->headers["x-acs-accesskey-id"] = $accessKeyId; + $_request->headers["x-acs-security-token"] = $securityToken; + } + $stringToSign = OpenApiUtilClient::getStringToSign($_request); + $_request->headers["authorization"] = "acs " . $accessKeyId . ":" . OpenApiUtilClient::getROASignature($stringToSign, $accessKeySecret) . ""; + } + } + $_lastRequest = $_request; + $_response = Tea::send($_request, $_runtime); + if (Utils::equalNumber($_response->statusCode, 204)) { + return [ + "headers" => $_response->headers + ]; + } + if (Utils::is4xx($_response->statusCode) || Utils::is5xx($_response->statusCode)) { + $_res = Utils::readAsJSON($_response->body); + $err = Utils::assertAsMap($_res); + @$err["statusCode"] = $_response->statusCode; + throw new TeaError([ + "code" => "" . (string) (self::defaultAny(@$err["Code"], @$err["code"])) . "", + "message" => "code: " . (string) ($_response->statusCode) . ", " . (string) (self::defaultAny(@$err["Message"], @$err["message"])) . " request id: " . (string) (self::defaultAny(@$err["RequestId"], @$err["requestId"])) . "", + "data" => $err, + "description" => "" . (string) (self::defaultAny(@$err["Description"], @$err["description"])) . "", + "accessDeniedDetail" => self::defaultAny(@$err["AccessDeniedDetail"], @$err["accessDeniedDetail"]) + ]); + } + if (Utils::equalString($bodyType, "binary")) { + $resp = [ + "body" => $_response->body, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + return $resp; + } else if (Utils::equalString($bodyType, "byte")) { + $byt = Utils::readAsBytes($_response->body); + return [ + "body" => $byt, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "string")) { + $str = Utils::readAsString($_response->body); + return [ + "body" => $str, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "json")) { + $obj = Utils::readAsJSON($_response->body); + $res = Utils::assertAsMap($obj); + return [ + "body" => $res, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($bodyType, "array")) { + $arr = Utils::readAsJSON($_response->body); + return [ + "body" => $arr, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else { + return [ + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } + } catch (Exception $e) { + if (!($e instanceof TeaError)) { + $e = new TeaError([], $e->getMessage(), $e->getCode(), $e); + } + if (Tea::isRetryable($e)) { + $_lastException = $e; + continue; + } + throw $e; + } + } + throw new TeaUnableRetryError($_lastRequest, $_lastException); + } + + /** + * Encapsulate the request and invoke the network + * @param Params $params + * @param OpenApiRequest $request object of OpenApiRequest + * @param RuntimeOptions $runtime which controls some details of call api, such as retry times + * @return array the response + * @throws TeaError + * @throws Exception + * @throws TeaUnableRetryError + */ + public function doRequest($params, $request, $runtime) + { + $params->validate(); + $request->validate(); + $runtime->validate(); + $_runtime = [ + "timeouted" => "retry", + "key" => Utils::defaultString($runtime->key, $this->_key), + "cert" => Utils::defaultString($runtime->cert, $this->_cert), + "ca" => Utils::defaultString($runtime->ca, $this->_ca), + "readTimeout" => Utils::defaultNumber($runtime->readTimeout, $this->_readTimeout), + "connectTimeout" => Utils::defaultNumber($runtime->connectTimeout, $this->_connectTimeout), + "httpProxy" => Utils::defaultString($runtime->httpProxy, $this->_httpProxy), + "httpsProxy" => Utils::defaultString($runtime->httpsProxy, $this->_httpsProxy), + "noProxy" => Utils::defaultString($runtime->noProxy, $this->_noProxy), + "socks5Proxy" => Utils::defaultString($runtime->socks5Proxy, $this->_socks5Proxy), + "socks5NetWork" => Utils::defaultString($runtime->socks5NetWork, $this->_socks5NetWork), + "maxIdleConns" => Utils::defaultNumber($runtime->maxIdleConns, $this->_maxIdleConns), + "retry" => [ + "retryable" => $runtime->autoretry, + "maxAttempts" => Utils::defaultNumber($runtime->maxAttempts, 3) + ], + "backoff" => [ + "policy" => Utils::defaultString($runtime->backoffPolicy, "no"), + "period" => Utils::defaultNumber($runtime->backoffPeriod, 1) + ], + "ignoreSSL" => $runtime->ignoreSSL, + "tlsMinVersion" => $this->_tlsMinVersion + ]; + $_lastRequest = null; + $_lastException = null; + $_now = time(); + $_retryTimes = 0; + while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) { + if ($_retryTimes > 0) { + $_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes); + if ($_backoffTime > 0) { + Tea::sleep($_backoffTime); + } + } + $_retryTimes = $_retryTimes + 1; + try { + $_request = new Request(); + $_request->protocol = Utils::defaultString($this->_protocol, $params->protocol); + $_request->method = $params->method; + $_request->pathname = $params->pathname; + $globalQueries = []; + $globalHeaders = []; + if (!Utils::isUnset($this->_globalParameters)) { + $globalParams = $this->_globalParameters; + if (!Utils::isUnset($globalParams->queries)) { + $globalQueries = $globalParams->queries; + } + if (!Utils::isUnset($globalParams->headers)) { + $globalHeaders = $globalParams->headers; + } + } + $extendsHeaders = []; + $extendsQueries = []; + if (!Utils::isUnset($runtime->extendsParameters)) { + $extendsParameters = $runtime->extendsParameters; + if (!Utils::isUnset($extendsParameters->headers)) { + $extendsHeaders = $extendsParameters->headers; + } + if (!Utils::isUnset($extendsParameters->queries)) { + $extendsQueries = $extendsParameters->queries; + } + } + $_request->query = Tea::merge($globalQueries, $extendsQueries, $request->query); + // endpoint is setted in product client + $_request->headers = Tea::merge([ + "host" => $this->_endpoint, + "x-acs-version" => $params->version, + "x-acs-action" => $params->action, + "user-agent" => $this->getUserAgent(), + "x-acs-date" => OpenApiUtilClient::getTimestamp(), + "x-acs-signature-nonce" => Utils::getNonce(), + "accept" => "application/json" + ], $globalHeaders, $extendsHeaders, $request->headers); + if (Utils::equalString($params->style, "RPC")) { + $headers = $this->getRpcHeaders(); + if (!Utils::isUnset($headers)) { + $_request->headers = Tea::merge($_request->headers, $headers); + } + } + $signatureAlgorithm = Utils::defaultString($this->_signatureAlgorithm, "ACS3-HMAC-SHA256"); + $hashedRequestPayload = OpenApiUtilClient::hexEncode(OpenApiUtilClient::hash(Utils::toBytes(""), $signatureAlgorithm)); + if (!Utils::isUnset($request->stream)) { + $tmp = Utils::readAsBytes($request->stream); + $hashedRequestPayload = OpenApiUtilClient::hexEncode(OpenApiUtilClient::hash($tmp, $signatureAlgorithm)); + $_request->body = $tmp; + $_request->headers["content-type"] = "application/octet-stream"; + } else { + if (!Utils::isUnset($request->body)) { + if (Utils::equalString($params->reqBodyType, "byte")) { + $byteObj = Utils::assertAsBytes($request->body); + $hashedRequestPayload = OpenApiUtilClient::hexEncode(OpenApiUtilClient::hash($byteObj, $signatureAlgorithm)); + $_request->body = $byteObj; + } else if (Utils::equalString($params->reqBodyType, "json")) { + $jsonObj = Utils::toJSONString($request->body); + $hashedRequestPayload = OpenApiUtilClient::hexEncode(OpenApiUtilClient::hash(Utils::toBytes($jsonObj), $signatureAlgorithm)); + $_request->body = $jsonObj; + $_request->headers["content-type"] = "application/json; charset=utf-8"; + } else { + $m = Utils::assertAsMap($request->body); + $formObj = OpenApiUtilClient::toForm($m); + $hashedRequestPayload = OpenApiUtilClient::hexEncode(OpenApiUtilClient::hash(Utils::toBytes($formObj), $signatureAlgorithm)); + $_request->body = $formObj; + $_request->headers["content-type"] = "application/x-www-form-urlencoded"; + } + } + } + $_request->headers["x-acs-content-sha256"] = $hashedRequestPayload; + if (!Utils::equalString($params->authType, "Anonymous")) { + if (Utils::isUnset($this->_credential)) { + throw new TeaError([ + "code" => "InvalidCredentials", + "message" => "Please set up the credentials correctly. If you are setting them through environment variables, please ensure that ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET are set correctly. See https://help.aliyun.com/zh/sdk/developer-reference/configure-the-alibaba-cloud-accesskey-environment-variable-on-linux-macos-and-windows-systems for more details." + ]); + } + $credentialModel = $this->_credential->getCredential(); + if (!Utils::empty_($credentialModel->providerName)) { + $_request->headers["x-acs-credentials-provider"] = $credentialModel->providerName; + } + $authType = $credentialModel->type; + if (Utils::equalString($authType, "bearer")) { + $bearerToken = $credentialModel->bearerToken; + $_request->headers["x-acs-bearer-token"] = $bearerToken; + if (Utils::equalString($params->style, "RPC")) { + $_request->query["SignatureType"] = "BEARERTOKEN"; + } else { + $_request->headers["x-acs-signature-type"] = "BEARERTOKEN"; + } + } else if (Utils::equalString($authType, "id_token")) { + $idToken = $credentialModel->securityToken; + $_request->headers["x-acs-zero-trust-idtoken"] = $idToken; + } else { + $accessKeyId = $credentialModel->accessKeyId; + $accessKeySecret = $credentialModel->accessKeySecret; + $securityToken = $credentialModel->securityToken; + if (!Utils::empty_($securityToken)) { + $_request->headers["x-acs-accesskey-id"] = $accessKeyId; + $_request->headers["x-acs-security-token"] = $securityToken; + } + $_request->headers["Authorization"] = OpenApiUtilClient::getAuthorization($_request, $signatureAlgorithm, $hashedRequestPayload, $accessKeyId, $accessKeySecret); + } + } + $_lastRequest = $_request; + $_response = Tea::send($_request, $_runtime); + if (Utils::is4xx($_response->statusCode) || Utils::is5xx($_response->statusCode)) { + $err = []; + if (!Utils::isUnset(@$_response->headers["content-type"]) && Utils::equalString(@$_response->headers["content-type"], "text/xml;charset=utf-8")) { + $_str = Utils::readAsString($_response->body); + $respMap = XML::parseXml($_str, null); + $err = Utils::assertAsMap(@$respMap["Error"]); + } else { + $_res = Utils::readAsJSON($_response->body); + $err = Utils::assertAsMap($_res); + } + @$err["statusCode"] = $_response->statusCode; + throw new TeaError([ + "code" => "" . (string) (self::defaultAny(@$err["Code"], @$err["code"])) . "", + "message" => "code: " . (string) ($_response->statusCode) . ", " . (string) (self::defaultAny(@$err["Message"], @$err["message"])) . " request id: " . (string) (self::defaultAny(@$err["RequestId"], @$err["requestId"])) . "", + "data" => $err, + "description" => "" . (string) (self::defaultAny(@$err["Description"], @$err["description"])) . "", + "accessDeniedDetail" => self::defaultAny(@$err["AccessDeniedDetail"], @$err["accessDeniedDetail"]) + ]); + } + if (Utils::equalString($params->bodyType, "binary")) { + $resp = [ + "body" => $_response->body, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + return $resp; + } else if (Utils::equalString($params->bodyType, "byte")) { + $byt = Utils::readAsBytes($_response->body); + return [ + "body" => $byt, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($params->bodyType, "string")) { + $str = Utils::readAsString($_response->body); + return [ + "body" => $str, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($params->bodyType, "json")) { + $obj = Utils::readAsJSON($_response->body); + $res = Utils::assertAsMap($obj); + return [ + "body" => $res, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else if (Utils::equalString($params->bodyType, "array")) { + $arr = Utils::readAsJSON($_response->body); + return [ + "body" => $arr, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } else { + $anything = Utils::readAsString($_response->body); + return [ + "body" => $anything, + "headers" => $_response->headers, + "statusCode" => $_response->statusCode + ]; + } + } catch (Exception $e) { + if (!($e instanceof TeaError)) { + $e = new TeaError([], $e->getMessage(), $e->getCode(), $e); + } + if (Tea::isRetryable($e)) { + $_lastException = $e; + continue; + } + throw $e; + } + } + throw new TeaUnableRetryError($_lastRequest, $_lastException); + } + + /** + * Encapsulate the request and invoke the network + * @param Params $params + * @param OpenApiRequest $request object of OpenApiRequest + * @param RuntimeOptions $runtime which controls some details of call api, such as retry times + * @return array the response + * @throws TeaError + * @throws Exception + * @throws TeaUnableRetryError + */ + public function execute($params, $request, $runtime) + { + $params->validate(); + $request->validate(); + $runtime->validate(); + $_runtime = [ + "timeouted" => "retry", + "key" => Utils::defaultString($runtime->key, $this->_key), + "cert" => Utils::defaultString($runtime->cert, $this->_cert), + "ca" => Utils::defaultString($runtime->ca, $this->_ca), + "readTimeout" => Utils::defaultNumber($runtime->readTimeout, $this->_readTimeout), + "connectTimeout" => Utils::defaultNumber($runtime->connectTimeout, $this->_connectTimeout), + "httpProxy" => Utils::defaultString($runtime->httpProxy, $this->_httpProxy), + "httpsProxy" => Utils::defaultString($runtime->httpsProxy, $this->_httpsProxy), + "noProxy" => Utils::defaultString($runtime->noProxy, $this->_noProxy), + "socks5Proxy" => Utils::defaultString($runtime->socks5Proxy, $this->_socks5Proxy), + "socks5NetWork" => Utils::defaultString($runtime->socks5NetWork, $this->_socks5NetWork), + "maxIdleConns" => Utils::defaultNumber($runtime->maxIdleConns, $this->_maxIdleConns), + "retry" => [ + "retryable" => $runtime->autoretry, + "maxAttempts" => Utils::defaultNumber($runtime->maxAttempts, 3) + ], + "backoff" => [ + "policy" => Utils::defaultString($runtime->backoffPolicy, "no"), + "period" => Utils::defaultNumber($runtime->backoffPeriod, 1) + ], + "ignoreSSL" => $runtime->ignoreSSL, + "disableHttp2" => self::defaultAny($this->_disableHttp2, false), + "tlsMinVersion" => $this->_tlsMinVersion + ]; + $_lastRequest = null; + $_lastException = null; + $_now = time(); + $_retryTimes = 0; + while (Tea::allowRetry(@$_runtime["retry"], $_retryTimes, $_now)) { + if ($_retryTimes > 0) { + $_backoffTime = Tea::getBackoffTime(@$_runtime["backoff"], $_retryTimes); + if ($_backoffTime > 0) { + Tea::sleep($_backoffTime); + } + } + $_retryTimes = $_retryTimes + 1; + try { + $_request = new Request(); + // spi = new Gateway();//Gateway implements SPI,这一步在产品 SDK 中实例化 + $headers = $this->getRpcHeaders(); + $globalQueries = []; + $globalHeaders = []; + if (!Utils::isUnset($this->_globalParameters)) { + $globalParams = $this->_globalParameters; + if (!Utils::isUnset($globalParams->queries)) { + $globalQueries = $globalParams->queries; + } + if (!Utils::isUnset($globalParams->headers)) { + $globalHeaders = $globalParams->headers; + } + } + $extendsHeaders = []; + $extendsQueries = []; + if (!Utils::isUnset($runtime->extendsParameters)) { + $extendsParameters = $runtime->extendsParameters; + if (!Utils::isUnset($extendsParameters->headers)) { + $extendsHeaders = $extendsParameters->headers; + } + if (!Utils::isUnset($extendsParameters->queries)) { + $extendsQueries = $extendsParameters->queries; + } + } + $requestContext = new \Darabonba\GatewaySpi\Models\InterceptorContext\request([ + "headers" => Tea::merge($globalHeaders, $extendsHeaders, $request->headers, $headers), + "query" => Tea::merge($globalQueries, $extendsQueries, $request->query), + "body" => $request->body, + "stream" => $request->stream, + "hostMap" => $request->hostMap, + "pathname" => $params->pathname, + "productId" => $this->_productId, + "action" => $params->action, + "version" => $params->version, + "protocol" => Utils::defaultString($this->_protocol, $params->protocol), + "method" => Utils::defaultString($this->_method, $params->method), + "authType" => $params->authType, + "bodyType" => $params->bodyType, + "reqBodyType" => $params->reqBodyType, + "style" => $params->style, + "credential" => $this->_credential, + "signatureVersion" => $this->_signatureVersion, + "signatureAlgorithm" => $this->_signatureAlgorithm, + "userAgent" => $this->getUserAgent() + ]); + $configurationContext = new configuration([ + "regionId" => $this->_regionId, + "endpoint" => Utils::defaultString($request->endpointOverride, $this->_endpoint), + "endpointRule" => $this->_endpointRule, + "endpointMap" => $this->_endpointMap, + "endpointType" => $this->_endpointType, + "network" => $this->_network, + "suffix" => $this->_suffix + ]); + $interceptorContext = new InterceptorContext([ + "request" => $requestContext, + "configuration" => $configurationContext + ]); + $attributeMap = new AttributeMap([]); + // 1. spi.modifyConfiguration(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap); + $this->_spi->modifyConfiguration($interceptorContext, $attributeMap); + // 2. spi.modifyRequest(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap); + $this->_spi->modifyRequest($interceptorContext, $attributeMap); + $_request->protocol = $interceptorContext->request->protocol; + $_request->method = $interceptorContext->request->method; + $_request->pathname = $interceptorContext->request->pathname; + $_request->query = $interceptorContext->request->query; + $_request->body = $interceptorContext->request->stream; + $_request->headers = $interceptorContext->request->headers; + $_lastRequest = $_request; + $_response = Tea::send($_request, $_runtime); + $responseContext = new response([ + "statusCode" => $_response->statusCode, + "headers" => $_response->headers, + "body" => $_response->body + ]); + $interceptorContext->response = $responseContext; + // 3. spi.modifyResponse(context: SPI.InterceptorContext, attributeMap: SPI.AttributeMap); + $this->_spi->modifyResponse($interceptorContext, $attributeMap); + return [ + "headers" => $interceptorContext->response->headers, + "statusCode" => $interceptorContext->response->statusCode, + "body" => $interceptorContext->response->deserializedBody + ]; + } catch (Exception $e) { + if (!($e instanceof TeaError)) { + $e = new TeaError([], $e->getMessage(), $e->getCode(), $e); + } + if (Tea::isRetryable($e)) { + $_lastException = $e; + continue; + } + throw $e; + } + } + throw new TeaUnableRetryError($_lastRequest, $_lastException); + } + + /** + * @param Params $params + * @param OpenApiRequest $request + * @param RuntimeOptions $runtime + * @return array + * @throws TeaError + */ + public function callApi($params, $request, $runtime) + { + if (Utils::isUnset($params)) { + throw new TeaError([ + "code" => "ParameterMissing", + "message" => "'params' can not be unset" + ]); + } + if (Utils::isUnset($this->_signatureVersion) || !Utils::equalString($this->_signatureVersion, "v4")) { + if (Utils::isUnset($this->_signatureAlgorithm) || !Utils::equalString($this->_signatureAlgorithm, "v2")) { + return $this->doRequest($params, $request, $runtime); + } else if (Utils::equalString($params->style, "ROA") && Utils::equalString($params->reqBodyType, "json")) { + return $this->doROARequest($params->action, $params->version, $params->protocol, $params->method, $params->authType, $params->pathname, $params->bodyType, $request, $runtime); + } else if (Utils::equalString($params->style, "ROA")) { + return $this->doROARequestWithForm($params->action, $params->version, $params->protocol, $params->method, $params->authType, $params->pathname, $params->bodyType, $request, $runtime); + } else { + return $this->doRPCRequest($params->action, $params->version, $params->protocol, $params->method, $params->authType, $params->bodyType, $request, $runtime); + } + } else { + return $this->execute($params, $request, $runtime); + } + } + + /** + * Get user agent + * @return string user agent + */ + public function getUserAgent() + { + $userAgent = Utils::getUserAgent($this->_userAgent); + return $userAgent; + } + + /** + * Get accesskey id by using credential + * @return string accesskey id + */ + public function getAccessKeyId() + { + if (Utils::isUnset($this->_credential)) { + return ''; + } + $accessKeyId = $this->_credential->getAccessKeyId(); + return $accessKeyId; + } + + /** + * Get accesskey secret by using credential + * @return string accesskey secret + */ + public function getAccessKeySecret() + { + if (Utils::isUnset($this->_credential)) { + return ''; + } + $secret = $this->_credential->getAccessKeySecret(); + return $secret; + } + + /** + * Get security token by using credential + * @return string security token + */ + public function getSecurityToken() + { + if (Utils::isUnset($this->_credential)) { + return ''; + } + $token = $this->_credential->getSecurityToken(); + return $token; + } + + /** + * Get bearer token by credential + * @return string bearer token + */ + public function getBearerToken() + { + if (Utils::isUnset($this->_credential)) { + return ''; + } + $token = $this->_credential->getBearerToken(); + return $token; + } + + /** + * Get credential type by credential + * @return string credential type e.g. access_key + */ + public function getType() + { + if (Utils::isUnset($this->_credential)) { + return ''; + } + $authType = $this->_credential->getType(); + return $authType; + } + + /** + * If inputValue is not null, return it or return defaultValue + * @param mixed $inputValue users input value + * @param mixed $defaultValue default value + * @return any the final result + */ + public static function defaultAny($inputValue, $defaultValue) + { + if (Utils::isUnset($inputValue)) { + return $defaultValue; + } + return $inputValue; + } + + /** + * If the endpointRule and config.endpoint are empty, throw error + * @param \Darabonba\OpenApi\Models\Config $config config contains the necessary information to create a client + * @return void + * @throws TeaError + */ + public function checkConfig($config) + { + if (Utils::empty_($this->_endpointRule) && Utils::empty_($config->endpoint)) { + throw new TeaError([ + "code" => "ParameterMissing", + "message" => "'config.endpoint' can not be empty" + ]); + } + } + + /** + * set gateway client + * @param Client $spi + * @return void + */ + public function setGatewayClient($spi) + { + $this->_spi = $spi; + } + + /** + * set RPC header for debug + * @param string[] $headers headers for debug, this header can be used only once. + * @return void + */ + public function setRpcHeaders($headers) + { + $this->_headers = $headers; + } + + /** + * get RPC header for debug + * @return array + */ + public function getRpcHeaders() + { + $headers = $this->_headers; + $this->_headers = null; + return $headers; + } +} diff --git a/vendor/alibabacloud/darabonba-openapi/tests/OpenApiClientTest.php b/vendor/alibabacloud/darabonba-openapi/tests/OpenApiClientTest.php new file mode 100644 index 0000000..8d5d96e --- /dev/null +++ b/vendor/alibabacloud/darabonba-openapi/tests/OpenApiClientTest.php @@ -0,0 +1,329 @@ + [ + "global-key" => "global-value" + ], + "queries" => [ + "global-query" => "global-value" + ] + ]); + $config = new Config([ + "endpoint" => "config.endpoint", + "endpointType" => "regional", + "network" => "config.network", + "suffix" => "config.suffix", + "protocol" => "config.protocol", + "method" => "config.method", + "regionId" => "config.regionId", + "userAgent" => "config.userAgent", + "readTimeout" => 3000, + "connectTimeout" => 3000, + "httpProxy" => "config.httpProxy", + "httpsProxy" => "config.httpsProxy", + "noProxy" => "config.noProxy", + "socks5Proxy" => "config.socks5Proxy", + "socks5NetWork" => "config.socks5NetWork", + "maxIdleConns" => 128, + "signatureVersion" => "config.signatureVersion", + "signatureAlgorithm" => "config.signatureAlgorithm", + "globalParameters" => $globalParameters + ]); + $creConfig = new \AlibabaCloud\Credentials\Credential\Config([ + "accessKeyId" => "accessKeyId", + "accessKeySecret" => "accessKeySecret", + "securityToken" => "securityToken", + "type" => "sts" + ]); + $credential = new Credential($creConfig); + $config->credential = $credential; + $client = new OpenApiClient($config); + $config->accessKeyId = "ak"; + $config->accessKeySecret = "secret"; + $config->securityToken = "token"; + $config->type = "sts"; + $client = new OpenApiClient($config); + } + + /** + * @return Config + */ + public static function createConfig(){ + $globalParameters = new GlobalParameters([ + "headers" => [ + "global-key" => "global-value" + ], + "queries" => [ + "global-query" => "global-value" + ] + ]); + $config = new Config([ + "accessKeyId" => "ak", + "accessKeySecret" => "secret", + "securityToken" => "token", + "type" => "sts", + "userAgent" => "config.userAgent", + "readTimeout" => 3000, + "connectTimeout" => 3000, + "maxIdleConns" => 128, + "signatureVersion" => "config.signatureVersion", + "signatureAlgorithm" => "ACS3-HMAC-SHA256", + "globalParameters" => $globalParameters, + "tlsMinVersion" => "TLSv1.2" + ]); + return $config; + } + + /** + * @return RuntimeOptions + */ + public static function createRuntimeOptions(){ + $runtime = new RuntimeOptions([ + "readTimeout" => 4000, + "connectTimeout" => 4000, + "maxIdleConns" => 100, + "autoretry" => true, + "maxAttempts" => 1, + "backoffPolicy" => "no", + "backoffPeriod" => 1, + "ignoreSSL" => true + ]); + return $runtime; + } + + /** + * @return OpenApiRequest + */ + public static function createOpenApiRequest(){ + $query = []; + $query["key1"] = "value"; + $query["key2"] = 1; + $query["key3"] = true; + $body = []; + $body["key1"] = "value"; + $body["key2"] = 1; + $body["key3"] = true; + $headers = [ + "for-test" => "sdk" + ]; + $req = new OpenApiRequest([ + "headers" => $headers, + "query" => OpenApiUtilClient::query($query), + "body" => OpenApiUtilClient::parseToMap($body) + ]); + return $req; + } + + public function testCallApiForRPCWithV2Sign_AK_Form(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->signatureAlgorithm = "v2"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/", + "method" => "POST", + "authType" => "AK", + "style" => "RPC", + "reqBodyType" => "formData", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testCallApiForRPCWithV2Sign_Anonymous_JSON(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->signatureAlgorithm = "v2"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/", + "method" => "POST", + "authType" => "Anonymous", + "style" => "RPC", + "reqBodyType" => "json", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testCallApiForROAWithV2Sign_HTTPS_AK_Form(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->signatureAlgorithm = "v2"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/test", + "method" => "POST", + "authType" => "AK", + "style" => "ROA", + "reqBodyType" => "formData", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testCallApiForROAWithV2Sign_Anonymous_JSON(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->signatureAlgorithm = "v2"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/test", + "method" => "POST", + "authType" => "Anonymous", + "style" => "ROA", + "reqBodyType" => "json", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testCallApiForRPCWithV3Sign_AK_Form(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/", + "method" => "POST", + "authType" => "AK", + "style" => "RPC", + "reqBodyType" => "formData", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testCallApiForRPCWithV3Sign_Anonymous_JSON(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/", + "method" => "POST", + "authType" => "Anonymous", + "style" => "RPC", + "reqBodyType" => "json", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testCallApiForROAWithV3Sign_AK_Form(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/test", + "method" => "POST", + "authType" => "AK", + "style" => "ROA", + "reqBodyType" => "formData", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testCallApiForROAWithV3Sign_Anonymous_JSON(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/test", + "method" => "POST", + "authType" => "Anonymous", + "style" => "ROA", + "reqBodyType" => "json", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + } + + public function testResponseBodyType(){ + $config = self::createConfig(); + $runtime = self::createRuntimeOptions(); + $config->protocol = "HTTP"; + $config->endpoint = "test.aliyuncs.com"; + $client = new OpenApiClient($config); + $request = self::createOpenApiRequest(); + $params = new Params([ + "action" => "TestAPI", + "version" => "2022-06-01", + "protocol" => "HTTPS", + "pathname" => "/test", + "method" => "POST", + "authType" => "AK", + "style" => "ROA", + "reqBodyType" => "formData", + "bodyType" => "json" + ]); + $client->callApi($params, $request, $runtime); + $params->bodyType = "array"; + $client->callApi($params, $request, $runtime); + $params->bodyType = "string"; + $client->callApi($params, $request, $runtime); + $params->bodyType = "byte"; + $client->callApi($params, $request, $runtime); + } +} diff --git a/vendor/alibabacloud/darabonba-openapi/tests/bootstrap.php b/vendor/alibabacloud/darabonba-openapi/tests/bootstrap.php new file mode 100644 index 0000000..c62c4e8 --- /dev/null +++ b/vendor/alibabacloud/darabonba-openapi/tests/bootstrap.php @@ -0,0 +1,3 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/alibabacloud/dypnsapi-20170525/ChangeLog.md b/vendor/alibabacloud/dypnsapi-20170525/ChangeLog.md new file mode 100644 index 0000000..dfeea5d --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/ChangeLog.md @@ -0,0 +1,59 @@ +2024-10-24 Version: 1.1.3 +- Update API CreateVerifyScheme: add param HmAppIdentifier. +- Update API CreateVerifyScheme: add param HmPackageName. +- Update API CreateVerifyScheme: add param HmSignName. +- Update API GetAuthToken: add param BizType. +- Update API GetAuthToken: add param CmApiCode. +- Update API GetAuthToken: add param CtApiCode. +- Update API GetAuthToken: add param CuApiCode. +- Update API GetAuthToken: add param Version. + + +2024-10-18 Version: 1.1.3 +- Update API CreateVerifyScheme: add param HmAppIdentifier. +- Update API CreateVerifyScheme: add param HmPackageName. +- Update API CreateVerifyScheme: add param HmSignName. + + +2024-01-04 Version: 1.1.2 +- Generated php 2017-05-25 for Dypnsapi. + +2023-12-29 Version: 1.2.0 +- Generated php 2017-05-25 for Dypnsapi. + +2023-09-21 Version: 1.1.0 +- Generated php 2017-05-25 for Dypnsapi. + +2023-04-14 Version: 1.0.10 +- Supported Fusion Auth. + +2022-12-27 Version: 1.0.9 +- Support Sms Verification for Dypnsapi. + +2022-11-30 Version: 1.0.8 +- Support Sms Verification for Dypnsapi. + +2022-02-08 Version: 1.0.7 +- Supported New Features. + +2022-01-19 Version: 1.0.6 +- Supported New Features. + +2022-01-13 Version: 1.0.5 +- Supported New Features. + +2022-01-07 Version: 1.0.4 +- Supported New Features. + +2021-09-22 Version: 1.0.3 +- Support Sms Verification for Dypnsapi. + +2021-09-22 Version: 1.0.2 +- Support Sms Verification for Dypnsapi. + +2021-03-17 Version: 1.0.1 +- Generated php 2017-05-25 for Dypnsapi. + +2020-12-30 Version: 1.0.0 +- AMP Version Change. + diff --git a/vendor/alibabacloud/dypnsapi-20170525/LICENSE b/vendor/alibabacloud/dypnsapi-20170525/LICENSE new file mode 100644 index 0000000..0c44dce --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/alibabacloud/dypnsapi-20170525/README-CN.md b/vendor/alibabacloud/dypnsapi-20170525/README-CN.md new file mode 100644 index 0000000..e9bfe72 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/README-CN.md @@ -0,0 +1,35 @@ +[English](README.md) | 简体中文 + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +# Alibaba Cloud Dypnsapi SDK for PHP + +## 安装 + +### Composer + +```bash +composer require alibabacloud/dypnsapi-20170525 +``` + +## 问题 + +[提交 Issue](https://github.com/aliyun/alibabacloud-php-sdk/issues/new),不符合指南的问题可能会立即关闭。 + +## 使用说明 + +[快速使用](https://github.com/aliyun/alibabacloud-php-sdk/blob/master/docs/0-Examples-CN.md#%E5%BF%AB%E9%80%9F%E4%BD%BF%E7%94%A8) + +## 发行说明 + +每个版本的详细更改记录在[发行说明](./ChangeLog.txt)中。 + +## 相关 + +* [最新源码](https://github.com/aliyun/alibabacloud-php-sdk/) + +## 许可证 + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/alibabacloud/dypnsapi-20170525/README.md b/vendor/alibabacloud/dypnsapi-20170525/README.md new file mode 100644 index 0000000..f99bf5c --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/README.md @@ -0,0 +1,35 @@ +English | [简体中文](README-CN.md) + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +# Alibaba Cloud Dypnsapi SDK for PHP + +## Installation + +### Composer + +```bash +composer require alibabacloud/dypnsapi-20170525 +``` + +## Issues + +[Opening an Issue](https://github.com/aliyun/alibabacloud-php-sdk/issues/new), Issues not conforming to the guidelines may be closed immediately. + +## Usage + +[Quick Examples](https://github.com/aliyun/alibabacloud-php-sdk/blob/master/docs/0-Examples-EN.md#quick-examples) + +## Changelog + +Detailed changes for each release are documented in the [release notes](./ChangeLog.txt). + +## References + +* [Latest Release](https://github.com/aliyun/alibabacloud-php-sdk/) + +## License + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/alibabacloud/dypnsapi-20170525/autoload.php b/vendor/alibabacloud/dypnsapi-20170525/autoload.php new file mode 100644 index 0000000..cce9a41 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/autoload.php @@ -0,0 +1,17 @@ +5.5", + "alibabacloud/tea-utils": "^0.2.21", + "alibabacloud/darabonba-openapi": "^0.2.13", + "alibabacloud/openapi-util": "^0.1.10|^0.2.1", + "alibabacloud/endpoint-util": "^0.1.0" + }, + "autoload": { + "psr-4": { + "AlibabaCloud\\SDK\\Dypnsapi\\V20170525\\": "src" + } + }, + "scripts": { + "fixer": "php-cs-fixer fix ./" + }, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "optimize-autoloader": true + }, + "prefer-stable": true +} \ No newline at end of file diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Dypnsapi.php b/vendor/alibabacloud/dypnsapi-20170525/src/Dypnsapi.php new file mode 100644 index 0000000..d2ba137 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Dypnsapi.php @@ -0,0 +1,1658 @@ +_signatureAlgorithm = 'v2'; + $this->_endpointRule = 'central'; + $this->checkConfig($config); + $this->_endpoint = $this->getEndpoint('dypnsapi', $this->_regionId, $this->_endpointRule, $this->_network, $this->_suffix, $this->_endpointMap, $this->_endpoint); + } + + /** + * @param string $productId + * @param string $regionId + * @param string $endpointRule + * @param string $network + * @param string $suffix + * @param string[] $endpointMap + * @param string $endpoint + * + * @return string + */ + public function getEndpoint($productId, $regionId, $endpointRule, $network, $suffix, $endpointMap, $endpoint) + { + if (!Utils::empty_($endpoint)) { + return $endpoint; + } + if (!Utils::isUnset($endpointMap) && !Utils::empty_(@$endpointMap[$regionId])) { + return @$endpointMap[$regionId]; + } + + return Endpoint::getEndpointRules($productId, $regionId, $endpointRule, $network, $suffix); + } + + /** + * @summary Verifies SMS verification codes. + * * + * @param CheckSmsVerifyCodeRequest $request CheckSmsVerifyCodeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return CheckSmsVerifyCodeResponse CheckSmsVerifyCodeResponse + */ + public function checkSmsVerifyCodeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->caseAuthPolicy)) { + $query['CaseAuthPolicy'] = $request->caseAuthPolicy; + } + if (!Utils::isUnset($request->countryCode)) { + $query['CountryCode'] = $request->countryCode; + } + if (!Utils::isUnset($request->outId)) { + $query['OutId'] = $request->outId; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->phoneNumber)) { + $query['PhoneNumber'] = $request->phoneNumber; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->schemeName)) { + $query['SchemeName'] = $request->schemeName; + } + if (!Utils::isUnset($request->verifyCode)) { + $query['VerifyCode'] = $request->verifyCode; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'CheckSmsVerifyCode', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return CheckSmsVerifyCodeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Verifies SMS verification codes. + * * + * @param CheckSmsVerifyCodeRequest $request CheckSmsVerifyCodeRequest + * + * @return CheckSmsVerifyCodeResponse CheckSmsVerifyCodeResponse + */ + public function checkSmsVerifyCode($request) + { + $runtime = new RuntimeOptions([]); + + return $this->checkSmsVerifyCodeWithOptions($request, $runtime); + } + + /** + * @summary Creates a code for a converged communication authentication service. + * * + * @param CreateSchemeConfigRequest $request CreateSchemeConfigRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return CreateSchemeConfigResponse CreateSchemeConfigResponse + */ + public function createSchemeConfigWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->androidPackageName)) { + $query['AndroidPackageName'] = $request->androidPackageName; + } + if (!Utils::isUnset($request->androidPackageSign)) { + $query['AndroidPackageSign'] = $request->androidPackageSign; + } + if (!Utils::isUnset($request->appName)) { + $query['AppName'] = $request->appName; + } + if (!Utils::isUnset($request->h5Origin)) { + $query['H5Origin'] = $request->h5Origin; + } + if (!Utils::isUnset($request->h5Url)) { + $query['H5Url'] = $request->h5Url; + } + if (!Utils::isUnset($request->iosBundleId)) { + $query['IosBundleId'] = $request->iosBundleId; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->platform)) { + $query['Platform'] = $request->platform; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->schemeName)) { + $query['SchemeName'] = $request->schemeName; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'CreateSchemeConfig', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return CreateSchemeConfigResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Creates a code for a converged communication authentication service. + * * + * @param CreateSchemeConfigRequest $request CreateSchemeConfigRequest + * + * @return CreateSchemeConfigResponse CreateSchemeConfigResponse + */ + public function createSchemeConfig($request) + { + $runtime = new RuntimeOptions([]); + + return $this->createSchemeConfigWithOptions($request, $runtime); + } + + /** + * @summary Creates a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param CreateVerifySchemeRequest $request CreateVerifySchemeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return CreateVerifySchemeResponse CreateVerifySchemeResponse + */ + public function createVerifySchemeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->appName)) { + $query['AppName'] = $request->appName; + } + if (!Utils::isUnset($request->authType)) { + $query['AuthType'] = $request->authType; + } + if (!Utils::isUnset($request->bundleId)) { + $query['BundleId'] = $request->bundleId; + } + if (!Utils::isUnset($request->cmApiCode)) { + $query['CmApiCode'] = $request->cmApiCode; + } + if (!Utils::isUnset($request->ctApiCode)) { + $query['CtApiCode'] = $request->ctApiCode; + } + if (!Utils::isUnset($request->cuApiCode)) { + $query['CuApiCode'] = $request->cuApiCode; + } + if (!Utils::isUnset($request->email)) { + $query['Email'] = $request->email; + } + if (!Utils::isUnset($request->hmAppIdentifier)) { + $query['HmAppIdentifier'] = $request->hmAppIdentifier; + } + if (!Utils::isUnset($request->hmPackageName)) { + $query['HmPackageName'] = $request->hmPackageName; + } + if (!Utils::isUnset($request->hmSignName)) { + $query['HmSignName'] = $request->hmSignName; + } + if (!Utils::isUnset($request->ipWhiteList)) { + $query['IpWhiteList'] = $request->ipWhiteList; + } + if (!Utils::isUnset($request->origin)) { + $query['Origin'] = $request->origin; + } + if (!Utils::isUnset($request->osType)) { + $query['OsType'] = $request->osType; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->packName)) { + $query['PackName'] = $request->packName; + } + if (!Utils::isUnset($request->packSign)) { + $query['PackSign'] = $request->packSign; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->sceneType)) { + $query['SceneType'] = $request->sceneType; + } + if (!Utils::isUnset($request->schemeName)) { + $query['SchemeName'] = $request->schemeName; + } + if (!Utils::isUnset($request->smsSignName)) { + $query['SmsSignName'] = $request->smsSignName; + } + if (!Utils::isUnset($request->url)) { + $query['Url'] = $request->url; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'CreateVerifyScheme', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return CreateVerifySchemeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Creates a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param CreateVerifySchemeRequest $request CreateVerifySchemeRequest + * + * @return CreateVerifySchemeResponse CreateVerifySchemeResponse + */ + public function createVerifyScheme($request) + { + $runtime = new RuntimeOptions([]); + + return $this->createVerifySchemeWithOptions($request, $runtime); + } + + /** + * @summary Deletes a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param DeleteVerifySchemeRequest $request DeleteVerifySchemeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return DeleteVerifySchemeResponse DeleteVerifySchemeResponse + */ + public function deleteVerifySchemeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->customerId)) { + $query['CustomerId'] = $request->customerId; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->schemeCode)) { + $query['SchemeCode'] = $request->schemeCode; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'DeleteVerifyScheme', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return DeleteVerifySchemeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Deletes a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param DeleteVerifySchemeRequest $request DeleteVerifySchemeRequest + * + * @return DeleteVerifySchemeResponse DeleteVerifySchemeResponse + */ + public function deleteVerifyScheme($request) + { + $runtime = new RuntimeOptions([]); + + return $this->deleteVerifySchemeWithOptions($request, $runtime); + } + + /** + * @summary Queries the details of a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param DescribeVerifySchemeRequest $request DescribeVerifySchemeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return DescribeVerifySchemeResponse DescribeVerifySchemeResponse + */ + public function describeVerifySchemeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->customerId)) { + $query['CustomerId'] = $request->customerId; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->schemeCode)) { + $query['SchemeCode'] = $request->schemeCode; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'DescribeVerifyScheme', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return DescribeVerifySchemeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Queries the details of a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 100 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param DescribeVerifySchemeRequest $request DescribeVerifySchemeRequest + * + * @return DescribeVerifySchemeResponse DescribeVerifySchemeResponse + */ + public function describeVerifyScheme($request) + { + $runtime = new RuntimeOptions([]); + + return $this->describeVerifySchemeWithOptions($request, $runtime); + } + + /** + * @summary Obtains the authorization token used for the authentication of the phone number verification for HTML5 pages. You can obtain AccessToken and JwtToken after a successful call. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the phone number verification feature for HTML5 pages](https://help.aliyun.com/document_detail/169786.html). + * ### [](#qps)QPS limits + * You can call this operation up to 1,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetAuthTokenRequest $request GetAuthTokenRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return GetAuthTokenResponse GetAuthTokenResponse + */ + public function getAuthTokenWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->bizType)) { + $query['BizType'] = $request->bizType; + } + if (!Utils::isUnset($request->cmApiCode)) { + $query['CmApiCode'] = $request->cmApiCode; + } + if (!Utils::isUnset($request->ctApiCode)) { + $query['CtApiCode'] = $request->ctApiCode; + } + if (!Utils::isUnset($request->cuApiCode)) { + $query['CuApiCode'] = $request->cuApiCode; + } + if (!Utils::isUnset($request->origin)) { + $query['Origin'] = $request->origin; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->sceneCode)) { + $query['SceneCode'] = $request->sceneCode; + } + if (!Utils::isUnset($request->url)) { + $query['Url'] = $request->url; + } + if (!Utils::isUnset($request->version)) { + $query['Version'] = $request->version; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'GetAuthToken', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return GetAuthTokenResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Obtains the authorization token used for the authentication of the phone number verification for HTML5 pages. You can obtain AccessToken and JwtToken after a successful call. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the phone number verification feature for HTML5 pages](https://help.aliyun.com/document_detail/169786.html). + * ### [](#qps)QPS limits + * You can call this operation up to 1,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetAuthTokenRequest $request GetAuthTokenRequest + * + * @return GetAuthTokenResponse GetAuthTokenResponse + */ + public function getAuthToken($request) + { + $runtime = new RuntimeOptions([]); + + return $this->getAuthTokenWithOptions($request, $runtime); + } + + /** + * @summary Obtains the URL for the Alipay account authorization. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account and obtain an Alibaba Cloud AccessKey pair. For more information, see [Process of communication authorization](https://help.aliyun.com/document_detail/196922.html). + * ### [](#qps)QPS limits + * You can call this operation up to 1,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetAuthorizationUrlRequest $request GetAuthorizationUrlRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return GetAuthorizationUrlResponse GetAuthorizationUrlResponse + */ + public function getAuthorizationUrlWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->endDate)) { + $query['EndDate'] = $request->endDate; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->phoneNo)) { + $query['PhoneNo'] = $request->phoneNo; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->schemeId)) { + $query['SchemeId'] = $request->schemeId; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'GetAuthorizationUrl', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return GetAuthorizationUrlResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Obtains the URL for the Alipay account authorization. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account and obtain an Alibaba Cloud AccessKey pair. For more information, see [Process of communication authorization](https://help.aliyun.com/document_detail/196922.html). + * ### [](#qps)QPS limits + * You can call this operation up to 1,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetAuthorizationUrlRequest $request GetAuthorizationUrlRequest + * + * @return GetAuthorizationUrlResponse GetAuthorizationUrlResponse + */ + public function getAuthorizationUrl($request) + { + $runtime = new RuntimeOptions([]); + + return $this->getAuthorizationUrlWithOptions($request, $runtime); + } + + /** + * @summary Obtains the verification results by using the token that is obtained from the client SDKs. + * * + * @param GetFusionAuthTokenRequest $request GetFusionAuthTokenRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return GetFusionAuthTokenResponse GetFusionAuthTokenResponse + */ + public function getFusionAuthTokenWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->bundleId)) { + $query['BundleId'] = $request->bundleId; + } + if (!Utils::isUnset($request->durationSeconds)) { + $query['DurationSeconds'] = $request->durationSeconds; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->packageName)) { + $query['PackageName'] = $request->packageName; + } + if (!Utils::isUnset($request->packageSign)) { + $query['PackageSign'] = $request->packageSign; + } + if (!Utils::isUnset($request->platform)) { + $query['Platform'] = $request->platform; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->schemeCode)) { + $query['SchemeCode'] = $request->schemeCode; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'GetFusionAuthToken', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return GetFusionAuthTokenResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Obtains the verification results by using the token that is obtained from the client SDKs. + * * + * @param GetFusionAuthTokenRequest $request GetFusionAuthTokenRequest + * + * @return GetFusionAuthTokenResponse GetFusionAuthTokenResponse + */ + public function getFusionAuthToken($request) + { + $runtime = new RuntimeOptions([]); + + return $this->getFusionAuthTokenWithOptions($request, $runtime); + } + + /** + * @summary Obtains a phone number for one-click logon. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Getting Started](https://help.aliyun.com/document_detail/84541.html). + * > This operation is applicable only to one-click logon or registration. You can call this operation only after you confirm the authorization on the authorization page provided by the SDK for one-click logon. You are prohibited from simulating or bypassing the authorization process. Alibaba Cloud reserves the right to terminate our services and take legal actions against such violations. + * ### [](#qps)QPS limits + * You can call this operation up to 5,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetMobileRequest $request GetMobileRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return GetMobileResponse GetMobileResponse + */ + public function getMobileWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->accessToken)) { + $query['AccessToken'] = $request->accessToken; + } + if (!Utils::isUnset($request->outId)) { + $query['OutId'] = $request->outId; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'GetMobile', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return GetMobileResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Obtains a phone number for one-click logon. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Getting Started](https://help.aliyun.com/document_detail/84541.html). + * > This operation is applicable only to one-click logon or registration. You can call this operation only after you confirm the authorization on the authorization page provided by the SDK for one-click logon. You are prohibited from simulating or bypassing the authorization process. Alibaba Cloud reserves the right to terminate our services and take legal actions against such violations. + * ### [](#qps)QPS limits + * You can call this operation up to 5,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetMobileRequest $request GetMobileRequest + * + * @return GetMobileResponse GetMobileResponse + */ + public function getMobile($request) + { + $runtime = new RuntimeOptions([]); + + return $this->getMobileWithOptions($request, $runtime); + } + + /** + * @summary Obtains a phone number for one-click logon. This operation is exclusive to HTML5 pages. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Getting Started](https://help.aliyun.com/document_detail/84541.html). + * > This operation is applicable only to one-click logon or registration in HTML5 pages. You can call this operation only after you confirm the authorization on the authorization page provided by the JavaScript SDK. You are prohibited from simulating or bypassing the authorization process. Alibaba Cloud reserves the right to terminate our services and take legal actions against such violations. + * ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetPhoneWithTokenRequest $request GetPhoneWithTokenRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return GetPhoneWithTokenResponse GetPhoneWithTokenResponse + */ + public function getPhoneWithTokenWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->spToken)) { + $query['SpToken'] = $request->spToken; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'GetPhoneWithToken', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return GetPhoneWithTokenResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Obtains a phone number for one-click logon. This operation is exclusive to HTML5 pages. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Getting Started](https://help.aliyun.com/document_detail/84541.html). + * > This operation is applicable only to one-click logon or registration in HTML5 pages. You can call this operation only after you confirm the authorization on the authorization page provided by the JavaScript SDK. You are prohibited from simulating or bypassing the authorization process. Alibaba Cloud reserves the right to terminate our services and take legal actions against such violations. + * ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetPhoneWithTokenRequest $request GetPhoneWithTokenRequest + * + * @return GetPhoneWithTokenResponse GetPhoneWithTokenResponse + */ + public function getPhoneWithToken($request) + { + $runtime = new RuntimeOptions([]); + + return $this->getPhoneWithTokenWithOptions($request, $runtime); + } + + /** + * @summary Obtains the authorization token for an SMS verification code. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the SMS verification feature](https://help.aliyun.com/document_detail/313209.html). + * ### [](#qps)QPS limits + * You can call this operation up to 5,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetSmsAuthTokensRequest $request GetSmsAuthTokensRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return GetSmsAuthTokensResponse GetSmsAuthTokensResponse + */ + public function getSmsAuthTokensWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->bundleId)) { + $query['BundleId'] = $request->bundleId; + } + if (!Utils::isUnset($request->expire)) { + $query['Expire'] = $request->expire; + } + if (!Utils::isUnset($request->osType)) { + $query['OsType'] = $request->osType; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->packageName)) { + $query['PackageName'] = $request->packageName; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->sceneCode)) { + $query['SceneCode'] = $request->sceneCode; + } + if (!Utils::isUnset($request->signName)) { + $query['SignName'] = $request->signName; + } + if (!Utils::isUnset($request->smsCodeExpire)) { + $query['SmsCodeExpire'] = $request->smsCodeExpire; + } + if (!Utils::isUnset($request->smsTemplateCode)) { + $query['SmsTemplateCode'] = $request->smsTemplateCode; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'GetSmsAuthTokens', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return GetSmsAuthTokensResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Obtains the authorization token for an SMS verification code. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the SMS verification feature](https://help.aliyun.com/document_detail/313209.html). + * ### [](#qps)QPS limits + * You can call this operation up to 5,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param GetSmsAuthTokensRequest $request GetSmsAuthTokensRequest + * + * @return GetSmsAuthTokensResponse GetSmsAuthTokensResponse + */ + public function getSmsAuthTokens($request) + { + $runtime = new RuntimeOptions([]); + + return $this->getSmsAuthTokensWithOptions($request, $runtime); + } + + /** + * @deprecated openAPI JyCreateVerifyScheme is deprecated, please use Dypnsapi::2017-05-25::CreateVerifyScheme instead + * * + * @summary 创建方案号(为极意临时定制) + * * + * Deprecated + * + * @param JyCreateVerifySchemeRequest $request JyCreateVerifySchemeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return JyCreateVerifySchemeResponse JyCreateVerifySchemeResponse + */ + public function jyCreateVerifySchemeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->appName)) { + $query['AppName'] = $request->appName; + } + if (!Utils::isUnset($request->bundleId)) { + $query['BundleId'] = $request->bundleId; + } + if (!Utils::isUnset($request->cmApiCode)) { + $query['CmApiCode'] = $request->cmApiCode; + } + if (!Utils::isUnset($request->ctApiCode)) { + $query['CtApiCode'] = $request->ctApiCode; + } + if (!Utils::isUnset($request->cuApiCode)) { + $query['CuApiCode'] = $request->cuApiCode; + } + if (!Utils::isUnset($request->osType)) { + $query['OsType'] = $request->osType; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->packName)) { + $query['PackName'] = $request->packName; + } + if (!Utils::isUnset($request->packSign)) { + $query['PackSign'] = $request->packSign; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->schemeName)) { + $query['SchemeName'] = $request->schemeName; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'JyCreateVerifyScheme', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return JyCreateVerifySchemeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @deprecated openAPI JyCreateVerifyScheme is deprecated, please use Dypnsapi::2017-05-25::CreateVerifyScheme instead + * * + * @summary 创建方案号(为极意临时定制) + * * + * Deprecated + * + * @param JyCreateVerifySchemeRequest $request JyCreateVerifySchemeRequest + * + * @return JyCreateVerifySchemeResponse JyCreateVerifySchemeResponse + */ + public function jyCreateVerifyScheme($request) + { + $runtime = new RuntimeOptions([]); + + return $this->jyCreateVerifySchemeWithOptions($request, $runtime); + } + + /** + * @deprecated openAPI JyQueryAppInfoBySceneCode is deprecated, please use Dypnsapi::2017-05-25::QueryAppInfoBySceneCode instead + * * + * @summary 根据方案号查询运营商APP信(为极意临时定制) + * * + * Deprecated + * + * @param JyQueryAppInfoBySceneCodeRequest $request JyQueryAppInfoBySceneCodeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return JyQueryAppInfoBySceneCodeResponse JyQueryAppInfoBySceneCodeResponse + */ + public function jyQueryAppInfoBySceneCodeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->sceneCode)) { + $query['SceneCode'] = $request->sceneCode; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'JyQueryAppInfoBySceneCode', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return JyQueryAppInfoBySceneCodeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @deprecated openAPI JyQueryAppInfoBySceneCode is deprecated, please use Dypnsapi::2017-05-25::QueryAppInfoBySceneCode instead + * * + * @summary 根据方案号查询运营商APP信(为极意临时定制) + * * + * Deprecated + * + * @param JyQueryAppInfoBySceneCodeRequest $request JyQueryAppInfoBySceneCodeRequest + * + * @return JyQueryAppInfoBySceneCodeResponse JyQueryAppInfoBySceneCodeResponse + */ + public function jyQueryAppInfoBySceneCode($request) + { + $runtime = new RuntimeOptions([]); + + return $this->jyQueryAppInfoBySceneCodeWithOptions($request, $runtime); + } + + /** + * @summary Queries the fees generated by a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param QueryGateVerifyBillingPublicRequest $request QueryGateVerifyBillingPublicRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return QueryGateVerifyBillingPublicResponse QueryGateVerifyBillingPublicResponse + */ + public function queryGateVerifyBillingPublicWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->authenticationType)) { + $query['AuthenticationType'] = $request->authenticationType; + } + if (!Utils::isUnset($request->month)) { + $query['Month'] = $request->month; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'QueryGateVerifyBillingPublic', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return QueryGateVerifyBillingPublicResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Queries the fees generated by a verification service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param QueryGateVerifyBillingPublicRequest $request QueryGateVerifyBillingPublicRequest + * + * @return QueryGateVerifyBillingPublicResponse QueryGateVerifyBillingPublicResponse + */ + public function queryGateVerifyBillingPublic($request) + { + $runtime = new RuntimeOptions([]); + + return $this->queryGateVerifyBillingPublicWithOptions($request, $runtime); + } + + /** + * @summary Queries the calls of Phone Number Verification Service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param QueryGateVerifyStatisticPublicRequest $request QueryGateVerifyStatisticPublicRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return QueryGateVerifyStatisticPublicResponse QueryGateVerifyStatisticPublicResponse + */ + public function queryGateVerifyStatisticPublicWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->authenticationType)) { + $query['AuthenticationType'] = $request->authenticationType; + } + if (!Utils::isUnset($request->endDate)) { + $query['EndDate'] = $request->endDate; + } + if (!Utils::isUnset($request->osType)) { + $query['OsType'] = $request->osType; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->sceneCode)) { + $query['SceneCode'] = $request->sceneCode; + } + if (!Utils::isUnset($request->startDate)) { + $query['StartDate'] = $request->startDate; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'QueryGateVerifyStatisticPublic', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return QueryGateVerifyStatisticPublicResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Queries the calls of Phone Number Verification Service. + * * + * @description ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param QueryGateVerifyStatisticPublicRequest $request QueryGateVerifyStatisticPublicRequest + * + * @return QueryGateVerifyStatisticPublicResponse QueryGateVerifyStatisticPublicResponse + */ + public function queryGateVerifyStatisticPublic($request) + { + $runtime = new RuntimeOptions([]); + + return $this->queryGateVerifyStatisticPublicWithOptions($request, $runtime); + } + + /** + * @deprecated OpenAPI QuerySendDetails is deprecated + * * + * @summary Queries the delivery status of the SMS verification code. You can query only the delivery status of the SMS verification code that is sent by calling corresponding API operations. + * * + * Deprecated + * + * @param QuerySendDetailsRequest $request QuerySendDetailsRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return QuerySendDetailsResponse QuerySendDetailsResponse + */ + public function querySendDetailsWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->bizId)) { + $query['BizId'] = $request->bizId; + } + if (!Utils::isUnset($request->currentPage)) { + $query['CurrentPage'] = $request->currentPage; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->pageSize)) { + $query['PageSize'] = $request->pageSize; + } + if (!Utils::isUnset($request->phoneNumber)) { + $query['PhoneNumber'] = $request->phoneNumber; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->sendDate)) { + $query['SendDate'] = $request->sendDate; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'QuerySendDetails', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return QuerySendDetailsResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @deprecated OpenAPI QuerySendDetails is deprecated + * * + * @summary Queries the delivery status of the SMS verification code. You can query only the delivery status of the SMS verification code that is sent by calling corresponding API operations. + * * + * Deprecated + * + * @param QuerySendDetailsRequest $request QuerySendDetailsRequest + * + * @return QuerySendDetailsResponse QuerySendDetailsResponse + */ + public function querySendDetails($request) + { + $runtime = new RuntimeOptions([]); + + return $this->querySendDetailsWithOptions($request, $runtime); + } + + /** + * @summary Sends SMS verification codes. + * * + * @param SendSmsVerifyCodeRequest $request SendSmsVerifyCodeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return SendSmsVerifyCodeResponse SendSmsVerifyCodeResponse + */ + public function sendSmsVerifyCodeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->codeLength)) { + $query['CodeLength'] = $request->codeLength; + } + if (!Utils::isUnset($request->codeType)) { + $query['CodeType'] = $request->codeType; + } + if (!Utils::isUnset($request->countryCode)) { + $query['CountryCode'] = $request->countryCode; + } + if (!Utils::isUnset($request->duplicatePolicy)) { + $query['DuplicatePolicy'] = $request->duplicatePolicy; + } + if (!Utils::isUnset($request->interval)) { + $query['Interval'] = $request->interval; + } + if (!Utils::isUnset($request->outId)) { + $query['OutId'] = $request->outId; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->phoneNumber)) { + $query['PhoneNumber'] = $request->phoneNumber; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->returnVerifyCode)) { + $query['ReturnVerifyCode'] = $request->returnVerifyCode; + } + if (!Utils::isUnset($request->schemeName)) { + $query['SchemeName'] = $request->schemeName; + } + if (!Utils::isUnset($request->signName)) { + $query['SignName'] = $request->signName; + } + if (!Utils::isUnset($request->smsUpExtendCode)) { + $query['SmsUpExtendCode'] = $request->smsUpExtendCode; + } + if (!Utils::isUnset($request->templateCode)) { + $query['TemplateCode'] = $request->templateCode; + } + if (!Utils::isUnset($request->templateParam)) { + $query['TemplateParam'] = $request->templateParam; + } + if (!Utils::isUnset($request->validTime)) { + $query['ValidTime'] = $request->validTime; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'SendSmsVerifyCode', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return SendSmsVerifyCodeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Sends SMS verification codes. + * * + * @param SendSmsVerifyCodeRequest $request SendSmsVerifyCodeRequest + * + * @return SendSmsVerifyCodeResponse SendSmsVerifyCodeResponse + */ + public function sendSmsVerifyCode($request) + { + $runtime = new RuntimeOptions([]); + + return $this->sendSmsVerifyCodeWithOptions($request, $runtime); + } + + /** + * @summary Verifies the phone number that you use. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Getting Started](https://help.aliyun.com/document_detail/84541.html). + * > This operation is applicable to only the verification of thephone number that you use. To obtain a phone number for one-click logon, call [GetMobile](https://help.aliyun.com/document_detail/189865.html). + * ### [](#qps)QPS limits + * You can call this operation up to 5,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param VerifyMobileRequest $request VerifyMobileRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return VerifyMobileResponse VerifyMobileResponse + */ + public function verifyMobileWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->accessCode)) { + $query['AccessCode'] = $request->accessCode; + } + if (!Utils::isUnset($request->outId)) { + $query['OutId'] = $request->outId; + } + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->phoneNumber)) { + $query['PhoneNumber'] = $request->phoneNumber; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'VerifyMobile', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return VerifyMobileResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Verifies the phone number that you use. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Getting Started](https://help.aliyun.com/document_detail/84541.html). + * > This operation is applicable to only the verification of thephone number that you use. To obtain a phone number for one-click logon, call [GetMobile](https://help.aliyun.com/document_detail/189865.html). + * ### [](#qps)QPS limits + * You can call this operation up to 5,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param VerifyMobileRequest $request VerifyMobileRequest + * + * @return VerifyMobileResponse VerifyMobileResponse + */ + public function verifyMobile($request) + { + $runtime = new RuntimeOptions([]); + + return $this->verifyMobileWithOptions($request, $runtime); + } + + /** + * @summary Verifies the phone number used in HTML5 pages. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the phone number verification feature for HTML5 pages](https://help.aliyun.com/document_detail/169786.html). + * ### [](#qps)QPS limits + * You can call this operation up to 1,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param VerifyPhoneWithTokenRequest $request VerifyPhoneWithTokenRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return VerifyPhoneWithTokenResponse VerifyPhoneWithTokenResponse + */ + public function verifyPhoneWithTokenWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->phoneNumber)) { + $query['PhoneNumber'] = $request->phoneNumber; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->spToken)) { + $query['SpToken'] = $request->spToken; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'VerifyPhoneWithToken', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return VerifyPhoneWithTokenResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Verifies the phone number used in HTML5 pages. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the phone number verification feature for HTML5 pages](https://help.aliyun.com/document_detail/169786.html). + * ### [](#qps)QPS limits + * You can call this operation up to 1,000 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param VerifyPhoneWithTokenRequest $request VerifyPhoneWithTokenRequest + * + * @return VerifyPhoneWithTokenResponse VerifyPhoneWithTokenResponse + */ + public function verifyPhoneWithToken($request) + { + $runtime = new RuntimeOptions([]); + + return $this->verifyPhoneWithTokenWithOptions($request, $runtime); + } + + /** + * @summary Verifies SMS verification codes. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the SMS verification feature](https://help.aliyun.com/document_detail/313209.html). + * ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param VerifySmsCodeRequest $request VerifySmsCodeRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return VerifySmsCodeResponse VerifySmsCodeResponse + */ + public function verifySmsCodeWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->phoneNumber)) { + $query['PhoneNumber'] = $request->phoneNumber; + } + if (!Utils::isUnset($request->smsCode)) { + $query['SmsCode'] = $request->smsCode; + } + if (!Utils::isUnset($request->smsToken)) { + $query['SmsToken'] = $request->smsToken; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'VerifySmsCode', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return VerifySmsCodeResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Verifies SMS verification codes. + * * + * @description ### [](#)Preparations + * You must register an Alibaba Cloud account, obtain an Alibaba Cloud AccessKey pair, and create a verification service. For more information, see [Use the SMS verification feature](https://help.aliyun.com/document_detail/313209.html). + * ### [](#qps)QPS limits + * You can call this operation up to 500 times per second per account. If the number of calls per second exceeds the limit, throttling is triggered. As a result, your business may be affected. We recommend that you take note of the limit when you call this operation. + * * + * @param VerifySmsCodeRequest $request VerifySmsCodeRequest + * + * @return VerifySmsCodeResponse VerifySmsCodeResponse + */ + public function verifySmsCode($request) + { + $runtime = new RuntimeOptions([]); + + return $this->verifySmsCodeWithOptions($request, $runtime); + } + + /** + * @summary Obtains the verification results by using the verification token that is obtained by using the authentication token. + * * + * @param VerifyWithFusionAuthTokenRequest $request VerifyWithFusionAuthTokenRequest + * @param RuntimeOptions $runtime runtime options for this request RuntimeOptions + * + * @return VerifyWithFusionAuthTokenResponse VerifyWithFusionAuthTokenResponse + */ + public function verifyWithFusionAuthTokenWithOptions($request, $runtime) + { + Utils::validateModel($request); + $query = []; + if (!Utils::isUnset($request->ownerId)) { + $query['OwnerId'] = $request->ownerId; + } + if (!Utils::isUnset($request->resourceOwnerAccount)) { + $query['ResourceOwnerAccount'] = $request->resourceOwnerAccount; + } + if (!Utils::isUnset($request->resourceOwnerId)) { + $query['ResourceOwnerId'] = $request->resourceOwnerId; + } + if (!Utils::isUnset($request->verifyToken)) { + $query['VerifyToken'] = $request->verifyToken; + } + $req = new OpenApiRequest([ + 'query' => OpenApiUtilClient::query($query), + ]); + $params = new Params([ + 'action' => 'VerifyWithFusionAuthToken', + 'version' => '2017-05-25', + 'protocol' => 'HTTPS', + 'pathname' => '/', + 'method' => 'POST', + 'authType' => 'AK', + 'style' => 'RPC', + 'reqBodyType' => 'formData', + 'bodyType' => 'json', + ]); + + return VerifyWithFusionAuthTokenResponse::fromMap($this->callApi($params, $req, $runtime)); + } + + /** + * @summary Obtains the verification results by using the verification token that is obtained by using the authentication token. + * * + * @param VerifyWithFusionAuthTokenRequest $request VerifyWithFusionAuthTokenRequest + * + * @return VerifyWithFusionAuthTokenResponse VerifyWithFusionAuthTokenResponse + */ + public function verifyWithFusionAuthToken($request) + { + $runtime = new RuntimeOptions([]); + + return $this->verifyWithFusionAuthTokenWithOptions($request, $runtime); + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeRequest.php new file mode 100644 index 0000000..41437b0 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeRequest.php @@ -0,0 +1,172 @@ + 'CaseAuthPolicy', + 'countryCode' => 'CountryCode', + 'outId' => 'OutId', + 'ownerId' => 'OwnerId', + 'phoneNumber' => 'PhoneNumber', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'schemeName' => 'SchemeName', + 'verifyCode' => 'VerifyCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->caseAuthPolicy) { + $res['CaseAuthPolicy'] = $this->caseAuthPolicy; + } + if (null !== $this->countryCode) { + $res['CountryCode'] = $this->countryCode; + } + if (null !== $this->outId) { + $res['OutId'] = $this->outId; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->phoneNumber) { + $res['PhoneNumber'] = $this->phoneNumber; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->schemeName) { + $res['SchemeName'] = $this->schemeName; + } + if (null !== $this->verifyCode) { + $res['VerifyCode'] = $this->verifyCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return CheckSmsVerifyCodeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['CaseAuthPolicy'])) { + $model->caseAuthPolicy = $map['CaseAuthPolicy']; + } + if (isset($map['CountryCode'])) { + $model->countryCode = $map['CountryCode']; + } + if (isset($map['OutId'])) { + $model->outId = $map['OutId']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PhoneNumber'])) { + $model->phoneNumber = $map['PhoneNumber']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SchemeName'])) { + $model->schemeName = $map['SchemeName']; + } + if (isset($map['VerifyCode'])) { + $model->verifyCode = $map['VerifyCode']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponse.php new file mode 100644 index 0000000..0f2f7ff --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return CheckSmsVerifyCodeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = CheckSmsVerifyCodeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponseBody.php new file mode 100644 index 0000000..f993aeb --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponseBody.php @@ -0,0 +1,120 @@ + 'AccessDeniedDetail', + 'code' => 'Code', + 'message' => 'Message', + 'model' => 'Model', + 'success' => 'Success', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->accessDeniedDetail) { + $res['AccessDeniedDetail'] = $this->accessDeniedDetail; + } + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->model) { + $res['Model'] = null !== $this->model ? $this->model->toMap() : null; + } + if (null !== $this->success) { + $res['Success'] = $this->success; + } + + return $res; + } + + /** + * @param array $map + * + * @return CheckSmsVerifyCodeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AccessDeniedDetail'])) { + $model->accessDeniedDetail = $map['AccessDeniedDetail']; + } + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['Model'])) { + $model->model = model_::fromMap($map['Model']); + } + if (isset($map['Success'])) { + $model->success = $map['Success']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponseBody/model_.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponseBody/model_.php new file mode 100644 index 0000000..ceff045 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CheckSmsVerifyCodeResponseBody/model_.php @@ -0,0 +1,70 @@ + 'OutId', + 'verifyResult' => 'VerifyResult', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->outId) { + $res['OutId'] = $this->outId; + } + if (null !== $this->verifyResult) { + $res['VerifyResult'] = $this->verifyResult; + } + + return $res; + } + + /** + * @param array $map + * + * @return model_ + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['OutId'])) { + $model->outId = $map['OutId']; + } + if (isset($map['VerifyResult'])) { + $model->verifyResult = $map['VerifyResult']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigRequest.php new file mode 100644 index 0000000..9a4c08e --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigRequest.php @@ -0,0 +1,206 @@ + 'AndroidPackageName', + 'androidPackageSign' => 'AndroidPackageSign', + 'appName' => 'AppName', + 'h5Origin' => 'H5Origin', + 'h5Url' => 'H5Url', + 'iosBundleId' => 'IosBundleId', + 'ownerId' => 'OwnerId', + 'platform' => 'Platform', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'schemeName' => 'SchemeName', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->androidPackageName) { + $res['AndroidPackageName'] = $this->androidPackageName; + } + if (null !== $this->androidPackageSign) { + $res['AndroidPackageSign'] = $this->androidPackageSign; + } + if (null !== $this->appName) { + $res['AppName'] = $this->appName; + } + if (null !== $this->h5Origin) { + $res['H5Origin'] = $this->h5Origin; + } + if (null !== $this->h5Url) { + $res['H5Url'] = $this->h5Url; + } + if (null !== $this->iosBundleId) { + $res['IosBundleId'] = $this->iosBundleId; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->platform) { + $res['Platform'] = $this->platform; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->schemeName) { + $res['SchemeName'] = $this->schemeName; + } + + return $res; + } + + /** + * @param array $map + * + * @return CreateSchemeConfigRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AndroidPackageName'])) { + $model->androidPackageName = $map['AndroidPackageName']; + } + if (isset($map['AndroidPackageSign'])) { + $model->androidPackageSign = $map['AndroidPackageSign']; + } + if (isset($map['AppName'])) { + $model->appName = $map['AppName']; + } + if (isset($map['H5Origin'])) { + $model->h5Origin = $map['H5Origin']; + } + if (isset($map['H5Url'])) { + $model->h5Url = $map['H5Url']; + } + if (isset($map['IosBundleId'])) { + $model->iosBundleId = $map['IosBundleId']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['Platform'])) { + $model->platform = $map['Platform']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SchemeName'])) { + $model->schemeName = $map['SchemeName']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponse.php new file mode 100644 index 0000000..018528f --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return CreateSchemeConfigResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = CreateSchemeConfigResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponseBody.php new file mode 100644 index 0000000..7a24fb3 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponseBody.php @@ -0,0 +1,120 @@ + 'Code', + 'message' => 'Message', + 'model' => 'Model', + 'requestId' => 'RequestId', + 'success' => 'Success', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->model) { + $res['Model'] = null !== $this->model ? $this->model->toMap() : null; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->success) { + $res['Success'] = $this->success; + } + + return $res; + } + + /** + * @param array $map + * + * @return CreateSchemeConfigResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['Model'])) { + $model->model = model_::fromMap($map['Model']); + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['Success'])) { + $model->success = $map['Success']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponseBody/model_.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponseBody/model_.php new file mode 100644 index 0000000..07e3862 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateSchemeConfigResponseBody/model_.php @@ -0,0 +1,51 @@ + 'SchemeCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->schemeCode) { + $res['SchemeCode'] = $this->schemeCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return model_ + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['SchemeCode'])) { + $model->schemeCode = $map['SchemeCode']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeRequest.php new file mode 100644 index 0000000..6a7af9a --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeRequest.php @@ -0,0 +1,369 @@ + 'AppName', + 'authType' => 'AuthType', + 'bundleId' => 'BundleId', + 'cmApiCode' => 'CmApiCode', + 'ctApiCode' => 'CtApiCode', + 'cuApiCode' => 'CuApiCode', + 'email' => 'Email', + 'hmAppIdentifier' => 'HmAppIdentifier', + 'hmPackageName' => 'HmPackageName', + 'hmSignName' => 'HmSignName', + 'ipWhiteList' => 'IpWhiteList', + 'origin' => 'Origin', + 'osType' => 'OsType', + 'ownerId' => 'OwnerId', + 'packName' => 'PackName', + 'packSign' => 'PackSign', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'sceneType' => 'SceneType', + 'schemeName' => 'SchemeName', + 'smsSignName' => 'SmsSignName', + 'url' => 'Url', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->appName) { + $res['AppName'] = $this->appName; + } + if (null !== $this->authType) { + $res['AuthType'] = $this->authType; + } + if (null !== $this->bundleId) { + $res['BundleId'] = $this->bundleId; + } + if (null !== $this->cmApiCode) { + $res['CmApiCode'] = $this->cmApiCode; + } + if (null !== $this->ctApiCode) { + $res['CtApiCode'] = $this->ctApiCode; + } + if (null !== $this->cuApiCode) { + $res['CuApiCode'] = $this->cuApiCode; + } + if (null !== $this->email) { + $res['Email'] = $this->email; + } + if (null !== $this->hmAppIdentifier) { + $res['HmAppIdentifier'] = $this->hmAppIdentifier; + } + if (null !== $this->hmPackageName) { + $res['HmPackageName'] = $this->hmPackageName; + } + if (null !== $this->hmSignName) { + $res['HmSignName'] = $this->hmSignName; + } + if (null !== $this->ipWhiteList) { + $res['IpWhiteList'] = $this->ipWhiteList; + } + if (null !== $this->origin) { + $res['Origin'] = $this->origin; + } + if (null !== $this->osType) { + $res['OsType'] = $this->osType; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->packName) { + $res['PackName'] = $this->packName; + } + if (null !== $this->packSign) { + $res['PackSign'] = $this->packSign; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->sceneType) { + $res['SceneType'] = $this->sceneType; + } + if (null !== $this->schemeName) { + $res['SchemeName'] = $this->schemeName; + } + if (null !== $this->smsSignName) { + $res['SmsSignName'] = $this->smsSignName; + } + if (null !== $this->url) { + $res['Url'] = $this->url; + } + + return $res; + } + + /** + * @param array $map + * + * @return CreateVerifySchemeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AppName'])) { + $model->appName = $map['AppName']; + } + if (isset($map['AuthType'])) { + $model->authType = $map['AuthType']; + } + if (isset($map['BundleId'])) { + $model->bundleId = $map['BundleId']; + } + if (isset($map['CmApiCode'])) { + $model->cmApiCode = $map['CmApiCode']; + } + if (isset($map['CtApiCode'])) { + $model->ctApiCode = $map['CtApiCode']; + } + if (isset($map['CuApiCode'])) { + $model->cuApiCode = $map['CuApiCode']; + } + if (isset($map['Email'])) { + $model->email = $map['Email']; + } + if (isset($map['HmAppIdentifier'])) { + $model->hmAppIdentifier = $map['HmAppIdentifier']; + } + if (isset($map['HmPackageName'])) { + $model->hmPackageName = $map['HmPackageName']; + } + if (isset($map['HmSignName'])) { + $model->hmSignName = $map['HmSignName']; + } + if (isset($map['IpWhiteList'])) { + $model->ipWhiteList = $map['IpWhiteList']; + } + if (isset($map['Origin'])) { + $model->origin = $map['Origin']; + } + if (isset($map['OsType'])) { + $model->osType = $map['OsType']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PackName'])) { + $model->packName = $map['PackName']; + } + if (isset($map['PackSign'])) { + $model->packSign = $map['PackSign']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SceneType'])) { + $model->sceneType = $map['SceneType']; + } + if (isset($map['SchemeName'])) { + $model->schemeName = $map['SchemeName']; + } + if (isset($map['SmsSignName'])) { + $model->smsSignName = $map['SmsSignName']; + } + if (isset($map['Url'])) { + $model->url = $map['Url']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponse.php new file mode 100644 index 0000000..725d738 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return CreateVerifySchemeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = CreateVerifySchemeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponseBody.php new file mode 100644 index 0000000..2f0093e --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponseBody.php @@ -0,0 +1,136 @@ + 'Code', + 'gateVerifySchemeDTO' => 'GateVerifySchemeDTO', + 'httpStatusCode' => 'HttpStatusCode', + 'message' => 'Message', + 'requestId' => 'RequestId', + 'success' => 'Success', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->gateVerifySchemeDTO) { + $res['GateVerifySchemeDTO'] = null !== $this->gateVerifySchemeDTO ? $this->gateVerifySchemeDTO->toMap() : null; + } + if (null !== $this->httpStatusCode) { + $res['HttpStatusCode'] = $this->httpStatusCode; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->success) { + $res['Success'] = $this->success; + } + + return $res; + } + + /** + * @param array $map + * + * @return CreateVerifySchemeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['GateVerifySchemeDTO'])) { + $model->gateVerifySchemeDTO = gateVerifySchemeDTO::fromMap($map['GateVerifySchemeDTO']); + } + if (isset($map['HttpStatusCode'])) { + $model->httpStatusCode = $map['HttpStatusCode']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['Success'])) { + $model->success = $map['Success']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponseBody/gateVerifySchemeDTO.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponseBody/gateVerifySchemeDTO.php new file mode 100644 index 0000000..c21d043 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/CreateVerifySchemeResponseBody/gateVerifySchemeDTO.php @@ -0,0 +1,51 @@ + 'SchemeCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->schemeCode) { + $res['SchemeCode'] = $this->schemeCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return gateVerifySchemeDTO + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['SchemeCode'])) { + $model->schemeCode = $map['SchemeCode']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeRequest.php new file mode 100644 index 0000000..33a60b5 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeRequest.php @@ -0,0 +1,104 @@ + 'CustomerId', + 'ownerId' => 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'schemeCode' => 'SchemeCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->customerId) { + $res['CustomerId'] = $this->customerId; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->schemeCode) { + $res['SchemeCode'] = $this->schemeCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return DeleteVerifySchemeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['CustomerId'])) { + $model->customerId = $map['CustomerId']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SchemeCode'])) { + $model->schemeCode = $map['SchemeCode']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeResponse.php new file mode 100644 index 0000000..ccf321f --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return DeleteVerifySchemeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = DeleteVerifySchemeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeResponseBody.php new file mode 100644 index 0000000..49cc585 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/DeleteVerifySchemeResponseBody.php @@ -0,0 +1,102 @@ + 'Code', + 'message' => 'Message', + 'requestId' => 'RequestId', + 'result' => 'Result', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->result) { + $res['Result'] = $this->result; + } + + return $res; + } + + /** + * @param array $map + * + * @return DeleteVerifySchemeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['Result'])) { + $model->result = $map['Result']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeRequest.php new file mode 100644 index 0000000..4b14dcc --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeRequest.php @@ -0,0 +1,104 @@ + 'CustomerId', + 'ownerId' => 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'schemeCode' => 'SchemeCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->customerId) { + $res['CustomerId'] = $this->customerId; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->schemeCode) { + $res['SchemeCode'] = $this->schemeCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return DescribeVerifySchemeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['CustomerId'])) { + $model->customerId = $map['CustomerId']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SchemeCode'])) { + $model->schemeCode = $map['SchemeCode']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponse.php new file mode 100644 index 0000000..6ac0dac --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return DescribeVerifySchemeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = DescribeVerifySchemeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponseBody.php new file mode 100644 index 0000000..508750d --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponseBody.php @@ -0,0 +1,98 @@ + 'Code', + 'message' => 'Message', + 'requestId' => 'RequestId', + 'schemeQueryResultDTO' => 'SchemeQueryResultDTO', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->schemeQueryResultDTO) { + $res['SchemeQueryResultDTO'] = null !== $this->schemeQueryResultDTO ? $this->schemeQueryResultDTO->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return DescribeVerifySchemeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['SchemeQueryResultDTO'])) { + $model->schemeQueryResultDTO = schemeQueryResultDTO::fromMap($map['SchemeQueryResultDTO']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponseBody/schemeQueryResultDTO.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponseBody/schemeQueryResultDTO.php new file mode 100644 index 0000000..c29d1c8 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/DescribeVerifySchemeResponseBody/schemeQueryResultDTO.php @@ -0,0 +1,51 @@ + 'AppEncryptInfo', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->appEncryptInfo) { + $res['AppEncryptInfo'] = $this->appEncryptInfo; + } + + return $res; + } + + /** + * @param array $map + * + * @return schemeQueryResultDTO + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AppEncryptInfo'])) { + $model->appEncryptInfo = $map['AppEncryptInfo']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenRequest.php new file mode 100644 index 0000000..67c2080 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenRequest.php @@ -0,0 +1,177 @@ + 'BizType', + 'cmApiCode' => 'CmApiCode', + 'ctApiCode' => 'CtApiCode', + 'cuApiCode' => 'CuApiCode', + 'origin' => 'Origin', + 'ownerId' => 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'sceneCode' => 'SceneCode', + 'url' => 'Url', + 'version' => 'Version', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->bizType) { + $res['BizType'] = $this->bizType; + } + if (null !== $this->cmApiCode) { + $res['CmApiCode'] = $this->cmApiCode; + } + if (null !== $this->ctApiCode) { + $res['CtApiCode'] = $this->ctApiCode; + } + if (null !== $this->cuApiCode) { + $res['CuApiCode'] = $this->cuApiCode; + } + if (null !== $this->origin) { + $res['Origin'] = $this->origin; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->sceneCode) { + $res['SceneCode'] = $this->sceneCode; + } + if (null !== $this->url) { + $res['Url'] = $this->url; + } + if (null !== $this->version) { + $res['Version'] = $this->version; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetAuthTokenRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['BizType'])) { + $model->bizType = $map['BizType']; + } + if (isset($map['CmApiCode'])) { + $model->cmApiCode = $map['CmApiCode']; + } + if (isset($map['CtApiCode'])) { + $model->ctApiCode = $map['CtApiCode']; + } + if (isset($map['CuApiCode'])) { + $model->cuApiCode = $map['CuApiCode']; + } + if (isset($map['Origin'])) { + $model->origin = $map['Origin']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SceneCode'])) { + $model->sceneCode = $map['SceneCode']; + } + if (isset($map['Url'])) { + $model->url = $map['Url']; + } + if (isset($map['Version'])) { + $model->version = $map['Version']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponse.php new file mode 100644 index 0000000..c13f7b6 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetAuthTokenResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = GetAuthTokenResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponseBody.php new file mode 100644 index 0000000..8f5c756 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'message' => 'Message', + 'requestId' => 'RequestId', + 'tokenInfo' => 'TokenInfo', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->tokenInfo) { + $res['TokenInfo'] = null !== $this->tokenInfo ? $this->tokenInfo->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetAuthTokenResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['TokenInfo'])) { + $model->tokenInfo = tokenInfo::fromMap($map['TokenInfo']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponseBody/tokenInfo.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponseBody/tokenInfo.php new file mode 100644 index 0000000..bcfb7a5 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthTokenResponseBody/tokenInfo.php @@ -0,0 +1,69 @@ + AccessToken is valid for 10 minutes and can be used repeatedly within its validity period. + * @example agag**** + * + * @var string + */ + public $accessToken; + + /** + * @description The API authentication token. + * + * > JwtToken is valid for 1 hour and can be used repeatedly within its validity period. + * @example aweghd**** + * + * @var string + */ + public $jwtToken; + protected $_name = [ + 'accessToken' => 'AccessToken', + 'jwtToken' => 'JwtToken', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->accessToken) { + $res['AccessToken'] = $this->accessToken; + } + if (null !== $this->jwtToken) { + $res['JwtToken'] = $this->jwtToken; + } + + return $res; + } + + /** + * @param array $map + * + * @return tokenInfo + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AccessToken'])) { + $model->accessToken = $map['AccessToken']; + } + if (isset($map['JwtToken'])) { + $model->jwtToken = $map['JwtToken']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlRequest.php new file mode 100644 index 0000000..d5e1970 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlRequest.php @@ -0,0 +1,121 @@ + 'EndDate', + 'ownerId' => 'OwnerId', + 'phoneNo' => 'PhoneNo', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'schemeId' => 'SchemeId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->endDate) { + $res['EndDate'] = $this->endDate; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->phoneNo) { + $res['PhoneNo'] = $this->phoneNo; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->schemeId) { + $res['SchemeId'] = $this->schemeId; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetAuthorizationUrlRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['EndDate'])) { + $model->endDate = $map['EndDate']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PhoneNo'])) { + $model->phoneNo = $map['PhoneNo']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SchemeId'])) { + $model->schemeId = $map['SchemeId']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponse.php new file mode 100644 index 0000000..59a31a6 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetAuthorizationUrlResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = GetAuthorizationUrlResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponseBody.php new file mode 100644 index 0000000..d362074 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'data' => 'Data', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->data) { + $res['Data'] = null !== $this->data ? $this->data->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetAuthorizationUrlResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Data'])) { + $model->data = data::fromMap($map['Data']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponseBody/data.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponseBody/data.php new file mode 100644 index 0000000..510f022 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetAuthorizationUrlResponseBody/data.php @@ -0,0 +1,51 @@ + 'AuthorizationUrl', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->authorizationUrl) { + $res['AuthorizationUrl'] = $this->authorizationUrl; + } + + return $res; + } + + /** + * @param array $map + * + * @return data + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AuthorizationUrl'])) { + $model->authorizationUrl = $map['AuthorizationUrl']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenRequest.php new file mode 100644 index 0000000..29db913 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenRequest.php @@ -0,0 +1,170 @@ + 'BundleId', + 'durationSeconds' => 'DurationSeconds', + 'ownerId' => 'OwnerId', + 'packageName' => 'PackageName', + 'packageSign' => 'PackageSign', + 'platform' => 'Platform', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'schemeCode' => 'SchemeCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->bundleId) { + $res['BundleId'] = $this->bundleId; + } + if (null !== $this->durationSeconds) { + $res['DurationSeconds'] = $this->durationSeconds; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->packageName) { + $res['PackageName'] = $this->packageName; + } + if (null !== $this->packageSign) { + $res['PackageSign'] = $this->packageSign; + } + if (null !== $this->platform) { + $res['Platform'] = $this->platform; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->schemeCode) { + $res['SchemeCode'] = $this->schemeCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetFusionAuthTokenRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['BundleId'])) { + $model->bundleId = $map['BundleId']; + } + if (isset($map['DurationSeconds'])) { + $model->durationSeconds = $map['DurationSeconds']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PackageName'])) { + $model->packageName = $map['PackageName']; + } + if (isset($map['PackageSign'])) { + $model->packageSign = $map['PackageSign']; + } + if (isset($map['Platform'])) { + $model->platform = $map['Platform']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SchemeCode'])) { + $model->schemeCode = $map['SchemeCode']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenResponse.php new file mode 100644 index 0000000..5bebaa4 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetFusionAuthTokenResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = GetFusionAuthTokenResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenResponseBody.php new file mode 100644 index 0000000..5e64389 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetFusionAuthTokenResponseBody.php @@ -0,0 +1,115 @@ + 'Code', + 'message' => 'Message', + 'model' => 'Model', + 'requestId' => 'RequestId', + 'success' => 'Success', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->model) { + $res['Model'] = $this->model; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->success) { + $res['Success'] = $this->success; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetFusionAuthTokenResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['Model'])) { + $model->model = $map['Model']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['Success'])) { + $model->success = $map['Success']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileRequest.php new file mode 100644 index 0000000..5504b03 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileRequest.php @@ -0,0 +1,104 @@ + 'AccessToken', + 'outId' => 'OutId', + 'ownerId' => 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->accessToken) { + $res['AccessToken'] = $this->accessToken; + } + if (null !== $this->outId) { + $res['OutId'] = $this->outId; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetMobileRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AccessToken'])) { + $model->accessToken = $map['AccessToken']; + } + if (isset($map['OutId'])) { + $model->outId = $map['OutId']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponse.php new file mode 100644 index 0000000..c30cc63 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetMobileResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = GetMobileResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponseBody.php new file mode 100644 index 0000000..20e2b0a --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'getMobileResultDTO' => 'GetMobileResultDTO', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->getMobileResultDTO) { + $res['GetMobileResultDTO'] = null !== $this->getMobileResultDTO ? $this->getMobileResultDTO->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetMobileResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['GetMobileResultDTO'])) { + $model->getMobileResultDTO = getMobileResultDTO::fromMap($map['GetMobileResultDTO']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponseBody/getMobileResultDTO.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponseBody/getMobileResultDTO.php new file mode 100644 index 0000000..b7eaeea --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetMobileResponseBody/getMobileResultDTO.php @@ -0,0 +1,51 @@ + 'Mobile', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->mobile) { + $res['Mobile'] = $this->mobile; + } + + return $res; + } + + /** + * @param array $map + * + * @return getMobileResultDTO + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Mobile'])) { + $model->mobile = $map['Mobile']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenRequest.php new file mode 100644 index 0000000..707c134 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenRequest.php @@ -0,0 +1,88 @@ + 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'spToken' => 'SpToken', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->spToken) { + $res['SpToken'] = $this->spToken; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetPhoneWithTokenRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SpToken'])) { + $model->spToken = $map['SpToken']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponse.php new file mode 100644 index 0000000..00a335d --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetPhoneWithTokenResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = GetPhoneWithTokenResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponseBody.php new file mode 100644 index 0000000..5fe75eb --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'data' => 'Data', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->data) { + $res['Data'] = null !== $this->data ? $this->data->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetPhoneWithTokenResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Data'])) { + $model->data = data::fromMap($map['Data']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponseBody/data.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponseBody/data.php new file mode 100644 index 0000000..77c5f4e --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetPhoneWithTokenResponseBody/data.php @@ -0,0 +1,51 @@ + 'Mobile', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->mobile) { + $res['Mobile'] = $this->mobile; + } + + return $res; + } + + /** + * @param array $map + * + * @return data + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Mobile'])) { + $model->mobile = $map['Mobile']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensRequest.php new file mode 100644 index 0000000..9315787 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensRequest.php @@ -0,0 +1,203 @@ + 'BundleId', + 'expire' => 'Expire', + 'osType' => 'OsType', + 'ownerId' => 'OwnerId', + 'packageName' => 'PackageName', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'sceneCode' => 'SceneCode', + 'signName' => 'SignName', + 'smsCodeExpire' => 'SmsCodeExpire', + 'smsTemplateCode' => 'SmsTemplateCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->bundleId) { + $res['BundleId'] = $this->bundleId; + } + if (null !== $this->expire) { + $res['Expire'] = $this->expire; + } + if (null !== $this->osType) { + $res['OsType'] = $this->osType; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->packageName) { + $res['PackageName'] = $this->packageName; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->sceneCode) { + $res['SceneCode'] = $this->sceneCode; + } + if (null !== $this->signName) { + $res['SignName'] = $this->signName; + } + if (null !== $this->smsCodeExpire) { + $res['SmsCodeExpire'] = $this->smsCodeExpire; + } + if (null !== $this->smsTemplateCode) { + $res['SmsTemplateCode'] = $this->smsTemplateCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetSmsAuthTokensRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['BundleId'])) { + $model->bundleId = $map['BundleId']; + } + if (isset($map['Expire'])) { + $model->expire = $map['Expire']; + } + if (isset($map['OsType'])) { + $model->osType = $map['OsType']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PackageName'])) { + $model->packageName = $map['PackageName']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SceneCode'])) { + $model->sceneCode = $map['SceneCode']; + } + if (isset($map['SignName'])) { + $model->signName = $map['SignName']; + } + if (isset($map['SmsCodeExpire'])) { + $model->smsCodeExpire = $map['SmsCodeExpire']; + } + if (isset($map['SmsTemplateCode'])) { + $model->smsTemplateCode = $map['SmsTemplateCode']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponse.php new file mode 100644 index 0000000..2001f88 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetSmsAuthTokensResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = GetSmsAuthTokensResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponseBody.php new file mode 100644 index 0000000..cf0583c --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'data' => 'Data', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->data) { + $res['Data'] = null !== $this->data ? $this->data->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return GetSmsAuthTokensResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Data'])) { + $model->data = data::fromMap($map['Data']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponseBody/data.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponseBody/data.php new file mode 100644 index 0000000..8d9b339 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/GetSmsAuthTokensResponseBody/data.php @@ -0,0 +1,115 @@ + 'BizToken', + 'expireTime' => 'ExpireTime', + 'stsAccessKeyId' => 'StsAccessKeyId', + 'stsAccessKeySecret' => 'StsAccessKeySecret', + 'stsToken' => 'StsToken', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->bizToken) { + $res['BizToken'] = $this->bizToken; + } + if (null !== $this->expireTime) { + $res['ExpireTime'] = $this->expireTime; + } + if (null !== $this->stsAccessKeyId) { + $res['StsAccessKeyId'] = $this->stsAccessKeyId; + } + if (null !== $this->stsAccessKeySecret) { + $res['StsAccessKeySecret'] = $this->stsAccessKeySecret; + } + if (null !== $this->stsToken) { + $res['StsToken'] = $this->stsToken; + } + + return $res; + } + + /** + * @param array $map + * + * @return data + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['BizToken'])) { + $model->bizToken = $map['BizToken']; + } + if (isset($map['ExpireTime'])) { + $model->expireTime = $map['ExpireTime']; + } + if (isset($map['StsAccessKeyId'])) { + $model->stsAccessKeyId = $map['StsAccessKeyId']; + } + if (isset($map['StsAccessKeySecret'])) { + $model->stsAccessKeySecret = $map['StsAccessKeySecret']; + } + if (isset($map['StsToken'])) { + $model->stsToken = $map['StsToken']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeRequest.php new file mode 100644 index 0000000..77a2cb4 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeRequest.php @@ -0,0 +1,191 @@ + 'AppName', + 'bundleId' => 'BundleId', + 'cmApiCode' => 'CmApiCode', + 'ctApiCode' => 'CtApiCode', + 'cuApiCode' => 'CuApiCode', + 'osType' => 'OsType', + 'ownerId' => 'OwnerId', + 'packName' => 'PackName', + 'packSign' => 'PackSign', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'schemeName' => 'SchemeName', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->appName) { + $res['AppName'] = $this->appName; + } + if (null !== $this->bundleId) { + $res['BundleId'] = $this->bundleId; + } + if (null !== $this->cmApiCode) { + $res['CmApiCode'] = $this->cmApiCode; + } + if (null !== $this->ctApiCode) { + $res['CtApiCode'] = $this->ctApiCode; + } + if (null !== $this->cuApiCode) { + $res['CuApiCode'] = $this->cuApiCode; + } + if (null !== $this->osType) { + $res['OsType'] = $this->osType; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->packName) { + $res['PackName'] = $this->packName; + } + if (null !== $this->packSign) { + $res['PackSign'] = $this->packSign; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->schemeName) { + $res['SchemeName'] = $this->schemeName; + } + + return $res; + } + + /** + * @param array $map + * + * @return JyCreateVerifySchemeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AppName'])) { + $model->appName = $map['AppName']; + } + if (isset($map['BundleId'])) { + $model->bundleId = $map['BundleId']; + } + if (isset($map['CmApiCode'])) { + $model->cmApiCode = $map['CmApiCode']; + } + if (isset($map['CtApiCode'])) { + $model->ctApiCode = $map['CtApiCode']; + } + if (isset($map['CuApiCode'])) { + $model->cuApiCode = $map['CuApiCode']; + } + if (isset($map['OsType'])) { + $model->osType = $map['OsType']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PackName'])) { + $model->packName = $map['PackName']; + } + if (isset($map['PackSign'])) { + $model->packSign = $map['PackSign']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SchemeName'])) { + $model->schemeName = $map['SchemeName']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponse.php new file mode 100644 index 0000000..552897b --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return JyCreateVerifySchemeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = JyCreateVerifySchemeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponseBody.php new file mode 100644 index 0000000..543e9b0 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponseBody.php @@ -0,0 +1,84 @@ + 'Code', + 'gateVerifySchemeData' => 'GateVerifySchemeData', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->gateVerifySchemeData) { + $res['GateVerifySchemeData'] = null !== $this->gateVerifySchemeData ? $this->gateVerifySchemeData->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return JyCreateVerifySchemeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['GateVerifySchemeData'])) { + $model->gateVerifySchemeData = gateVerifySchemeData::fromMap($map['GateVerifySchemeData']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponseBody/gateVerifySchemeData.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponseBody/gateVerifySchemeData.php new file mode 100644 index 0000000..d1ce6d9 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyCreateVerifySchemeResponseBody/gateVerifySchemeData.php @@ -0,0 +1,47 @@ + 'SchemeCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->schemeCode) { + $res['SchemeCode'] = $this->schemeCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return gateVerifySchemeData + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['SchemeCode'])) { + $model->schemeCode = $map['SchemeCode']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeRequest.php new file mode 100644 index 0000000..99040eb --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeRequest.php @@ -0,0 +1,85 @@ + 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'sceneCode' => 'SceneCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->sceneCode) { + $res['SceneCode'] = $this->sceneCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return JyQueryAppInfoBySceneCodeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SceneCode'])) { + $model->sceneCode = $map['SceneCode']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponse.php new file mode 100644 index 0000000..a9ef016 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return JyQueryAppInfoBySceneCodeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = JyQueryAppInfoBySceneCodeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponseBody.php new file mode 100644 index 0000000..d1cd1be --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponseBody.php @@ -0,0 +1,84 @@ + 'Code', + 'data' => 'Data', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->data) { + $res['Data'] = null !== $this->data ? $this->data->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return JyQueryAppInfoBySceneCodeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Data'])) { + $model->data = data::fromMap($map['Data']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponseBody/data.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponseBody/data.php new file mode 100644 index 0000000..92beda1 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/JyQueryAppInfoBySceneCodeResponseBody/data.php @@ -0,0 +1,83 @@ + 'CmAppId', + 'cmAppKey' => 'CmAppKey', + 'ctAppId' => 'CtAppId', + 'ctAppKey' => 'CtAppKey', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->cmAppId) { + $res['CmAppId'] = $this->cmAppId; + } + if (null !== $this->cmAppKey) { + $res['CmAppKey'] = $this->cmAppKey; + } + if (null !== $this->ctAppId) { + $res['CtAppId'] = $this->ctAppId; + } + if (null !== $this->ctAppKey) { + $res['CtAppKey'] = $this->ctAppKey; + } + + return $res; + } + + /** + * @param array $map + * + * @return data + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['CmAppId'])) { + $model->cmAppId = $map['CmAppId']; + } + if (isset($map['CmAppKey'])) { + $model->cmAppKey = $map['CmAppKey']; + } + if (isset($map['CtAppId'])) { + $model->ctAppId = $map['CtAppId']; + } + if (isset($map['CtAppKey'])) { + $model->ctAppKey = $map['CtAppKey']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicRequest.php new file mode 100644 index 0000000..d1b76ac --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicRequest.php @@ -0,0 +1,99 @@ + 'AuthenticationType', + 'month' => 'Month', + 'ownerId' => 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->authenticationType) { + $res['AuthenticationType'] = $this->authenticationType; + } + if (null !== $this->month) { + $res['Month'] = $this->month; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + + return $res; + } + + /** + * @param array $map + * + * @return QueryGateVerifyBillingPublicRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AuthenticationType'])) { + $model->authenticationType = $map['AuthenticationType']; + } + if (isset($map['Month'])) { + $model->month = $map['Month']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponse.php new file mode 100644 index 0000000..59777f8 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return QueryGateVerifyBillingPublicResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = QueryGateVerifyBillingPublicResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody.php new file mode 100644 index 0000000..37a039c --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'data' => 'Data', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->data) { + $res['Data'] = null !== $this->data ? $this->data->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return QueryGateVerifyBillingPublicResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Data'])) { + $model->data = data::fromMap($map['Data']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody/data.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody/data.php new file mode 100644 index 0000000..742a8c6 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody/data.php @@ -0,0 +1,78 @@ + 'AmountSum', + 'sceneBillingList' => 'SceneBillingList', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->amountSum) { + $res['AmountSum'] = $this->amountSum; + } + if (null !== $this->sceneBillingList) { + $res['SceneBillingList'] = []; + if (null !== $this->sceneBillingList && \is_array($this->sceneBillingList)) { + $n = 0; + foreach ($this->sceneBillingList as $item) { + $res['SceneBillingList'][$n++] = null !== $item ? $item->toMap() : $item; + } + } + } + + return $res; + } + + /** + * @param array $map + * + * @return data + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AmountSum'])) { + $model->amountSum = $map['AmountSum']; + } + if (isset($map['SceneBillingList'])) { + if (!empty($map['SceneBillingList'])) { + $model->sceneBillingList = []; + $n = 0; + foreach ($map['SceneBillingList'] as $item) { + $model->sceneBillingList[$n++] = null !== $item ? sceneBillingList::fromMap($item) : $item; + } + } + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody/data/sceneBillingList.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody/data/sceneBillingList.php new file mode 100644 index 0000000..09246f5 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyBillingPublicResponseBody/data/sceneBillingList.php @@ -0,0 +1,147 @@ + 'Add', + 'amount' => 'Amount', + 'appName' => 'AppName', + 'itemName' => 'ItemName', + 'sceneCode' => 'SceneCode', + 'sceneName' => 'SceneName', + 'singlePrice' => 'SinglePrice', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->add) { + $res['Add'] = $this->add; + } + if (null !== $this->amount) { + $res['Amount'] = $this->amount; + } + if (null !== $this->appName) { + $res['AppName'] = $this->appName; + } + if (null !== $this->itemName) { + $res['ItemName'] = $this->itemName; + } + if (null !== $this->sceneCode) { + $res['SceneCode'] = $this->sceneCode; + } + if (null !== $this->sceneName) { + $res['SceneName'] = $this->sceneName; + } + if (null !== $this->singlePrice) { + $res['SinglePrice'] = $this->singlePrice; + } + + return $res; + } + + /** + * @param array $map + * + * @return sceneBillingList + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Add'])) { + $model->add = $map['Add']; + } + if (isset($map['Amount'])) { + $model->amount = $map['Amount']; + } + if (isset($map['AppName'])) { + $model->appName = $map['AppName']; + } + if (isset($map['ItemName'])) { + $model->itemName = $map['ItemName']; + } + if (isset($map['SceneCode'])) { + $model->sceneCode = $map['SceneCode']; + } + if (isset($map['SceneName'])) { + $model->sceneName = $map['SceneName']; + } + if (isset($map['SinglePrice'])) { + $model->singlePrice = $map['SinglePrice']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicRequest.php new file mode 100644 index 0000000..ef8c682 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicRequest.php @@ -0,0 +1,150 @@ + 'AuthenticationType', + 'endDate' => 'EndDate', + 'osType' => 'OsType', + 'ownerId' => 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'sceneCode' => 'SceneCode', + 'startDate' => 'StartDate', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->authenticationType) { + $res['AuthenticationType'] = $this->authenticationType; + } + if (null !== $this->endDate) { + $res['EndDate'] = $this->endDate; + } + if (null !== $this->osType) { + $res['OsType'] = $this->osType; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->sceneCode) { + $res['SceneCode'] = $this->sceneCode; + } + if (null !== $this->startDate) { + $res['StartDate'] = $this->startDate; + } + + return $res; + } + + /** + * @param array $map + * + * @return QueryGateVerifyStatisticPublicRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AuthenticationType'])) { + $model->authenticationType = $map['AuthenticationType']; + } + if (isset($map['EndDate'])) { + $model->endDate = $map['EndDate']; + } + if (isset($map['OsType'])) { + $model->osType = $map['OsType']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['SceneCode'])) { + $model->sceneCode = $map['SceneCode']; + } + if (isset($map['StartDate'])) { + $model->startDate = $map['StartDate']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponse.php new file mode 100644 index 0000000..cbc64c5 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return QueryGateVerifyStatisticPublicResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = QueryGateVerifyStatisticPublicResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody.php new file mode 100644 index 0000000..6c5d425 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'data' => 'Data', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->data) { + $res['Data'] = null !== $this->data ? $this->data->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return QueryGateVerifyStatisticPublicResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Data'])) { + $model->data = data::fromMap($map['Data']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody/data.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody/data.php new file mode 100644 index 0000000..e6975a9 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody/data.php @@ -0,0 +1,126 @@ + 'DayStatistic', + 'total' => 'Total', + 'totalFail' => 'TotalFail', + 'totalSuccess' => 'TotalSuccess', + 'totalUnknown' => 'TotalUnknown', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->dayStatistic) { + $res['DayStatistic'] = []; + if (null !== $this->dayStatistic && \is_array($this->dayStatistic)) { + $n = 0; + foreach ($this->dayStatistic as $item) { + $res['DayStatistic'][$n++] = null !== $item ? $item->toMap() : $item; + } + } + } + if (null !== $this->total) { + $res['Total'] = $this->total; + } + if (null !== $this->totalFail) { + $res['TotalFail'] = $this->totalFail; + } + if (null !== $this->totalSuccess) { + $res['TotalSuccess'] = $this->totalSuccess; + } + if (null !== $this->totalUnknown) { + $res['TotalUnknown'] = $this->totalUnknown; + } + + return $res; + } + + /** + * @param array $map + * + * @return data + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['DayStatistic'])) { + if (!empty($map['DayStatistic'])) { + $model->dayStatistic = []; + $n = 0; + foreach ($map['DayStatistic'] as $item) { + $model->dayStatistic[$n++] = null !== $item ? dayStatistic::fromMap($item) : $item; + } + } + } + if (isset($map['Total'])) { + $model->total = $map['Total']; + } + if (isset($map['TotalFail'])) { + $model->totalFail = $map['TotalFail']; + } + if (isset($map['TotalSuccess'])) { + $model->totalSuccess = $map['TotalSuccess']; + } + if (isset($map['TotalUnknown'])) { + $model->totalUnknown = $map['TotalUnknown']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody/data/dayStatistic.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody/data/dayStatistic.php new file mode 100644 index 0000000..a7f407b --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QueryGateVerifyStatisticPublicResponseBody/data/dayStatistic.php @@ -0,0 +1,99 @@ + 'StatisticDateStr', + 'totalFail' => 'TotalFail', + 'totalSuccess' => 'TotalSuccess', + 'totalUnknown' => 'TotalUnknown', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->statisticDateStr) { + $res['StatisticDateStr'] = $this->statisticDateStr; + } + if (null !== $this->totalFail) { + $res['TotalFail'] = $this->totalFail; + } + if (null !== $this->totalSuccess) { + $res['TotalSuccess'] = $this->totalSuccess; + } + if (null !== $this->totalUnknown) { + $res['TotalUnknown'] = $this->totalUnknown; + } + + return $res; + } + + /** + * @param array $map + * + * @return dayStatistic + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['StatisticDateStr'])) { + $model->statisticDateStr = $map['StatisticDateStr']; + } + if (isset($map['TotalFail'])) { + $model->totalFail = $map['TotalFail']; + } + if (isset($map['TotalSuccess'])) { + $model->totalSuccess = $map['TotalSuccess']; + } + if (isset($map['TotalUnknown'])) { + $model->totalUnknown = $map['TotalUnknown']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsRequest.php new file mode 100644 index 0000000..ccc2049 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsRequest.php @@ -0,0 +1,155 @@ + 'BizId', + 'currentPage' => 'CurrentPage', + 'ownerId' => 'OwnerId', + 'pageSize' => 'PageSize', + 'phoneNumber' => 'PhoneNumber', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'sendDate' => 'SendDate', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->bizId) { + $res['BizId'] = $this->bizId; + } + if (null !== $this->currentPage) { + $res['CurrentPage'] = $this->currentPage; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->pageSize) { + $res['PageSize'] = $this->pageSize; + } + if (null !== $this->phoneNumber) { + $res['PhoneNumber'] = $this->phoneNumber; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->sendDate) { + $res['SendDate'] = $this->sendDate; + } + + return $res; + } + + /** + * @param array $map + * + * @return QuerySendDetailsRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['BizId'])) { + $model->bizId = $map['BizId']; + } + if (isset($map['CurrentPage'])) { + $model->currentPage = $map['CurrentPage']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PageSize'])) { + $model->pageSize = $map['PageSize']; + } + if (isset($map['PhoneNumber'])) { + $model->phoneNumber = $map['PhoneNumber']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SendDate'])) { + $model->sendDate = $map['SendDate']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponse.php new file mode 100644 index 0000000..7fc1a8d --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return QuerySendDetailsResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = QuerySendDetailsResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponseBody.php new file mode 100644 index 0000000..6a1445b --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponseBody.php @@ -0,0 +1,146 @@ + 'AccessDeniedDetail', + 'code' => 'Code', + 'message' => 'Message', + 'model' => 'Model', + 'success' => 'Success', + 'totalCount' => 'TotalCount', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->accessDeniedDetail) { + $res['AccessDeniedDetail'] = $this->accessDeniedDetail; + } + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->model) { + $res['Model'] = []; + if (null !== $this->model && \is_array($this->model)) { + $n = 0; + foreach ($this->model as $item) { + $res['Model'][$n++] = null !== $item ? $item->toMap() : $item; + } + } + } + if (null !== $this->success) { + $res['Success'] = $this->success; + } + if (null !== $this->totalCount) { + $res['TotalCount'] = $this->totalCount; + } + + return $res; + } + + /** + * @param array $map + * + * @return QuerySendDetailsResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AccessDeniedDetail'])) { + $model->accessDeniedDetail = $map['AccessDeniedDetail']; + } + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['Model'])) { + if (!empty($map['Model'])) { + $model->model = []; + $n = 0; + foreach ($map['Model'] as $item) { + $model->model[$n++] = null !== $item ? model_::fromMap($item) : $item; + } + } + } + if (isset($map['Success'])) { + $model->success = $map['Success']; + } + if (isset($map['TotalCount'])) { + $model->totalCount = $map['TotalCount']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponseBody/model_.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponseBody/model_.php new file mode 100644 index 0000000..c83148f --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/QuerySendDetailsResponseBody/model_.php @@ -0,0 +1,174 @@ + The text message templates must be created on the Go Globe page and approved. + * @example SMS_12231**** + * + * @var string + */ + public $templateCode; + protected $_name = [ + 'content' => 'Content', + 'errCode' => 'ErrCode', + 'outId' => 'OutId', + 'phoneNum' => 'PhoneNum', + 'receiveDate' => 'ReceiveDate', + 'sendDate' => 'SendDate', + 'sendStatus' => 'SendStatus', + 'templateCode' => 'TemplateCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->content) { + $res['Content'] = $this->content; + } + if (null !== $this->errCode) { + $res['ErrCode'] = $this->errCode; + } + if (null !== $this->outId) { + $res['OutId'] = $this->outId; + } + if (null !== $this->phoneNum) { + $res['PhoneNum'] = $this->phoneNum; + } + if (null !== $this->receiveDate) { + $res['ReceiveDate'] = $this->receiveDate; + } + if (null !== $this->sendDate) { + $res['SendDate'] = $this->sendDate; + } + if (null !== $this->sendStatus) { + $res['SendStatus'] = $this->sendStatus; + } + if (null !== $this->templateCode) { + $res['TemplateCode'] = $this->templateCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return model_ + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Content'])) { + $model->content = $map['Content']; + } + if (isset($map['ErrCode'])) { + $model->errCode = $map['ErrCode']; + } + if (isset($map['OutId'])) { + $model->outId = $map['OutId']; + } + if (isset($map['PhoneNum'])) { + $model->phoneNum = $map['PhoneNum']; + } + if (isset($map['ReceiveDate'])) { + $model->receiveDate = $map['ReceiveDate']; + } + if (isset($map['SendDate'])) { + $model->sendDate = $map['SendDate']; + } + if (isset($map['SendStatus'])) { + $model->sendStatus = $map['SendStatus']; + } + if (isset($map['TemplateCode'])) { + $model->templateCode = $map['TemplateCode']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeRequest.php new file mode 100644 index 0000000..601a65d --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeRequest.php @@ -0,0 +1,322 @@ + The extension code is automatically generated by the system when the signature is generated. You do not need to specify the extension code. You can skip this parameter based on your business requirements. If you want to use custom extension codes, contact your account manager. + * @example 1213123 + * + * @var string + */ + public $smsUpExtendCode; + + /** + * @description The code of the text message template. + * + * Log on to the [SMS console](https://dysms.console.aliyun.com/dysms.htm?spm=5176.12818093.categories-n-products.ddysms.3b2816d0xml2NA#/overview). In the left-side navigation pane, click **Go China** or **Go Globe**. You can view the text message template code in the **Template Code** column on the **Message Templates** tab. + * + * This parameter is required. + * @example azsq_***** + * + * @var string + */ + public $templateCode; + + /** + * @description The value of the variable in the text message template. The verification code is replaced with "##code##". + * + * > + * + * If line breaks are required in JSON-formatted data, they must meet the relevant requirements that are specified in the standard JSON protocol. + * + * For more information about template variables, see [SMS template specifications](https://help.aliyun.com/document_detail/108253.html). + * + * This parameter is required. + * @example {"code":"##code##"} + * + * @var string + */ + public $templateParam; + + /** + * @description The validity period of the verification code. Unit: seconds. Default value: 300. + * + * @example 300 + * + * @var int + */ + public $validTime; + protected $_name = [ + 'codeLength' => 'CodeLength', + 'codeType' => 'CodeType', + 'countryCode' => 'CountryCode', + 'duplicatePolicy' => 'DuplicatePolicy', + 'interval' => 'Interval', + 'outId' => 'OutId', + 'ownerId' => 'OwnerId', + 'phoneNumber' => 'PhoneNumber', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'returnVerifyCode' => 'ReturnVerifyCode', + 'schemeName' => 'SchemeName', + 'signName' => 'SignName', + 'smsUpExtendCode' => 'SmsUpExtendCode', + 'templateCode' => 'TemplateCode', + 'templateParam' => 'TemplateParam', + 'validTime' => 'ValidTime', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->codeLength) { + $res['CodeLength'] = $this->codeLength; + } + if (null !== $this->codeType) { + $res['CodeType'] = $this->codeType; + } + if (null !== $this->countryCode) { + $res['CountryCode'] = $this->countryCode; + } + if (null !== $this->duplicatePolicy) { + $res['DuplicatePolicy'] = $this->duplicatePolicy; + } + if (null !== $this->interval) { + $res['Interval'] = $this->interval; + } + if (null !== $this->outId) { + $res['OutId'] = $this->outId; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->phoneNumber) { + $res['PhoneNumber'] = $this->phoneNumber; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->returnVerifyCode) { + $res['ReturnVerifyCode'] = $this->returnVerifyCode; + } + if (null !== $this->schemeName) { + $res['SchemeName'] = $this->schemeName; + } + if (null !== $this->signName) { + $res['SignName'] = $this->signName; + } + if (null !== $this->smsUpExtendCode) { + $res['SmsUpExtendCode'] = $this->smsUpExtendCode; + } + if (null !== $this->templateCode) { + $res['TemplateCode'] = $this->templateCode; + } + if (null !== $this->templateParam) { + $res['TemplateParam'] = $this->templateParam; + } + if (null !== $this->validTime) { + $res['ValidTime'] = $this->validTime; + } + + return $res; + } + + /** + * @param array $map + * + * @return SendSmsVerifyCodeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['CodeLength'])) { + $model->codeLength = $map['CodeLength']; + } + if (isset($map['CodeType'])) { + $model->codeType = $map['CodeType']; + } + if (isset($map['CountryCode'])) { + $model->countryCode = $map['CountryCode']; + } + if (isset($map['DuplicatePolicy'])) { + $model->duplicatePolicy = $map['DuplicatePolicy']; + } + if (isset($map['Interval'])) { + $model->interval = $map['Interval']; + } + if (isset($map['OutId'])) { + $model->outId = $map['OutId']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PhoneNumber'])) { + $model->phoneNumber = $map['PhoneNumber']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['ReturnVerifyCode'])) { + $model->returnVerifyCode = $map['ReturnVerifyCode']; + } + if (isset($map['SchemeName'])) { + $model->schemeName = $map['SchemeName']; + } + if (isset($map['SignName'])) { + $model->signName = $map['SignName']; + } + if (isset($map['SmsUpExtendCode'])) { + $model->smsUpExtendCode = $map['SmsUpExtendCode']; + } + if (isset($map['TemplateCode'])) { + $model->templateCode = $map['TemplateCode']; + } + if (isset($map['TemplateParam'])) { + $model->templateParam = $map['TemplateParam']; + } + if (isset($map['ValidTime'])) { + $model->validTime = $map['ValidTime']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponse.php new file mode 100644 index 0000000..101d426 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return SendSmsVerifyCodeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = SendSmsVerifyCodeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponseBody.php new file mode 100644 index 0000000..c84b361 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponseBody.php @@ -0,0 +1,117 @@ + 'AccessDeniedDetail', + 'code' => 'Code', + 'message' => 'Message', + 'model' => 'Model', + 'success' => 'Success', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->accessDeniedDetail) { + $res['AccessDeniedDetail'] = $this->accessDeniedDetail; + } + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->model) { + $res['Model'] = null !== $this->model ? $this->model->toMap() : null; + } + if (null !== $this->success) { + $res['Success'] = $this->success; + } + + return $res; + } + + /** + * @param array $map + * + * @return SendSmsVerifyCodeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AccessDeniedDetail'])) { + $model->accessDeniedDetail = $map['AccessDeniedDetail']; + } + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['Model'])) { + $model->model = model_::fromMap($map['Model']); + } + if (isset($map['Success'])) { + $model->success = $map['Success']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponseBody/model_.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponseBody/model_.php new file mode 100644 index 0000000..43dd126 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/SendSmsVerifyCodeResponseBody/model_.php @@ -0,0 +1,99 @@ + 'BizId', + 'outId' => 'OutId', + 'requestId' => 'RequestId', + 'verifyCode' => 'VerifyCode', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->bizId) { + $res['BizId'] = $this->bizId; + } + if (null !== $this->outId) { + $res['OutId'] = $this->outId; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->verifyCode) { + $res['VerifyCode'] = $this->verifyCode; + } + + return $res; + } + + /** + * @param array $map + * + * @return model_ + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['BizId'])) { + $model->bizId = $map['BizId']; + } + if (isset($map['OutId'])) { + $model->outId = $map['OutId']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['VerifyCode'])) { + $model->verifyCode = $map['VerifyCode']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileRequest.php new file mode 100644 index 0000000..3aef876 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileRequest.php @@ -0,0 +1,121 @@ + 'AccessCode', + 'outId' => 'OutId', + 'ownerId' => 'OwnerId', + 'phoneNumber' => 'PhoneNumber', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->accessCode) { + $res['AccessCode'] = $this->accessCode; + } + if (null !== $this->outId) { + $res['OutId'] = $this->outId; + } + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->phoneNumber) { + $res['PhoneNumber'] = $this->phoneNumber; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyMobileRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['AccessCode'])) { + $model->accessCode = $map['AccessCode']; + } + if (isset($map['OutId'])) { + $model->outId = $map['OutId']; + } + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PhoneNumber'])) { + $model->phoneNumber = $map['PhoneNumber']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponse.php new file mode 100644 index 0000000..fd19f2e --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyMobileResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = VerifyMobileResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponseBody.php new file mode 100644 index 0000000..57ee0bf --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'gateVerifyResultDTO' => 'GateVerifyResultDTO', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->gateVerifyResultDTO) { + $res['GateVerifyResultDTO'] = null !== $this->gateVerifyResultDTO ? $this->gateVerifyResultDTO->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyMobileResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['GateVerifyResultDTO'])) { + $model->gateVerifyResultDTO = gateVerifyResultDTO::fromMap($map['GateVerifyResultDTO']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponseBody/gateVerifyResultDTO.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponseBody/gateVerifyResultDTO.php new file mode 100644 index 0000000..06b24ab --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyMobileResponseBody/gateVerifyResultDTO.php @@ -0,0 +1,71 @@ + 'VerifyId', + 'verifyResult' => 'VerifyResult', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->verifyId) { + $res['VerifyId'] = $this->verifyId; + } + if (null !== $this->verifyResult) { + $res['VerifyResult'] = $this->verifyResult; + } + + return $res; + } + + /** + * @param array $map + * + * @return gateVerifyResultDTO + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['VerifyId'])) { + $model->verifyId = $map['VerifyId']; + } + if (isset($map['VerifyResult'])) { + $model->verifyResult = $map['VerifyResult']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenRequest.php new file mode 100644 index 0000000..50f77d5 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenRequest.php @@ -0,0 +1,105 @@ + 'OwnerId', + 'phoneNumber' => 'PhoneNumber', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'spToken' => 'SpToken', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->phoneNumber) { + $res['PhoneNumber'] = $this->phoneNumber; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->spToken) { + $res['SpToken'] = $this->spToken; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyPhoneWithTokenRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['PhoneNumber'])) { + $model->phoneNumber = $map['PhoneNumber']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['SpToken'])) { + $model->spToken = $map['SpToken']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponse.php new file mode 100644 index 0000000..fe78395 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyPhoneWithTokenResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = VerifyPhoneWithTokenResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponseBody.php new file mode 100644 index 0000000..5c04ca1 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponseBody.php @@ -0,0 +1,101 @@ + 'Code', + 'gateVerify' => 'GateVerify', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->gateVerify) { + $res['GateVerify'] = null !== $this->gateVerify ? $this->gateVerify->toMap() : null; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyPhoneWithTokenResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['GateVerify'])) { + $model->gateVerify = gateVerify::fromMap($map['GateVerify']); + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponseBody/gateVerify.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponseBody/gateVerify.php new file mode 100644 index 0000000..32ce8f9 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyPhoneWithTokenResponseBody/gateVerify.php @@ -0,0 +1,71 @@ + 'VerifyId', + 'verifyResult' => 'VerifyResult', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->verifyId) { + $res['VerifyId'] = $this->verifyId; + } + if (null !== $this->verifyResult) { + $res['VerifyResult'] = $this->verifyResult; + } + + return $res; + } + + /** + * @param array $map + * + * @return gateVerify + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['VerifyId'])) { + $model->verifyId = $map['VerifyId']; + } + if (isset($map['VerifyResult'])) { + $model->verifyResult = $map['VerifyResult']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeRequest.php new file mode 100644 index 0000000..f5bbad4 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeRequest.php @@ -0,0 +1,86 @@ + 'PhoneNumber', + 'smsCode' => 'SmsCode', + 'smsToken' => 'SmsToken', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->phoneNumber) { + $res['PhoneNumber'] = $this->phoneNumber; + } + if (null !== $this->smsCode) { + $res['SmsCode'] = $this->smsCode; + } + if (null !== $this->smsToken) { + $res['SmsToken'] = $this->smsToken; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifySmsCodeRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['PhoneNumber'])) { + $model->phoneNumber = $map['PhoneNumber']; + } + if (isset($map['SmsCode'])) { + $model->smsCode = $map['SmsCode']; + } + if (isset($map['SmsToken'])) { + $model->smsToken = $map['SmsToken']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeResponse.php new file mode 100644 index 0000000..ebf6902 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifySmsCodeResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = VerifySmsCodeResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeResponseBody.php new file mode 100644 index 0000000..05e298e --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifySmsCodeResponseBody.php @@ -0,0 +1,105 @@ + 'Code', + 'data' => 'Data', + 'message' => 'Message', + 'requestId' => 'RequestId', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->data) { + $res['Data'] = $this->data; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifySmsCodeResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Data'])) { + $model->data = $map['Data']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenRequest.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenRequest.php new file mode 100644 index 0000000..0c02a86 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenRequest.php @@ -0,0 +1,88 @@ + 'OwnerId', + 'resourceOwnerAccount' => 'ResourceOwnerAccount', + 'resourceOwnerId' => 'ResourceOwnerId', + 'verifyToken' => 'VerifyToken', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->ownerId) { + $res['OwnerId'] = $this->ownerId; + } + if (null !== $this->resourceOwnerAccount) { + $res['ResourceOwnerAccount'] = $this->resourceOwnerAccount; + } + if (null !== $this->resourceOwnerId) { + $res['ResourceOwnerId'] = $this->resourceOwnerId; + } + if (null !== $this->verifyToken) { + $res['VerifyToken'] = $this->verifyToken; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyWithFusionAuthTokenRequest + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['OwnerId'])) { + $model->ownerId = $map['OwnerId']; + } + if (isset($map['ResourceOwnerAccount'])) { + $model->resourceOwnerAccount = $map['ResourceOwnerAccount']; + } + if (isset($map['ResourceOwnerId'])) { + $model->resourceOwnerId = $map['ResourceOwnerId']; + } + if (isset($map['VerifyToken'])) { + $model->verifyToken = $map['VerifyToken']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponse.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponse.php new file mode 100644 index 0000000..be835d2 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponse.php @@ -0,0 +1,71 @@ + 'headers', + 'statusCode' => 'statusCode', + 'body' => 'body', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->body) { + $res['body'] = null !== $this->body ? $this->body->toMap() : null; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyWithFusionAuthTokenResponse + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['headers'])) { + $model->headers = $map['headers']; + } + if (isset($map['statusCode'])) { + $model->statusCode = $map['statusCode']; + } + if (isset($map['body'])) { + $model->body = VerifyWithFusionAuthTokenResponseBody::fromMap($map['body']); + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponseBody.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponseBody.php new file mode 100644 index 0000000..df8a5ed --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponseBody.php @@ -0,0 +1,114 @@ + 'Code', + 'message' => 'Message', + 'model' => 'Model', + 'requestId' => 'RequestId', + 'success' => 'Success', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->code) { + $res['Code'] = $this->code; + } + if (null !== $this->message) { + $res['Message'] = $this->message; + } + if (null !== $this->model) { + $res['Model'] = null !== $this->model ? $this->model->toMap() : null; + } + if (null !== $this->requestId) { + $res['RequestId'] = $this->requestId; + } + if (null !== $this->success) { + $res['Success'] = $this->success; + } + + return $res; + } + + /** + * @param array $map + * + * @return VerifyWithFusionAuthTokenResponseBody + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['Code'])) { + $model->code = $map['Code']; + } + if (isset($map['Message'])) { + $model->message = $map['Message']; + } + if (isset($map['Model'])) { + $model->model = model_::fromMap($map['Model']); + } + if (isset($map['RequestId'])) { + $model->requestId = $map['RequestId']; + } + if (isset($map['Success'])) { + $model->success = $map['Success']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponseBody/model_.php b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponseBody/model_.php new file mode 100644 index 0000000..8553d19 --- /dev/null +++ b/vendor/alibabacloud/dypnsapi-20170525/src/Models/VerifyWithFusionAuthTokenResponseBody/model_.php @@ -0,0 +1,83 @@ + 'PhoneNumber', + 'phoneScore' => 'PhoneScore', + 'verifyResult' => 'VerifyResult', + ]; + + public function validate() + { + } + + public function toMap() + { + $res = []; + if (null !== $this->phoneNumber) { + $res['PhoneNumber'] = $this->phoneNumber; + } + if (null !== $this->phoneScore) { + $res['PhoneScore'] = $this->phoneScore; + } + if (null !== $this->verifyResult) { + $res['VerifyResult'] = $this->verifyResult; + } + + return $res; + } + + /** + * @param array $map + * + * @return model_ + */ + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['PhoneNumber'])) { + $model->phoneNumber = $map['PhoneNumber']; + } + if (isset($map['PhoneScore'])) { + $model->phoneScore = $map['PhoneScore']; + } + if (isset($map['VerifyResult'])) { + $model->verifyResult = $map['VerifyResult']; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/endpoint-util/.gitignore b/vendor/alibabacloud/endpoint-util/.gitignore new file mode 100644 index 0000000..0ee6c28 --- /dev/null +++ b/vendor/alibabacloud/endpoint-util/.gitignore @@ -0,0 +1,13 @@ +composer.phar +/vendor/ + +# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control +# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file +composer.lock + +.idea +.DS_Store + +cache/ +*.cache +runtime/ diff --git a/vendor/alibabacloud/endpoint-util/.php_cs.dist b/vendor/alibabacloud/endpoint-util/.php_cs.dist new file mode 100644 index 0000000..8617ec2 --- /dev/null +++ b/vendor/alibabacloud/endpoint-util/.php_cs.dist @@ -0,0 +1,65 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/alibabacloud/endpoint-util/LICENSE b/vendor/alibabacloud/endpoint-util/LICENSE new file mode 100644 index 0000000..ec13fcc --- /dev/null +++ b/vendor/alibabacloud/endpoint-util/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vendor/alibabacloud/endpoint-util/README-CN.md b/vendor/alibabacloud/endpoint-util/README-CN.md new file mode 100644 index 0000000..80374a4 --- /dev/null +++ b/vendor/alibabacloud/endpoint-util/README-CN.md @@ -0,0 +1,31 @@ +English | [简体中文](README-CN.md) + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud Endpoint Library for PHP + +## Installation + +### Composer + +```bash +composer require alibabacloud/endpoint-util +``` + +## Issues + +[Opening an Issue](https://github.com/aliyun/endpoint-util/issues/new), Issues not conforming to the guidelines may be closed immediately. + +## Changelog + +Detailed changes for each release are documented in the [release notes](./ChangeLog.txt). + +## References + +* [Latest Release](https://github.com/aliyun/endpoint-util) + +## License + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/alibabacloud/endpoint-util/README.md b/vendor/alibabacloud/endpoint-util/README.md new file mode 100644 index 0000000..3cd5898 --- /dev/null +++ b/vendor/alibabacloud/endpoint-util/README.md @@ -0,0 +1,31 @@ +[English](README.md) | 简体中文 + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud Endpoint Library for PHP + +## 安装 + +### Composer + +```bash +composer require alibabacloud/endpoint-util +``` + +## 问题 + +[提交 Issue](https://github.com/aliyun/endpoint-util/issues/new),不符合指南的问题可能会立即关闭。 + +## 发行说明 + +每个版本的详细更改记录在[发行说明](./ChangeLog.txt)中。 + +## 相关 + +* [最新源码](https://github.com/aliyun/endpoint-util) + +## 许可证 + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/alibabacloud/endpoint-util/composer.json b/vendor/alibabacloud/endpoint-util/composer.json new file mode 100644 index 0000000..d22ce33 --- /dev/null +++ b/vendor/alibabacloud/endpoint-util/composer.json @@ -0,0 +1,42 @@ +{ + "name": "alibabacloud/endpoint-util", + "description": "Alibaba Cloud Endpoint Library for PHP", + "type": "library", + "license": "Apache-2.0", + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "require": { + "php": ">5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35|^5.4.3" + }, + "autoload": { + "psr-4": { + "AlibabaCloud\\Endpoint\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "AlibabaCloud\\Endpoint\\Tests\\": "tests" + } + }, + "scripts": { + "fixer": "php-cs-fixer fix ./", + "test": [ + "@clearCache", + "./vendor/bin/phpunit --colors=always" + ], + "clearCache": "rm -rf cache/*" + }, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "optimize-autoloader": true + }, + "prefer-stable": true +} \ No newline at end of file diff --git a/vendor/alibabacloud/endpoint-util/phpunit.xml b/vendor/alibabacloud/endpoint-util/phpunit.xml new file mode 100644 index 0000000..8306a79 --- /dev/null +++ b/vendor/alibabacloud/endpoint-util/phpunit.xml @@ -0,0 +1,32 @@ + + + + + + tests + + + ./tests/Unit + + + + + + integration + + + + + + + + + + + + ./src + + + diff --git a/vendor/alibabacloud/endpoint-util/src/Endpoint.php b/vendor/alibabacloud/endpoint-util/src/Endpoint.php new file mode 100644 index 0000000..5afa676 --- /dev/null +++ b/vendor/alibabacloud/endpoint-util/src/Endpoint.php @@ -0,0 +1,61 @@ +..aliyuncs.com'; + const CENTRAL_RULES = '.aliyuncs.com'; + + /** + * @param string $product required + * @param string $regionId optional It will be required when endpoint type is 'regional' + * @param string $endpointType optional regional|central + * @param string $network optional + * @param string $suffix optional + * + * @throws \InvalidArgumentException + * + * @return string + */ + public static function getEndpointRules($product, $regionId, $endpointType = '', $network = '', $suffix = '') + { + if (empty($product)) { + throw new \InvalidArgumentException('Product name cannot be empty.'); + } + $endpoint = self::REGIONAL_RULES; + if (self::ENDPOINT_TYPE_REGIONAL === $endpointType) { + if (empty($regionId)) { + throw new \InvalidArgumentException('RegionId is empty, please set a valid RegionId'); + } + $endpoint = self::render($endpoint, 'region_id', strtolower($regionId)); + } elseif (self::ENDPOINT_TYPE_CENTRAL === $endpointType) { + $endpoint = self::CENTRAL_RULES; + } else { + throw new \InvalidArgumentException('Invalid EndpointType'); + } + if (!empty($network) && 'public' !== $network) { + $endpoint = self::render($endpoint, 'network', '-' . $network); + } else { + $endpoint = self::render($endpoint, 'network', ''); + } + if (!empty($suffix)) { + $endpoint = self::render($endpoint, 'suffix', '-' . $suffix); + } else { + $endpoint = self::render($endpoint, 'suffix', ''); + } + + return self::render($endpoint, 'product', strtolower($product)); + } + + private static function render($str, $tag, $replace) + { + return str_replace('<' . $tag . '>', $replace, $str); + } +} diff --git a/vendor/alibabacloud/endpoint-util/tests/EndpointTest.php b/vendor/alibabacloud/endpoint-util/tests/EndpointTest.php new file mode 100644 index 0000000..e21dcd4 --- /dev/null +++ b/vendor/alibabacloud/endpoint-util/tests/EndpointTest.php @@ -0,0 +1,58 @@ +expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Product name cannot be empty.'); + Endpoint::getEndpointRules('', '', '', ''); + } + + public function testGetEndpointWhenInvalidEndpointType() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid EndpointType'); + Endpoint::getEndpointRules('ecs', '', 'fake endpoint type', ''); + } + + public function testGetEndpointWhenInvalidRegionId() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('RegionId is empty, please set a valid RegionId'); + Endpoint::getEndpointRules('ecs', '', Endpoint::ENDPOINT_TYPE_REGIONAL, ''); + } + + public function testGetEndpointCentral() + { + $endpoint = Endpoint::getEndpointRules('ecs', '', Endpoint::ENDPOINT_TYPE_CENTRAL); + $this->assertEquals('ecs.aliyuncs.com', $endpoint); + } + + public function testGetEndpointRegional() + { + $endpoint = Endpoint::getEndpointRules('ecs', 'cn-hangzhou', Endpoint::ENDPOINT_TYPE_REGIONAL); + $this->assertEquals('ecs.cn-hangzhou.aliyuncs.com', $endpoint); + } + + public function testGetEndpointRegionalWithNetwork() + { + $endpoint = Endpoint::getEndpointRules('ecs', 'cn-hangzhou', Endpoint::ENDPOINT_TYPE_REGIONAL, 'internal'); + $this->assertEquals('ecs-internal.cn-hangzhou.aliyuncs.com', $endpoint); + } + + public function testGetEndpointRegionalWithSuffix() + { + $endpoint = Endpoint::getEndpointRules('ecs', 'cn-hangzhou', Endpoint::ENDPOINT_TYPE_REGIONAL, 'internal', 'test'); + $this->assertEquals('ecs-test-internal.cn-hangzhou.aliyuncs.com', $endpoint); + } +} diff --git a/vendor/alibabacloud/endpoint-util/tests/bootstrap.php b/vendor/alibabacloud/endpoint-util/tests/bootstrap.php new file mode 100644 index 0000000..c62c4e8 --- /dev/null +++ b/vendor/alibabacloud/endpoint-util/tests/bootstrap.php @@ -0,0 +1,3 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/alibabacloud/gateway-spi/autoload.php b/vendor/alibabacloud/gateway-spi/autoload.php new file mode 100644 index 0000000..f48d6cb --- /dev/null +++ b/vendor/alibabacloud/gateway-spi/autoload.php @@ -0,0 +1,15 @@ +5.5", + "alibabacloud/credentials": "^1.1" + }, + "autoload": { + "psr-4": { + "Darabonba\\GatewaySpi\\": "src" + } + }, + "scripts": { + "fixer": "php-cs-fixer fix ./" + }, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "optimize-autoloader": true + }, + "prefer-stable": true +} \ No newline at end of file diff --git a/vendor/alibabacloud/gateway-spi/src/Client.php b/vendor/alibabacloud/gateway-spi/src/Client.php new file mode 100644 index 0000000..7b7b131 --- /dev/null +++ b/vendor/alibabacloud/gateway-spi/src/Client.php @@ -0,0 +1,35 @@ +attributes, true); + Model::validateRequired('key', $this->key, true); + } + public function toMap() { + $res = []; + if (null !== $this->attributes) { + $res['attributes'] = $this->attributes; + } + if (null !== $this->key) { + $res['key'] = $this->key; + } + return $res; + } + /** + * @param array $map + * @return AttributeMap + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['attributes'])){ + $model->attributes = $map['attributes']; + } + if(isset($map['key'])){ + $model->key = $map['key']; + } + return $model; + } + /** + * @var mixed[] + */ + public $attributes; + + /** + * @var string[] + */ + public $key; + +} diff --git a/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext.php b/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext.php new file mode 100644 index 0000000..cc3a436 --- /dev/null +++ b/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext.php @@ -0,0 +1,63 @@ +request, true); + Model::validateRequired('configuration', $this->configuration, true); + Model::validateRequired('response', $this->response, true); + } + public function toMap() { + $res = []; + if (null !== $this->request) { + $res['request'] = null !== $this->request ? $this->request->toMap() : null; + } + if (null !== $this->configuration) { + $res['configuration'] = null !== $this->configuration ? $this->configuration->toMap() : null; + } + if (null !== $this->response) { + $res['response'] = null !== $this->response ? $this->response->toMap() : null; + } + return $res; + } + /** + * @param array $map + * @return InterceptorContext + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['request'])){ + $model->request = request::fromMap($map['request']); + } + if(isset($map['configuration'])){ + $model->configuration = configuration::fromMap($map['configuration']); + } + if(isset($map['response'])){ + $model->response = response::fromMap($map['response']); + } + return $model; + } + /** + * @var request + */ + public $request; + + /** + * @var configuration + */ + public $configuration; + + /** + * @var response + */ + public $response; + +} diff --git a/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/configuration.php b/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/configuration.php new file mode 100644 index 0000000..02e6f92 --- /dev/null +++ b/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/configuration.php @@ -0,0 +1,83 @@ +regionId, true); + } + public function toMap() { + $res = []; + if (null !== $this->regionId) { + $res['regionId'] = $this->regionId; + } + if (null !== $this->endpoint) { + $res['endpoint'] = $this->endpoint; + } + if (null !== $this->endpointRule) { + $res['endpointRule'] = $this->endpointRule; + } + if (null !== $this->endpointMap) { + $res['endpointMap'] = $this->endpointMap; + } + if (null !== $this->endpointType) { + $res['endpointType'] = $this->endpointType; + } + if (null !== $this->network) { + $res['network'] = $this->network; + } + if (null !== $this->suffix) { + $res['suffix'] = $this->suffix; + } + return $res; + } + /** + * @param array $map + * @return configuration + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['regionId'])){ + $model->regionId = $map['regionId']; + } + if(isset($map['endpoint'])){ + $model->endpoint = $map['endpoint']; + } + if(isset($map['endpointRule'])){ + $model->endpointRule = $map['endpointRule']; + } + if(isset($map['endpointMap'])){ + $model->endpointMap = $map['endpointMap']; + } + if(isset($map['endpointType'])){ + $model->endpointType = $map['endpointType']; + } + if(isset($map['network'])){ + $model->network = $map['network']; + } + if(isset($map['suffix'])){ + $model->suffix = $map['suffix']; + } + return $model; + } + /** + * @var string + */ + public $regionId; + + public $endpoint; + + public $endpointRule; + + public $endpointMap; + + public $endpointType; + + public $network; + + public $suffix; + +} diff --git a/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/request.php b/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/request.php new file mode 100644 index 0000000..878ca95 --- /dev/null +++ b/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/request.php @@ -0,0 +1,220 @@ +pathname, true); + Model::validateRequired('productId', $this->productId, true); + Model::validateRequired('action', $this->action, true); + Model::validateRequired('version', $this->version, true); + Model::validateRequired('protocol', $this->protocol, true); + Model::validateRequired('method', $this->method, true); + Model::validateRequired('authType', $this->authType, true); + Model::validateRequired('bodyType', $this->bodyType, true); + Model::validateRequired('reqBodyType', $this->reqBodyType, true); + Model::validateRequired('credential', $this->credential, true); + Model::validateRequired('userAgent', $this->userAgent, true); + } + public function toMap() { + $res = []; + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->query) { + $res['query'] = $this->query; + } + if (null !== $this->body) { + $res['body'] = $this->body; + } + if (null !== $this->stream) { + $res['stream'] = $this->stream; + } + if (null !== $this->hostMap) { + $res['hostMap'] = $this->hostMap; + } + if (null !== $this->pathname) { + $res['pathname'] = $this->pathname; + } + if (null !== $this->productId) { + $res['productId'] = $this->productId; + } + if (null !== $this->action) { + $res['action'] = $this->action; + } + if (null !== $this->version) { + $res['version'] = $this->version; + } + if (null !== $this->protocol) { + $res['protocol'] = $this->protocol; + } + if (null !== $this->method) { + $res['method'] = $this->method; + } + if (null !== $this->authType) { + $res['authType'] = $this->authType; + } + if (null !== $this->bodyType) { + $res['bodyType'] = $this->bodyType; + } + if (null !== $this->reqBodyType) { + $res['reqBodyType'] = $this->reqBodyType; + } + if (null !== $this->style) { + $res['style'] = $this->style; + } + if (null !== $this->credential) { + $res['credential'] = null !== $this->credential ? $this->credential->toMap() : null; + } + if (null !== $this->signatureVersion) { + $res['signatureVersion'] = $this->signatureVersion; + } + if (null !== $this->signatureAlgorithm) { + $res['signatureAlgorithm'] = $this->signatureAlgorithm; + } + if (null !== $this->userAgent) { + $res['userAgent'] = $this->userAgent; + } + return $res; + } + /** + * @param array $map + * @return request + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['headers'])){ + $model->headers = $map['headers']; + } + if(isset($map['query'])){ + $model->query = $map['query']; + } + if(isset($map['body'])){ + $model->body = $map['body']; + } + if(isset($map['stream'])){ + $model->stream = $map['stream']; + } + if(isset($map['hostMap'])){ + $model->hostMap = $map['hostMap']; + } + if(isset($map['pathname'])){ + $model->pathname = $map['pathname']; + } + if(isset($map['productId'])){ + $model->productId = $map['productId']; + } + if(isset($map['action'])){ + $model->action = $map['action']; + } + if(isset($map['version'])){ + $model->version = $map['version']; + } + if(isset($map['protocol'])){ + $model->protocol = $map['protocol']; + } + if(isset($map['method'])){ + $model->method = $map['method']; + } + if(isset($map['authType'])){ + $model->authType = $map['authType']; + } + if(isset($map['bodyType'])){ + $model->bodyType = $map['bodyType']; + } + if(isset($map['reqBodyType'])){ + $model->reqBodyType = $map['reqBodyType']; + } + if(isset($map['style'])){ + $model->style = $map['style']; + } + if(isset($map['credential'])){ + $model->credential = Credential::fromMap($map['credential']); + } + if(isset($map['signatureVersion'])){ + $model->signatureVersion = $map['signatureVersion']; + } + if(isset($map['signatureAlgorithm'])){ + $model->signatureAlgorithm = $map['signatureAlgorithm']; + } + if(isset($map['userAgent'])){ + $model->userAgent = $map['userAgent']; + } + return $model; + } + public $headers; + + public $query; + + public $body; + + public $stream; + + public $hostMap; + + /** + * @var string + */ + public $pathname; + + /** + * @var string + */ + public $productId; + + /** + * @var string + */ + public $action; + + /** + * @var string + */ + public $version; + + /** + * @var string + */ + public $protocol; + + /** + * @var string + */ + public $method; + + /** + * @var string + */ + public $authType; + + /** + * @var string + */ + public $bodyType; + + /** + * @var string + */ + public $reqBodyType; + + public $style; + + /** + * @var Credential + */ + public $credential; + + public $signatureVersion; + + public $signatureAlgorithm; + + /** + * @var string + */ + public $userAgent; + +} diff --git a/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/response.php b/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/response.php new file mode 100644 index 0000000..d899e4d --- /dev/null +++ b/vendor/alibabacloud/gateway-spi/src/Models/InterceptorContext/response.php @@ -0,0 +1,54 @@ +statusCode) { + $res['statusCode'] = $this->statusCode; + } + if (null !== $this->headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->body) { + $res['body'] = $this->body; + } + if (null !== $this->deserializedBody) { + $res['deserializedBody'] = $this->deserializedBody; + } + return $res; + } + /** + * @param array $map + * @return response + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['statusCode'])){ + $model->statusCode = $map['statusCode']; + } + if(isset($map['headers'])){ + $model->headers = $map['headers']; + } + if(isset($map['body'])){ + $model->body = $map['body']; + } + if(isset($map['deserializedBody'])){ + $model->deserializedBody = $map['deserializedBody']; + } + return $model; + } + public $statusCode; + + public $headers; + + public $body; + + public $deserializedBody; + +} diff --git a/vendor/alibabacloud/openapi-util/.gitignore b/vendor/alibabacloud/openapi-util/.gitignore new file mode 100644 index 0000000..89c7aa5 --- /dev/null +++ b/vendor/alibabacloud/openapi-util/.gitignore @@ -0,0 +1,15 @@ +composer.phar +/vendor/ + +# Commit your application's lock file https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control +# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file +composer.lock + +.vscode/ +.idea +.DS_Store + +cache/ +*.cache +runtime/ +.php_cs.cache diff --git a/vendor/alibabacloud/openapi-util/.php_cs.dist b/vendor/alibabacloud/openapi-util/.php_cs.dist new file mode 100644 index 0000000..8617ec2 --- /dev/null +++ b/vendor/alibabacloud/openapi-util/.php_cs.dist @@ -0,0 +1,65 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/alibabacloud/openapi-util/README-CN.md b/vendor/alibabacloud/openapi-util/README-CN.md new file mode 100644 index 0000000..57b03a4 --- /dev/null +++ b/vendor/alibabacloud/openapi-util/README-CN.md @@ -0,0 +1,31 @@ +[English](README.md) | 简体中文 + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud OpenApi Util + +## 安装 + +### Composer + +```bash +composer require alibabacloud/openapi-util +``` + +## 问题 + +[提交 Issue](https://github.com/aliyun/openapiutil/issues/new),不符合指南的问题可能会立即关闭。 + +## 发行说明 + +每个版本的详细更改记录在[发行说明](./ChangeLog.txt)中。 + +## 相关 + +* [最新源码](https://github.com/aliyun/openapiutil) + +## 许可证 + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/alibabacloud/openapi-util/README.md b/vendor/alibabacloud/openapi-util/README.md new file mode 100644 index 0000000..2ad0472 --- /dev/null +++ b/vendor/alibabacloud/openapi-util/README.md @@ -0,0 +1,31 @@ +English | [简体中文](README-CN.md) + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud OpenApi Util + +## Installation + +### Composer + +```bash +composer require alibabacloud/openapi-util +``` + +## Issues + +[Opening an Issue](https://github.com/aliyun/openapiutil/issues/new), Issues not conforming to the guidelines may be closed immediately. + +## Changelog + +Detailed changes for each release are documented in the [release notes](./ChangeLog.txt). + +## References + +* [Latest Release](https://github.com/aliyun/openapiutil) + +## License + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/alibabacloud/openapi-util/autoload.php b/vendor/alibabacloud/openapi-util/autoload.php new file mode 100644 index 0000000..b787ba0 --- /dev/null +++ b/vendor/alibabacloud/openapi-util/autoload.php @@ -0,0 +1,17 @@ +5.5", + "alibabacloud/tea": "^3.1", + "alibabacloud/tea-utils": "^0.2", + "lizhichao/one-sm": "^1.5" + }, + "require-dev": { + "phpunit/phpunit": "*" + }, + "autoload": { + "psr-4": { + "AlibabaCloud\\OpenApiUtil\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "AlibabaCloud\\OpenApiUtil\\Tests\\": "tests" + } + }, + "scripts": { + "fixer": "php-cs-fixer fix ./", + "test": [ + "@clearCache", + "./vendor/bin/phpunit --colors=always" + ], + "clearCache": "rm -rf cache/*" + }, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "optimize-autoloader": true + }, + "prefer-stable": true +} diff --git a/vendor/alibabacloud/openapi-util/phpunit.xml b/vendor/alibabacloud/openapi-util/phpunit.xml new file mode 100644 index 0000000..5042ba8 --- /dev/null +++ b/vendor/alibabacloud/openapi-util/phpunit.xml @@ -0,0 +1,31 @@ + + + + + + tests + + + ./tests + + + + + + integration + + + + + + + + + + + ./src + + + diff --git a/vendor/alibabacloud/openapi-util/src/OpenApiUtilClient.php b/vendor/alibabacloud/openapi-util/src/OpenApiUtilClient.php new file mode 100644 index 0000000..b891712 --- /dev/null +++ b/vendor/alibabacloud/openapi-util/src/OpenApiUtilClient.php @@ -0,0 +1,573 @@ +toMap(); + $map = self::exceptStream($map); + $newContent = $content::fromMap($map); + $class = new \ReflectionClass($newContent); + foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { + $name = $property->getName(); + if (!$property->isStatic()) { + $content->{$name} = $property->getValue($newContent); + } + } + } + + private static function exceptStream($map) + { + if ($map instanceof StreamInterface) { + return null; + } elseif (\is_array($map)) { + $data = []; + foreach ($map as $k => $v) { + if (null !== $v) { + $item = self::exceptStream($v); + if (null !== $item) { + $data[$k] = $item; + } + } else { + $data[$k] = $v; + } + } + return $data; + } + return $map; + } + + /** + * Get the string to be signed according to request. + * + * @param Request $request which contains signed messages + * + * @return string the signed string + */ + public static function getStringToSign($request) + { + $pathname = $request->pathname ?: ''; + $query = $request->query ?: []; + + $accept = isset($request->headers['accept']) ? $request->headers['accept'] : ''; + $contentMD5 = isset($request->headers['content-md5']) ? $request->headers['content-md5'] : ''; + $contentType = isset($request->headers['content-type']) ? $request->headers['content-type'] : ''; + $date = isset($request->headers['date']) ? $request->headers['date'] : ''; + + $result = $request->method . "\n" . + $accept . "\n" . + $contentMD5 . "\n" . + $contentType . "\n" . + $date . "\n"; + + $canonicalizedHeaders = self::getCanonicalizedHeaders($request->headers); + $canonicalizedResource = self::getCanonicalizedResource($pathname, $query); + + return $result . $canonicalizedHeaders . $canonicalizedResource; + } + + /** + * Get signature according to stringToSign, secret. + * + * @param string $stringToSign the signed string + * @param string $secret accesskey secret + * + * @return string the signature + */ + public static function getROASignature($stringToSign, $secret) + { + return base64_encode(hash_hmac('sha1', $stringToSign, $secret, true)); + } + + /** + * Parse filter into a form string. + * + * @param array $filter object + * + * @return string the string + */ + public static function toForm($filter) + { + $query = $filter; + if (null === $query) { + return ''; + } + if ($query instanceof Model) { + $query = $query->toMap(); + } + $tmp = []; + foreach ($query as $k => $v) { + if (0 !== strpos($k, '_')) { + $tmp[$k] = $v; + } + } + $res = self::flatten($tmp); + ksort($res); + + return http_build_query($res); + } + + /** + * Get timestamp. + * + * @return string the timestamp string + */ + public static function getTimestamp() + { + return gmdate('Y-m-d\\TH:i:s\\Z'); + } + + /** + * Parse filter into a object which's type is map[string]string. + * + * @param array $filter query param + * + * @return array the object + */ + public static function query($filter) + { + if (null === $filter) { + return []; + } + $dict = $filter; + if ($dict instanceof Model) { + $dict = $dict->toMap(); + } + $tmp = []; + foreach ($dict as $k => $v) { + if (0 !== strpos($k, '_')) { + $tmp[$k] = $v; + } + } + + return self::flatten($tmp); + } + + /** + * Get signature according to signedParams, method and secret. + * + * @param array $signedParams params which need to be signed + * @param string $method http method e.g. GET + * @param string $secret AccessKeySecret + * + * @return string the signature + */ + public static function getRPCSignature($signedParams, $method, $secret) + { + $secret .= '&'; + $strToSign = self::getRpcStrToSign($method, $signedParams); + + $signMethod = 'HMAC-SHA1'; + + return self::encode($signMethod, $strToSign, $secret); + } + + /** + * Parse object into a string with specified style. + * + * @style specified style e.g. repeatList + * + * @param mixed $object the object + * @param string $prefix the prefix string + * @param string $style + * + * @return string the string + */ + public static function arrayToStringWithSpecifiedStyle($object, $prefix, $style) + { + if (null === $object) { + return ''; + } + if ('repeatList' === $style) { + return self::toForm([$prefix => $object]); + } + if ('simple' == $style || 'spaceDelimited' == $style || 'pipeDelimited' == $style) { + $strs = self::flatten($object); + + switch ($style) { + case 'spaceDelimited': + return implode(' ', $strs); + + case 'pipeDelimited': + return implode('|', $strs); + + default: + return implode(',', $strs); + } + } elseif ('json' === $style) { + self::parse($object, $parsed); + return json_encode($parsed); + } + + return ''; + } + + /** + * Transform input as array. + * + * @param mixed $input + * + * @return array + */ + public static function parseToArray($input) + { + self::parse($input, $result); + + return $result; + } + + /** + * Transform input as map. + * + * @param mixed $input + * + * @return array + */ + public static function parseToMap($input) + { + self::parse($input, $result); + + return $result; + } + + public static function getEndpoint($endpoint, $useAccelerate, $endpointType = 'public') + { + if ('internal' == $endpointType) { + $tmp = explode('.', $endpoint); + $tmp[0] .= '-internal'; + $endpoint = implode('.', $tmp); + } + if ($useAccelerate && 'accelerate' == $endpointType) { + return 'oss-accelerate.aliyuncs.com'; + } + + return $endpoint; + } + + /** + * Encode raw with base16. + * + * @param int[] $raw encoding data + * + * @return string encoded string + */ + public static function hexEncode($raw) + { + if (is_array($raw)) { + $raw = Utils::toString($raw); + } + return bin2hex($raw); + } + + /** + * Hash the raw data with signatureAlgorithm. + * + * @param int[] $raw hashing data + * @param string $signatureAlgorithm the autograph method + * + * @return array hashed bytes + */ + public static function hash($raw, $signatureAlgorithm) + { + $str = Utils::toString($raw); + + switch ($signatureAlgorithm) { + case 'ACS3-HMAC-SHA256': + case 'ACS3-RSA-SHA256': + $res = hash('sha256', $str, true); + return Utils::toBytes($res); + case 'ACS3-HMAC-SM3': + $res = self::sm3($str); + return Utils::toBytes(hex2bin($res)); + } + + return []; + } + + /** + * Get the authorization. + * + * @param Request $request request params + * @param string $signatureAlgorithm the autograph method + * @param string $payload the hashed request + * @param string $accesskey the accessKey string + * @param string $accessKeySecret the accessKeySecret string + * + * @return string authorization string + * @throws \ErrorException + * + */ + public static function getAuthorization($request, $signatureAlgorithm, $payload, $accesskey, $accessKeySecret) + { + $canonicalURI = $request->pathname ? $request->pathname : '/'; + $query = $request->query ?: []; + $method = strtoupper($request->method); + $canonicalQueryString = self::getCanonicalQueryString($query); + $signHeaders = []; + foreach ($request->headers as $k => $v) { + $k = strtolower($k); + if (0 === strpos($k, 'x-acs-') || 'host' === $k || 'content-type' === $k) { + $signHeaders[$k] = $v; + } + } + ksort($signHeaders); + $headers = []; + foreach ($request->headers as $k => $v) { + $k = strtolower($k); + if (0 === strpos($k, 'x-acs-') || 'host' === $k || 'content-type' === $k) { + $headers[$k] = trim($v); + } + } + $canonicalHeaderString = ''; + ksort($headers); + foreach ($headers as $k => $v) { + $canonicalHeaderString .= $k . ':' . trim(self::filter($v)) . "\n"; + } + if (empty($canonicalHeaderString)) { + $canonicalHeaderString = "\n"; + } + + $canonicalRequest = $method . "\n" . $canonicalURI . "\n" . $canonicalQueryString . "\n" . + $canonicalHeaderString . "\n" . implode(';', array_keys($signHeaders)) . "\n" . $payload; + $strtosign = $signatureAlgorithm . "\n" . self::hexEncode(self::hash(Utils::toBytes($canonicalRequest), $signatureAlgorithm)); + $signature = self::sign($accessKeySecret, $strtosign, $signatureAlgorithm); + $signature = self::hexEncode($signature); + + return $signatureAlgorithm . + ' Credential=' . $accesskey . + ',SignedHeaders=' . implode(';', array_keys($signHeaders)) . + ',Signature=' . $signature; + } + + public static function sign($secret, $str, $algorithm) + { + $result = ''; + switch ($algorithm) { + case 'ACS3-HMAC-SHA256': + $result = hash_hmac('sha256', $str, $secret, true); + break; + case 'ACS3-HMAC-SM3': + $result = self::hmac_sm3($str, $secret, true); + break; + case 'ACS3-RSA-SHA256': + $privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" . $secret . "\n-----END RSA PRIVATE KEY-----"; + @openssl_sign($str, $result, $privateKey, OPENSSL_ALGO_SHA256); + } + + return Utils::toBytes($result); + } + + /** + * Get encoded path. + * + * @param string $path the raw path + * + * @return string encoded path + */ + public static function getEncodePath($path) + { + $tmp = explode('/', $path); + foreach ($tmp as &$t) { + $t = rawurlencode($t); + } + + return implode('/', $tmp); + } + + /** + * Get encoded param. + * + * @param string $param the raw param + * + * @return string encoded param + */ + public static function getEncodeParam($param) + { + return rawurlencode($param); + } + + private static function getRpcStrToSign($method, $query) + { + ksort($query); + + $params = []; + foreach ($query as $k => $v) { + if (null !== $v) { + $k = rawurlencode($k); + $v = rawurlencode($v); + $params[] = $k . '=' . (string)$v; + } + } + $str = implode('&', $params); + + return $method . '&' . rawurlencode('/') . '&' . rawurlencode($str); + } + + private static function encode($signMethod, $strToSign, $secret) + { + switch ($signMethod) { + case 'HMAC-SHA256': + return base64_encode(hash_hmac('sha256', $strToSign, $secret, true)); + + default: + return base64_encode(hash_hmac('sha1', $strToSign, $secret, true)); + } + } + + /** + * @param array $items + * @param string $delimiter + * @param string $prepend + * + * @return array + */ + private static function flatten($items = [], $delimiter = '.', $prepend = '') + { + $flatten = []; + + foreach ($items as $key => $value) { + $pos = \is_int($key) ? $key + 1 : $key; + + if ($value instanceof Model) { + $value = $value->toMap(); + } elseif (\is_object($value)) { + $value = get_object_vars($value); + } + + if (\is_array($value) && !empty($value)) { + $flatten = array_merge( + $flatten, + self::flatten($value, $delimiter, $prepend . $pos . $delimiter) + ); + } else { + if (\is_bool($value)) { + $value = true === $value ? 'true' : 'false'; + } + $flatten[$prepend . $pos] = $value; + } + } + + return $flatten; + } + + private static function getCanonicalizedHeaders($headers, $prefix = 'x-acs-') + { + ksort($headers); + $str = ''; + foreach ($headers as $k => $v) { + if (0 === strpos(strtolower($k), $prefix)) { + $str .= $k . ':' . trim(self::filter($v)) . "\n"; + } + } + + return $str; + } + + private static function getCanonicalizedResource($pathname, $query) + { + if (0 === \count($query)) { + return $pathname; + } + ksort($query); + $tmp = []; + foreach ($query as $k => $v) { + if (!empty($v)) { + $tmp[] = $k . '=' . $v; + } else { + $tmp[] = $k; + } + } + + return $pathname . '?' . implode('&', $tmp); + } + + private static function parse($input, &$output) + { + if (null === $input || '' === $input) { + $output = []; + } + $recursive = function ($input) use (&$recursive) { + if ($input instanceof Model) { + $input = $input->toMap(); + } elseif (\is_object($input)) { + $input = get_object_vars($input); + } + if (!\is_array($input)) { + return $input; + } + $data = []; + foreach ($input as $k => $v) { + $data[$k] = $recursive($v); + } + + return $data; + }; + $output = $recursive($input); + if (!\is_array($output)) { + $output = [$output]; + } + } + + private static function filter($str) + { + return str_replace(["\t", "\n", "\r", "\f"], '', $str); + } + + private static function hmac_sm3($data, $key, $raw_output = false) + { + $pack = 'H' . \strlen(self::sm3('test')); + $blocksize = 64; + if (\strlen($key) > $blocksize) { + $key = pack($pack, self::sm3($key)); + } + $key = str_pad($key, $blocksize, \chr(0x00)); + $ipad = $key ^ str_repeat(\chr(0x36), $blocksize); + $opad = $key ^ str_repeat(\chr(0x5C), $blocksize); + $hmac = self::sm3($opad . pack($pack, self::sm3($ipad . $data))); + + return $raw_output ? pack($pack, $hmac) : $hmac; + } + + private static function sm3($message) + { + return (new Sm3())->sign($message); + } + + private static function getCanonicalQueryString($query) + { + ksort($query); + + $params = []; + foreach ($query as $k => $v) { + if (null === $v) { + continue; + } + $str = rawurlencode($k); + if ('' !== $v && null !== $v) { + $str .= '=' . rawurlencode($v); + } else { + $str .= '='; + } + $params[] = $str; + } + + return implode('&', $params); + } +} diff --git a/vendor/alibabacloud/openapi-util/tests/Models/SourceModel.php b/vendor/alibabacloud/openapi-util/tests/Models/SourceModel.php new file mode 100644 index 0000000..405cefb --- /dev/null +++ b/vendor/alibabacloud/openapi-util/tests/Models/SourceModel.php @@ -0,0 +1,126 @@ + 'Test', + 'empty' => 'empty', + 'bodyObject' => 'body', + 'listObject' => 'list', + ]; + public function validate() {} + public function toMap() { + $res = []; + if (null !== $this->test) { + $res['Test'] = $this->test; + } + if (null !== $this->empty) { + $res['empty'] = $this->empty; + } + if (null !== $this->bodyObject) { + $res['body'] = $this->bodyObject; + } + if (null !== $this->listObject) { + $res['list'] = $this->listObject; + } + if (null !== $this->urlListObject) { + $res['urlList'] = []; + if(null !== $this->urlListObject && is_array($this->urlListObject)){ + $n = 0; + foreach($this->urlListObject as $item){ + $res['urlList'][$n++] = null !== $item ? $item->toMap() : $item; + } + } + } + return $res; + } + /** + * @param array $map + * @return SourceModel + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['Test'])){ + $model->test = $map['Test']; + } + if(isset($map['empty'])){ + $model->empty = $map['empty']; + } + if(isset($map['body'])){ + $model->bodyObject = $map['body']; + } + if(isset($map['list'])){ + if(!empty($map['list'])){ + $model->listObject = $map['list']; + } + } + if(isset($map['urlList'])){ + if(!empty($map['urlList'])){ + $model->urlListObject = []; + $n = 0; + foreach($map['urlList'] as $item) { + $model->urlListObject[$n++] = null !== $item ? urlListObject::fromMap($item) : $item; + } + } + } + return $model; + } + /** + * @var string + */ + public $test; + + /** + * @var float + */ + public $empty; + + /** + * @var Stream + */ + public $bodyObject; + + /** + * @var Stream[] + */ + public $listObject; + + public $urlListObject; + +} + +class urlListObject extends Model { + protected $_name = [ + 'urlObject' => 'url', + ]; + public function validate() {} + public function toMap() { + $res = []; + if (null !== $this->urlObject) { + $res['url'] = $this->urlObject; + } + return $res; + } + /** + * @param array $map + * @return urlListObject + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['url'])){ + $model->urlObject = $map['url']; + } + return $model; + } + /** + * @var Stream + */ + public $urlObject; + +} + diff --git a/vendor/alibabacloud/openapi-util/tests/Models/TargetModel.php b/vendor/alibabacloud/openapi-util/tests/Models/TargetModel.php new file mode 100644 index 0000000..397aee4 --- /dev/null +++ b/vendor/alibabacloud/openapi-util/tests/Models/TargetModel.php @@ -0,0 +1,125 @@ + 'Test', + 'empty' => 'empty', + 'body' => 'body', + 'list' => 'list', + ]; + public function validate() {} + public function toMap() { + $res = []; + if (null !== $this->test) { + $res['Test'] = $this->test; + } + if (null !== $this->empty) { + $res['empty'] = $this->empty; + } + if (null !== $this->body) { + $res['body'] = $this->body; + } + if (null !== $this->list) { + $res['list'] = $this->list; + } + if (null !== $this->urlList) { + $res['urlList'] = []; + if(null !== $this->urlList && is_array($this->urlList)){ + $n = 0; + foreach($this->urlList as $item){ + $res['urlList'][$n++] = null !== $item ? $item->toMap() : $item; + } + } + } + return $res; + } + /** + * @param array $map + * @return TargetModel + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['Test'])){ + $model->test = $map['Test']; + } + if(isset($map['empty'])){ + $model->empty = $map['empty']; + } + if(isset($map['body'])){ + $model->body = $map['body']; + } + if(isset($map['list'])){ + if(!empty($map['list'])){ + $model->list = $map['list']; + } + } + if(isset($map['urlList'])){ + if(!empty($map['urlList'])){ + $model->urlList = []; + $n = 0; + foreach($map['urlList'] as $item) { + $model->urlList[$n++] = null !== $item ? urlList::fromMap($item) : $item; + } + } + } + return $model; + } + /** + * @var string + */ + public $test; + + /** + * @var float + */ + public $empty; + + /** + * @var Stream + */ + public $body; + + /** + * @var string[] + */ + public $list; + + public $urlList; + +} + +class urlList extends Model { + protected $_name = [ + 'url' => 'url', + ]; + public function validate() {} + public function toMap() { + $res = []; + if (null !== $this->url) { + $res['url'] = $this->url; + } + return $res; + } + /** + * @param array $map + * @return urlList + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['url'])){ + $model->url = $map['url']; + } + return $model; + } + /** + * @var string + */ + public $url; + +} \ No newline at end of file diff --git a/vendor/alibabacloud/openapi-util/tests/OpenApiUtilClientTest.php b/vendor/alibabacloud/openapi-util/tests/OpenApiUtilClientTest.php new file mode 100644 index 0000000..550b677 --- /dev/null +++ b/vendor/alibabacloud/openapi-util/tests/OpenApiUtilClientTest.php @@ -0,0 +1,501 @@ +a = 'foo'; + + $output = new MockModel(); + OpenApiUtilClient::convert($model, $output); + $this->assertEquals($model->a, $output->a); + + if (\function_exists('\GuzzleHttp\Psr7\stream_for')) { + // @deprecated stream_for will be removed in guzzlehttp/psr7:2.0 + $stream = \GuzzleHttp\Psr7\stream_for('test'); + } else { + $stream = \GuzzleHttp\Psr7\Utils::streamFor('test'); + } + $source = new SourceModel(); + $source->test = 'test'; + $source->bodyObject = $stream; + $source->listObject = [ + $stream + ]; + $urlListObject = new urlListObject(); + $urlListObject->urlObject = $stream; + $source->urlListObject = [ + $urlListObject + ]; + $target = new TargetModel(); + OpenApiUtilClient::convert($source, $target); + $this->assertEquals('test', $target->test); + $this->assertNull($target->empty); + $this->assertNull($target->body); + $this->assertTrue(empty($target->list)); + $this->assertNotNull($target->urlList[0]); + $this->assertNull($target->urlList[0]->url); + } + + public function testGetStringToSign() + { + $request = new Request(); + $request->method = 'GET'; + $request->pathname = '/'; + $request->headers['accept'] = 'application/json'; + + $this->assertEquals("GET\napplication/json\n\n\n\n/", OpenApiUtilClient::getStringToSign($request)); + + $request->headers = [ + 'accept' => 'application/json', + 'content-md5' => 'md5', + 'content-type' => 'application/json', + 'date' => 'date', + ]; + $this->assertEquals("GET\napplication/json\nmd5\napplication/json\ndate\n/", OpenApiUtilClient::getStringToSign($request)); + + $request->headers = [ + 'accept' => 'application/json', + 'content-md5' => 'md5', + 'content-type' => 'application/json', + 'date' => 'date', + 'x-acs-custom-key' => 'any value', + ]; + $this->assertEquals("GET\napplication/json\nmd5\napplication/json\ndate\nx-acs-custom-key:any value\n/", OpenApiUtilClient::getStringToSign($request)); + + $request->query = [ + 'key' => 'val ue with space', + ]; + $this->assertEquals("GET\napplication/json\nmd5\napplication/json\ndate\nx-acs-custom-key:any value\n/?key=val ue with space", OpenApiUtilClient::getStringToSign($request)); + } + + public function testGetROASignature() + { + $this->assertEquals('OmuTAr79tpI6CRoAdmzKRq5lHs0=', OpenApiUtilClient::getROASignature('stringtosign', 'secret')); + } + + public function testToForm() + { + $this->assertEquals('bool=true&client=test&strs.1=str1&strs.2=str2&strs.3=false&tag.key=value', OpenApiUtilClient::toForm([ + 'client' => 'test', + 'tag' => [ + 'key' => 'value', + ], + 'strs' => ['str1', 'str2', false], + 'bool' => true, + 'null' => null, + ])); + } + + public function testGetTimestamp() + { + $date = OpenApiUtilClient::getTimestamp(); + $this->assertEquals(20, \strlen($date)); + } + + public function testQuery() + { + $model = new MockModel(); + $model->a = 'foo'; + $model->c = 'boo'; + $model->r = true; + + $array = [ + 'a' => 'a', + 'b1' => [ + 'a' => 'a', + ], + 'b2' => [ + 'a' => 'a', + ], + 'c' => ['x', 'y', 'z'], + 'd' => [ + $model + ], + 'e' => true, + 'f' => null, + ]; + $this->assertEquals([ + 'a' => 'a', + 'b1.a' => 'a', + 'b2.a' => 'a', + 'c.1' => 'x', + 'c.2' => 'y', + 'c.3' => 'z', + 'd.1.A' => 'foo', + 'd.1.b' => '', + 'd.1.c' => 'boo', + 'd.1.c' => 'boo', + 'd.1.r' => 'true', + 'e' => 'true', + 'f' => null + ], OpenApiUtilClient::query($array)); + } + + public function testGetRPCSignature() + { + $request = new Request(); + $request->pathname = ''; + $request->query = [ + 'query' => 'test', + 'body' => 'test', + ]; + $this->assertEquals('XlUyV4sXjOuX5FnjUz9IF9tm5rU=', OpenApiUtilClient::getRPCSignature($request->query, $request->method, 'secret')); + } + + public function testArrayToStringWithSpecifiedStyle() + { + $data = ['ok', 'test', 2, 3]; + $this->assertEquals( + 'instance.1=ok&instance.2=test&instance.3=2&instance.4=3', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $data, + 'instance', + 'repeatList' + ) + ); + + $this->assertEquals( + '["ok","test",2,3]', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $data, + 'instance', + 'json' + ) + ); + + $test = new ParseModel([ + 'str' => 'A', + 'model' => new ParseModel(['str' => 'sub model']), + 'array' => [1, 2, 3], + ]); + $this->assertEquals( + '{"str":"A","model":{"str":"sub model","model":null,"array":null},"array":[1,2,3]}', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $test, + 'instance', + 'json' + ) + ); + // model item in array + $test = [ + new ParseModel([ + 'str' => 'A', + ]), + ]; + $this->assertEquals( + '[{"str":"A","model":null,"array":null}]', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $test, + 'instance', + 'json' + ) + ); + // model item in map + $test = [ + 'model' => new ParseModel([ + 'str' => 'A', + ]), + ]; + $this->assertEquals( + '{"model":{"str":"A","model":null,"array":null}}', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $test, + 'instance', + 'json' + ) + ); + + $this->assertEquals( + 'ok,test,2,3', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $data, + 'instance', + 'simple' + ) + ); + + $this->assertEquals( + 'ok test 2 3', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $data, + 'instance', + 'spaceDelimited' + ) + ); + + $this->assertEquals( + 'ok|test|2|3', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $data, + 'instance', + 'pipeDelimited' + ) + ); + + $this->assertEquals( + '', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + $data, + 'instance', + 'piDelimited' + ) + ); + + $this->assertEquals( + '', + OpenApiUtilClient::arrayToStringWithSpecifiedStyle( + null, + 'instance', + 'pipeDelimited' + ) + ); + } + + public function testParseToArray() + { + $test = $this->parseData(); + $data = $test['data']; + $expected = $test['expected']; + foreach ($data as $index => $item) { + $this->assertEquals($expected[$index], OpenApiUtilClient::parseToArray($item)); + } + } + + public function testParseToMap() + { + $test = $this->parseData(); + $data = $test['data']; + $expected = $test['expected']; + foreach ($data as $index => $item) { + $this->assertEquals($expected[$index], OpenApiUtilClient::parseToMap($item)); + } + } + + public function testGetEndpoint() + { + $endpoint = 'ecs.cn-hangzhou.aliyun.cs.com'; + $useAccelerate = false; + $endpointType = 'public'; + + $this->assertEquals('ecs.cn-hangzhou.aliyun.cs.com', OpenApiUtilClient::getEndpoint($endpoint, $useAccelerate, $endpointType)); + + $endpointType = 'internal'; + $this->assertEquals('ecs-internal.cn-hangzhou.aliyun.cs.com', OpenApiUtilClient::getEndpoint($endpoint, $useAccelerate, $endpointType)); + + $useAccelerate = true; + $endpointType = 'accelerate'; + $this->assertEquals('oss-accelerate.aliyuncs.com', OpenApiUtilClient::getEndpoint($endpoint, $useAccelerate, $endpointType)); + } + + public function testHexEncode() + { + $data = OpenApiUtilClient::hash(Utils::toBytes('test'), 'ACS3-HMAC-SHA256'); + $this->assertEquals( + Utils::toBytes(hex2bin('9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08')), + $data + ); + + $data = OpenApiUtilClient::hash(Utils::toBytes('test'), 'ACS3-RSA-SHA256'); + $this->assertEquals( + Utils::toBytes(hex2bin('9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08')), + $data + ); + + $data = OpenApiUtilClient::hash(Utils::toBytes('test'), 'ACS3-HMAC-SM3'); + $this->assertEquals( + Utils::toBytes(hex2bin('55e12e91650d2fec56ec74e1d3e4ddbfce2ef3a65890c2a19ecf88a307e76a23')), + $data + ); + + $data = OpenApiUtilClient::hash(Utils::toBytes('test'), 'ACS3-HM-SHA256'); + $this->assertEquals('', Utils::toString($data)); + } + + public function testGetEncodePath() + { + $this->assertEquals( + '/path/%20test', + OpenApiUtilClient::getEncodePath('/path/ test') + ); + } + + public function testGetEncodeParam() + { + $this->assertEquals( + 'a%2Fb%2Fc%2F%20test', + OpenApiUtilClient::getEncodeParam('a/b/c/ test') + ); + } + + public function testGetAuthorization() + { + $request = new Request(); + $request->method = ''; + $request->pathname = ''; + $request->query = [ + 'test' => 'ok', + 'empty' => '', + ]; + $request->headers = [ + 'x-acs-test' => 'http', + 'x-acs-TEST' => 'https', + ]; + + $res = OpenApiUtilClient::getAuthorization($request, 'ACS3-HMAC-SHA256', '55e12e91650d2fec56ec74e1d3e4ddbfce2ef3a65890c2a19ecf88a307e76a23', 'acesskey', 'secret'); + + $this->assertEquals('ACS3-HMAC-SHA256 Credential=acesskey,SignedHeaders=x-acs-test,Signature=0a0f89a45f1ec3537a2d1a1046c71b95513a8f1f02526056968da19b99a5b914', $res); + + $request->query = null; + + $res = OpenApiUtilClient::getAuthorization($request, 'ACS3-HMAC-SHA256', '55e12e91650d2fec56ec74e1d3e4ddbfce2ef3a65890c2a19ecf88a307e76a23', 'acesskey', 'secret'); + + $this->assertEquals('ACS3-HMAC-SHA256 Credential=acesskey,SignedHeaders=x-acs-test,Signature=af6d32deb090ae85a21d7183055cf18dca17751da96979cdf964f8f0853e9dd2', $res); + } + + public function testSign() + { + $this->assertEquals( + 'b9ff646822f41ef647c1416fa2b8408923828abc0464af6706e18db3e8553da8', + OpenApiUtilClient::hexEncode(OpenApiUtilClient::sign('secret', 'source', 'ACS3-HMAC-SM3')) + ); + $this->assertEquals( + '1d93c62698a1c26427265668e79fac099aa26c1df873669599a2fb2f272e64c9', + OpenApiUtilClient::hexEncode(OpenApiUtilClient::sign('secret', 'source', 'ACS3-HMAC-SHA256')) + ); + } + + private function parseData() + { + return [ + 'data' => [ + 'NotArray', + new ParseModel([ + 'str' => 'A', + 'model' => new ParseModel(['str' => 'sub model']), + 'array' => [1, 2, 3], + ]), + [ // model item in array + new ParseModel([ + 'str' => 'A', + ]), + ], + [ // model item in map + 'model' => new ParseModel([ + 'str' => 'A', + ]), + ], + ], + 'expected' => [ + ['NotArray'], + [ + 'str' => 'A', + 'model' => [ + 'str' => 'sub model', + 'model' => null, + 'array' => null, + ], + 'array' => [1, 2, 3], + ], + [ + [ + 'str' => 'A', + 'model' => null, + 'array' => null, + ], + ], + [ + 'model' => [ + 'str' => 'A', + 'model' => null, + 'array' => null, + ], + ], + ], + 'expectedJsonStr' => [ + '["NotArray"]', + 'NotArray', + 'NotArray', + 'NotArray', + ], + ]; + } +} + +class MockModel extends Model +{ + public $a = 'A'; + + public $b = ''; + + public $c = ''; + + public $r; + + public function __construct() + { + $this->_name['a'] = 'A'; + $this->_required['c'] = true; + parent::__construct([]); + } + + public function toMap() + { + $res = []; + if (null !== $this->a) { + $res['A'] = $this->a; + } + if (null !== $this->b) { + $res['b'] = $this->b; + } + if (null !== $this->c) { + $res['c'] = $this->c; + } + if (null !== $this->r) { + $res['r'] = $this->r; + } + return $res; + } + + public static function fromMap($map = []) + { + $model = new self(); + if (isset($map['A'])) { + $model->a = $map['A']; + } + if (isset($map['b'])) { + $model->b = $map['b']; + } + if (isset($map['c'])) { + $model->c = $map['c']; + } + if (isset($map['r'])) { + $model->r = $map['r']; + } + return $model; + } +} + +class ParseModel extends Model +{ + public $str; + public $model; + public $array; +} diff --git a/vendor/alibabacloud/openapi-util/tests/bootstrap.php b/vendor/alibabacloud/openapi-util/tests/bootstrap.php new file mode 100644 index 0000000..c62c4e8 --- /dev/null +++ b/vendor/alibabacloud/openapi-util/tests/bootstrap.php @@ -0,0 +1,3 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/alibabacloud/tea-utils/README-CN.md b/vendor/alibabacloud/tea-utils/README-CN.md new file mode 100644 index 0000000..07553ca --- /dev/null +++ b/vendor/alibabacloud/tea-utils/README-CN.md @@ -0,0 +1,31 @@ +English | [简体中文](README-CN.md) + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud Tea Util for PHP + +## Installation + +### Composer + +```bash +composer require alibabacloud/tea-utils +``` + +## Issues + +[Opening an Issue](https://github.com/aliyun/tea-util/issues/new), Issues not conforming to the guidelines may be closed immediately. + +## Changelog + +Detailed changes for each release are documented in the [release notes](./ChangeLog.txt). + +## References + +* [Latest Release](https://github.com/aliyun/tea-util) + +## License + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/alibabacloud/tea-utils/README.md b/vendor/alibabacloud/tea-utils/README.md new file mode 100644 index 0000000..ef53f6e --- /dev/null +++ b/vendor/alibabacloud/tea-utils/README.md @@ -0,0 +1,31 @@ +[English](README.md) | 简体中文 + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud Tea Util for PHP + +## 安装 + +### Composer + +```bash +composer require alibabacloud/tea-utils +``` + +## 问题 + +[提交 Issue](https://github.com/aliyun/tea-util/issues/new),不符合指南的问题可能会立即关闭。 + +## 发行说明 + +每个版本的详细更改记录在[发行说明](./ChangeLog.txt)中。 + +## 相关 + +* [最新源码](https://github.com/aliyun/tea-util) + +## 许可证 + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/alibabacloud/tea-utils/composer.json b/vendor/alibabacloud/tea-utils/composer.json new file mode 100644 index 0000000..f1178c0 --- /dev/null +++ b/vendor/alibabacloud/tea-utils/composer.json @@ -0,0 +1,38 @@ +{ + "name": "alibabacloud/tea-utils", + "description": "Alibaba Cloud Tea Utils for PHP", + "type": "library", + "license": "Apache-2.0", + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "support": { + "source": "https://github.com/aliyun/tea-util", + "issues": "https://github.com/aliyun/tea-util/issues" + }, + "require": { + "php": ">5.5", + "alibabacloud/tea": "^3.1" + }, + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\Utils\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "AlibabaCloud\\Tea\\Utils\\Tests\\": "tests" + } + }, + "scripts": { + "fixer": "php-cs-fixer fix ./", + "test": [ + "@clearCache", + "./vendor/bin/phpunit --colors=always" + ], + "clearCache": "rm -rf cache/*" + } +} diff --git a/vendor/alibabacloud/tea-utils/phpunit.xml b/vendor/alibabacloud/tea-utils/phpunit.xml new file mode 100644 index 0000000..a44c1a2 --- /dev/null +++ b/vendor/alibabacloud/tea-utils/phpunit.xml @@ -0,0 +1,18 @@ + + + + + src + + + + + + + + + + tests + + + diff --git a/vendor/alibabacloud/tea-utils/src/Utils.php b/vendor/alibabacloud/tea-utils/src/Utils.php new file mode 100644 index 0000000..13ca84f --- /dev/null +++ b/vendor/alibabacloud/tea-utils/src/Utils.php @@ -0,0 +1,600 @@ +isSeekable()) { + $stream->rewind(); + } + + return $stream->getContents(); + } + + /** + * Read data from a readable stream, and parse it by JSON format. + * + * @param StreamInterface $stream the readable stream + * + * @return array the parsed result + */ + public static function readAsJSON($stream) + { + return self::parseJSON(self::readAsString($stream)); + } + + /** + * Generate a nonce string. + * + * @return string the nonce string + */ + public static function getNonce() + { + return md5(uniqid() . uniqid(md5(microtime(true)), true)); + } + + /** + * Get an UTC format string by current date, e.g. 'Thu, 06 Feb 2020 07:32:54 GMT'. + * + * @return string the UTC format string + */ + public static function getDateUTCString() + { + return gmdate('D, d M Y H:i:s T'); + } + + /** + * If not set the real, use default value. + * + * @param string $real + * @param string $default + * + * @return string + */ + public static function defaultString($real, $default = '') + { + return null === $real ? $default : $real; + } + + /** + * If not set the real, use default value. + * + * @param int $real + * @param int $default + * + * @return int the return number + */ + public static function defaultNumber($real, $default = 0) + { + if (null === $real) { + return $default; + } + + return (int) $real; + } + + /** + * Format a map to form string, like a=a%20b%20c. + * + * @param array|object $query + * + * @return string the form string + */ + public static function toFormString($query) + { + if (null === $query) { + return ''; + } + + if (\is_object($query)) { + $query = json_decode(self::toJSONString($query), true); + } + + return str_replace('+', '%20', http_build_query($query)); + } + + /** + * If not set the real, use default value. + * + * @param array|Model $object + * + * @return string the return string + */ + public static function toJSONString($object) + { + if (is_string($object)) { + return $object; + } + + if ($object instanceof Model) { + $object = $object->toMap(); + } + + return json_encode($object, JSON_UNESCAPED_UNICODE + JSON_UNESCAPED_SLASHES); + } + + /** + * Check the string is empty? + * + * @param string $val + * + * @return bool if string is null or zero length, return true + * + * @deprecated + */ + public static function _empty($val) + { + return empty($val); + } + + /** + * Check the string is empty? + * + * @param string $val + * + * @return bool if string is null or zero length, return true + * + * @deprecated + */ + public static function emptyWithSuffix($val) + { + return empty($val); + } + + /** + * Check the string is empty? + * + * @param string $val + * + * @return bool if string is null or zero length, return true + */ + public static function empty_($val) + { + return empty($val); + } + + /** + * Check one string equals another one? + * + * @param int $left + * @param int $right + * + * @return bool if equals, return true + */ + public static function equalString($left, $right) + { + return $left === $right; + } + + /** + * Check one number equals another one? + * + * @param int $left + * @param int $right + * + * @return bool if equals, return true + */ + public static function equalNumber($left, $right) + { + return $left === $right; + } + + /** + * Check one value is unset. + * + * @param mixed $value + * + * @return bool if unset, return true + */ + public static function isUnset(&$value = null) + { + return !isset($value) || null === $value; + } + + /** + * Stringify the value of map. + * + * @param array $map + * + * @return array the new stringified map + */ + public static function stringifyMapValue($map) + { + if (null === $map) { + return []; + } + foreach ($map as &$node) { + if (is_numeric($node)) { + $node = (string) $node; + } elseif (null === $node) { + $node = ''; + } elseif (\is_bool($node)) { + $node = true === $node ? 'true' : 'false'; + } elseif (\is_object($node)) { + $node = json_decode(json_encode($node), true); + } + } + + return $map; + } + + /** + * Anyify the value of map. + * + * @param array $m + * + * @return array the new anyfied map + */ + public static function anyifyMapValue($m) + { + return $m; + } + + /** + * Assert a value, if it is a boolean, return it, otherwise throws. + * + * @param mixed $value + * + * @return bool the boolean value + */ + public static function assertAsBoolean($value) + { + if (\is_bool($value)) { + return $value; + } + + throw new \InvalidArgumentException('It is not a boolean value.'); + } + + /** + * Assert a value, if it is a string, return it, otherwise throws. + * + * @param mixed $value + * + * @return string the string value + */ + public static function assertAsString($value) + { + if (\is_string($value)) { + return $value; + } + + throw new \InvalidArgumentException('It is not a string value.'); + } + + private static function is_bytes($value) + { + if (!\is_array($value)) { + return false; + } + $i = 0; + foreach ($value as $k => $ord) { + if ($k !== $i) { + return false; + } + if (!\is_int($ord)) { + return false; + } + if ($ord < 0 || $ord > 255) { + return false; + } + ++$i; + } + + return true; + } + + /** + * Assert a value, if it is a bytes, return it, otherwise throws. + * + * @param mixed $value + * + * @return bytes the bytes value + */ + public static function assertAsBytes($value) + { + if (self::is_bytes($value)) { + return $value; + } + + throw new \InvalidArgumentException('It is not a bytes value.'); + } + + /** + * Assert a value, if it is a number, return it, otherwise throws. + * + * @param mixed $value + * + * @return int the number value + */ + public static function assertAsNumber($value) + { + if (\is_numeric($value)) { + return $value; + } + + throw new \InvalidArgumentException('It is not a number value.'); + } + + /** + * Assert a value, if it is a integer, return it, otherwise throws + * @param mixed $value + * @return int the integer value + */ + public static function assertAsInteger($value){ + if (\is_int($value)) { + return $value; + } + + throw new \InvalidArgumentException('It is not a int value.'); + } + + /** + * Assert a value, if it is a map, return it, otherwise throws. + * + * @param $any + * + * @return array the map value + */ + public static function assertAsMap($any) + { + if (\is_array($any)) { + return $any; + } + + throw new \InvalidArgumentException('It is not a map value.'); + } + + public static function assertAsArray($any){ + if (\is_array($any)) { + return $any; + } + + throw new \InvalidArgumentException('It is not a array value.'); + } + + /** + * Get user agent, if it userAgent is not null, splice it with defaultUserAgent and return, otherwise return + * defaultUserAgent. + * + * @param string $userAgent + * + * @return string the string value + */ + public static function getUserAgent($userAgent = '') + { + if (empty(self::$defaultUserAgent)) { + self::$defaultUserAgent = sprintf('AlibabaCloud (%s; %s) PHP/%s Core/3.1 TeaDSL/1', PHP_OS, \PHP_SAPI, PHP_VERSION); + } + if (!empty($userAgent)) { + return self::$defaultUserAgent . ' ' . $userAgent; + } + + return self::$defaultUserAgent; + } + + /** + * If the code between 200 and 300, return true, or return false. + * + * @param int $code + * + * @return bool + */ + public static function is2xx($code) + { + return $code >= 200 && $code < 300; + } + + /** + * If the code between 300 and 400, return true, or return false. + * + * @param int $code + * + * @return bool + */ + public static function is3xx($code) + { + return $code >= 300 && $code < 400; + } + + /** + * If the code between 400 and 500, return true, or return false. + * + * @param int $code + * + * @return bool + */ + public static function is4xx($code) + { + return $code >= 400 && $code < 500; + } + + /** + * If the code between 500 and 600, return true, or return false. + * + * @param int $code + * + * @return bool + */ + public static function is5xx($code) + { + return $code >= 500 && $code < 600; + } + + /** + * Validate model. + * + * @param Model $model + */ + public static function validateModel($model) + { + if (null !== $model) { + $model->validate(); + } + } + + /** + * Model transforms to map[string]any. + * + * @param Model $model + * + * @return array + */ + public static function toMap($model) + { + if (null === $model) { + return []; + } + $map = $model->toMap(); + $names = $model->getName(); + $vars = get_object_vars($model); + foreach ($vars as $k => $v) { + if (false !== strpos($k, 'Shrink') && !isset($names[$k])) { + // A field that has the suffix `Shrink` and is not a Model class property. + $targetKey = ucfirst(substr($k, 0, \strlen($k) - 6)); + if (isset($map[$targetKey])) { + // $targetKey exists in $map. + $map[$targetKey] = $v; + } + } + } + + return $map; + } + + /** + * Suspends the current thread for the specified number of milliseconds. + * + * @param int $millisecond + */ + public static function sleep($millisecond) + { + usleep($millisecond * 1000); + } + + /** + * Transform input as array. + * + * @param mixed $input + * + * @return array + */ + public static function toArray($input) + { + if (\is_array($input)) { + foreach ($input as $k => &$v) { + $v = self::toArray($v); + } + } elseif ($input instanceof Model) { + $input = $input->toMap(); + foreach ($input as $k => &$v) { + $v = self::toArray($v); + } + } + + return $input; + } + + /** + * Assert a value, if it is a readable, return it, otherwise throws. + * + * @param mixed $value + * + * @return Stream the readable value + */ + public static function assertAsReadable($value) + { + if (\is_string($value)) { + return new Stream( + fopen('data://text/plain;base64,' . + base64_encode($value), 'r') + ); + } + if ($value instanceof Stream) { + return $value; + } + + throw new \InvalidArgumentException('It is not a stream value.'); + } +} diff --git a/vendor/alibabacloud/tea-utils/src/Utils/ExtendsParameters.php b/vendor/alibabacloud/tea-utils/src/Utils/ExtendsParameters.php new file mode 100644 index 0000000..670b2da --- /dev/null +++ b/vendor/alibabacloud/tea-utils/src/Utils/ExtendsParameters.php @@ -0,0 +1,38 @@ +headers) { + $res['headers'] = $this->headers; + } + if (null !== $this->queries) { + $res['queries'] = $this->queries; + } + return $res; + } + /** + * @param array $map + * @return ExtendsParameters + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['headers'])){ + $model->headers = $map['headers']; + } + if(isset($map['queries'])){ + $model->queries = $map['queries']; + } + return $model; + } + public $headers; + + public $queries; + +} diff --git a/vendor/alibabacloud/tea-utils/src/Utils/RuntimeOptions.php b/vendor/alibabacloud/tea-utils/src/Utils/RuntimeOptions.php new file mode 100644 index 0000000..5924228 --- /dev/null +++ b/vendor/alibabacloud/tea-utils/src/Utils/RuntimeOptions.php @@ -0,0 +1,273 @@ + 'autoretry', + 'ignoreSSL' => 'ignoreSSL', + 'key' => 'key', + 'cert' => 'cert', + 'ca' => 'ca', + 'maxAttempts' => 'max_attempts', + 'backoffPolicy' => 'backoff_policy', + 'backoffPeriod' => 'backoff_period', + 'readTimeout' => 'readTimeout', + 'connectTimeout' => 'connectTimeout', + 'httpProxy' => 'httpProxy', + 'httpsProxy' => 'httpsProxy', + 'noProxy' => 'noProxy', + 'maxIdleConns' => 'maxIdleConns', + 'localAddr' => 'localAddr', + 'socks5Proxy' => 'socks5Proxy', + 'socks5NetWork' => 'socks5NetWork', + 'keepAlive' => 'keepAlive', + ]; + public function validate() {} + public function toMap() { + $res = []; + if (null !== $this->autoretry) { + $res['autoretry'] = $this->autoretry; + } + if (null !== $this->ignoreSSL) { + $res['ignoreSSL'] = $this->ignoreSSL; + } + if (null !== $this->key) { + $res['key'] = $this->key; + } + if (null !== $this->cert) { + $res['cert'] = $this->cert; + } + if (null !== $this->ca) { + $res['ca'] = $this->ca; + } + if (null !== $this->maxAttempts) { + $res['max_attempts'] = $this->maxAttempts; + } + if (null !== $this->backoffPolicy) { + $res['backoff_policy'] = $this->backoffPolicy; + } + if (null !== $this->backoffPeriod) { + $res['backoff_period'] = $this->backoffPeriod; + } + if (null !== $this->readTimeout) { + $res['readTimeout'] = $this->readTimeout; + } + if (null !== $this->connectTimeout) { + $res['connectTimeout'] = $this->connectTimeout; + } + if (null !== $this->httpProxy) { + $res['httpProxy'] = $this->httpProxy; + } + if (null !== $this->httpsProxy) { + $res['httpsProxy'] = $this->httpsProxy; + } + if (null !== $this->noProxy) { + $res['noProxy'] = $this->noProxy; + } + if (null !== $this->maxIdleConns) { + $res['maxIdleConns'] = $this->maxIdleConns; + } + if (null !== $this->localAddr) { + $res['localAddr'] = $this->localAddr; + } + if (null !== $this->socks5Proxy) { + $res['socks5Proxy'] = $this->socks5Proxy; + } + if (null !== $this->socks5NetWork) { + $res['socks5NetWork'] = $this->socks5NetWork; + } + if (null !== $this->keepAlive) { + $res['keepAlive'] = $this->keepAlive; + } + if (null !== $this->extendsParameters) { + $res['extendsParameters'] = null !== $this->extendsParameters ? $this->extendsParameters->toMap() : null; + } + return $res; + } + /** + * @param array $map + * @return RuntimeOptions + */ + public static function fromMap($map = []) { + $model = new self(); + if(isset($map['autoretry'])){ + $model->autoretry = $map['autoretry']; + } + if(isset($map['ignoreSSL'])){ + $model->ignoreSSL = $map['ignoreSSL']; + } + if(isset($map['key'])){ + $model->key = $map['key']; + } + if(isset($map['cert'])){ + $model->cert = $map['cert']; + } + if(isset($map['ca'])){ + $model->ca = $map['ca']; + } + if(isset($map['max_attempts'])){ + $model->maxAttempts = $map['max_attempts']; + } + if(isset($map['backoff_policy'])){ + $model->backoffPolicy = $map['backoff_policy']; + } + if(isset($map['backoff_period'])){ + $model->backoffPeriod = $map['backoff_period']; + } + if(isset($map['readTimeout'])){ + $model->readTimeout = $map['readTimeout']; + } + if(isset($map['connectTimeout'])){ + $model->connectTimeout = $map['connectTimeout']; + } + if(isset($map['httpProxy'])){ + $model->httpProxy = $map['httpProxy']; + } + if(isset($map['httpsProxy'])){ + $model->httpsProxy = $map['httpsProxy']; + } + if(isset($map['noProxy'])){ + $model->noProxy = $map['noProxy']; + } + if(isset($map['maxIdleConns'])){ + $model->maxIdleConns = $map['maxIdleConns']; + } + if(isset($map['localAddr'])){ + $model->localAddr = $map['localAddr']; + } + if(isset($map['socks5Proxy'])){ + $model->socks5Proxy = $map['socks5Proxy']; + } + if(isset($map['socks5NetWork'])){ + $model->socks5NetWork = $map['socks5NetWork']; + } + if(isset($map['keepAlive'])){ + $model->keepAlive = $map['keepAlive']; + } + if(isset($map['extendsParameters'])){ + $model->extendsParameters = ExtendsParameters::fromMap($map['extendsParameters']); + } + return $model; + } + /** + * @description whether to try again + * @var bool + */ + public $autoretry; + + /** + * @description ignore SSL validation + * @var bool + */ + public $ignoreSSL; + + /** + * @description privite key for client certificate + * @var string + */ + public $key; + + /** + * @description client certificate + * @var string + */ + public $cert; + + /** + * @description server certificate + * @var string + */ + public $ca; + + /** + * @description maximum number of retries + * @var int + */ + public $maxAttempts; + + /** + * @description backoff policy + * @var string + */ + public $backoffPolicy; + + /** + * @description backoff period + * @var int + */ + public $backoffPeriod; + + /** + * @description read timeout + * @var int + */ + public $readTimeout; + + /** + * @description connect timeout + * @var int + */ + public $connectTimeout; + + /** + * @description http proxy url + * @var string + */ + public $httpProxy; + + /** + * @description https Proxy url + * @var string + */ + public $httpsProxy; + + /** + * @description agent blacklist + * @var string + */ + public $noProxy; + + /** + * @description maximum number of connections + * @var int + */ + public $maxIdleConns; + + /** + * @description local addr + * @var string + */ + public $localAddr; + + /** + * @description SOCKS5 proxy + * @var string + */ + public $socks5Proxy; + + /** + * @description SOCKS5 netWork + * @var string + */ + public $socks5NetWork; + + /** + * @description whether to enable keep-alive + * @var bool + */ + public $keepAlive; + + /** + * @description Extends Parameters + * @var ExtendsParameters + */ + public $extendsParameters; + +} diff --git a/vendor/alibabacloud/tea-utils/tests/UtilsTest.php b/vendor/alibabacloud/tea-utils/tests/UtilsTest.php new file mode 100644 index 0000000..70d54f4 --- /dev/null +++ b/vendor/alibabacloud/tea-utils/tests/UtilsTest.php @@ -0,0 +1,550 @@ +assertEquals([ + 115, 116, 114, 105, 110, 103, + ], Utils::toBytes('string')); + $this->assertEquals([ + 115, 116, 114, 105, 110, 103, + ], Utils::toBytes([ + 115, 116, 114, 105, 110, 103, + ])); + } + + public function testToString() + { + $this->assertEquals('string', Utils::toString([ + 115, 116, 114, 105, 110, 103, + ])); + $this->assertEquals('string', Utils::toString('string')); + } + + public function testParseJSON() + { + $this->assertEquals([ + 'a' => 'b', + ], Utils::parseJSON('{"a":"b"}')); + } + + public function testReadAsBytes() + { + $bytes = Utils::readAsBytes($this->getStream()); + $this->assertEquals(123, $bytes[0]); + } + + public function testReadAsString() + { + $string = Utils::readAsString($this->getStream()); + $this->assertEquals($string[0], '{'); + } + + public function testReadAsJSON() + { + $result = Utils::readAsJSON($this->getStream()); + $this->assertEquals('http://httpbin.org/get', $result['url']); + } + + public function testGetNonce() + { + $nonce1 = Utils::getNonce(); + $nonce2 = Utils::getNonce(); + + $this->assertNotEquals($nonce1, $nonce2); + } + + public function testGetDateUTCString() + { + $gmdate = Utils::getDateUTCString(); + $now = time(); + $this->assertTrue(abs($now - strtotime($gmdate)) <= 1); + } + + public function testDefaultString() + { + $this->assertEquals('', Utils::defaultString(null)); + $this->assertEquals('default', Utils::defaultString(null, 'default')); + $this->assertEquals('real', Utils::defaultString('real', 'default')); + } + + public function testDefaultNumber() + { + $this->assertEquals(0, Utils::defaultNumber(null)); + $this->assertEquals(0, Utils::defaultNumber(0, 3)); + $this->assertEquals(404, Utils::defaultNumber(null, 404)); + $this->assertEquals(200, Utils::defaultNumber(200, 404)); + } + + public function testToFormString() + { + $query = [ + 'foo' => 'bar', + 'empty' => '', + 'a' => null, + 'withWhiteSpace' => 'a b', + ]; + $this->assertEquals('foo=bar&empty=&withWhiteSpace=a%20b', Utils::toFormString($query)); + + $object = json_decode(json_encode($query)); + $this->assertEquals('foo=bar&empty=&withWhiteSpace=a%20b', Utils::toFormString($object)); + } + + public function testToJSONString() + { + $object = new \stdClass(); + $this->assertJson(Utils::toJSONString($object)); + $this->assertEquals('[]', Utils::toJSONString([])); + $this->assertEquals('["foo"]', Utils::toJSONString(['foo'])); + $this->assertEquals( + '{"str":"test","number":1,"bool":false,"null":null,"chinese":"中文","http":"https://aliyun.com:8080/zh/中文.html"}', + Utils::toJSONString([ + 'str' => 'test', + 'number' => 1, + 'bool' => FALSE, + 'null' => null, + 'chinese' => '中文', + 'http' => 'https://aliyun.com:8080/zh/中文.html', + ]) + ); + $this->assertEquals('1', Utils::toJSONString(1)); + $this->assertEquals('true', Utils::toJSONString(TRUE)); + $this->assertEquals('null', Utils::toJSONString(null)); + } + + public function testEmpty() + { + $this->assertTrue(Utils::_empty('')); + $this->assertFalse(Utils::_empty('not empty')); + } + + public function testEqualString() + { + $this->assertTrue(Utils::equalString('a', 'a')); + $this->assertFalse(Utils::equalString('a', 'b')); + } + + public function testEqualNumber() + { + $this->assertTrue(Utils::equalNumber(1, 1)); + $this->assertFalse(Utils::equalNumber(1, 2)); + } + + public function testIsUnset() + { + $this->assertTrue(Utils::isUnset($a)); + $b = 1; + $this->assertFalse(Utils::isUnset($b)); + } + + public function testStringifyMapValue() + { + $this->assertEquals([], Utils::stringifyMapValue(null)); + $this->assertEquals([ + 'foo' => 'bar', + 'null' => '', + 'true' => 'true', + 'false' => 'false', + 'number' => '1000', + ], Utils::stringifyMapValue([ + 'foo' => 'bar', + 'null' => null, + 'true' => true, + 'false' => false, + 'number' => 1000, + ])); + } + + public function testAnyifyMapValue() + { + $this->assertEquals([ + 'foo' => 'bar', + 'null' => null, + 'true' => true, + 'false' => false, + 'number' => 1000, + ], Utils::anyifyMapValue([ + 'foo' => 'bar', + 'null' => null, + 'true' => true, + 'false' => false, + 'number' => 1000, + ])); + } + + public function testAssertAsBoolean() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a boolean value.'); + Utils::assertAsBoolean('true'); + + try { + $map = true; + $this->assertEquals($map, Utils::assertAsBoolean($map)); + } catch (\Exception $e) { + // should not be here + $this->assertTrue(false); + } + } + + public function testAssertAsString() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a string value.'); + Utils::assertAsString(123); + + try { + $map = '123'; + $this->assertEquals($map, Utils::assertAsString($map)); + } catch (\Exception $e) { + // should not be here + $this->assertTrue(false); + } + } + + public function testAssertAsBytes() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a bytes value.'); + // failed because $var is not array + Utils::assertAsBytes('test'); + // failed because $var is map not array + Utils::assertAsBytes(['foo' => 1]); + // failed because item value is not int + Utils::assertAsBytes(['1']); + // failed because item value is out off range + Utils::assertAsBytes([256]); + + try { + // success + $map = [1, 2, 3]; + $this->assertEquals($map, Utils::assertAsBytes($map)); + $this->assertEquals([ + 115, 116, 114, 105, 110, 103, + ], Utils::assertAsBytes(Utils::toBytes('string'))); + } catch (\Exception $e) { + // should not be here + $this->assertTrue(false); + } + } + + public function testAssertAsNumber() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a number value.'); + Utils::assertAsNumber('is not number'); + + try { + $map = 123; + $this->assertEquals($map, Utils::assertAsNumber($map)); + } catch (\Exception $e) { + // should not be here + $this->assertTrue(false); + } + } + + public function testAssertAsInteger() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a int value.'); + Utils::assertAsInteger('is not int'); + + try { + $map = 123; + $this->assertEquals($map, Utils::assertAsInteger($map)); + } catch (\Exception $e) { + // should not be here + $this->assertTrue(false); + } + } + + public function testAssertAsMap() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a map value.'); + Utils::assertAsMap('is not array'); + + try { + $map = ['foo' => 'bar']; + $this->assertEquals($map, Utils::assertAsMap($map)); + } catch (\Exception $e) { + // should not be here + $this->assertTrue(false); + } + } + + public function testAssertAsArray() + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a array value.'); + Utils::assertAsArray('is not array'); + + try { + $map = ['foo']; + $this->assertEquals($map, Utils::assertAsArray($map)); + } catch (\Exception $e) { + // should not be here + $this->assertTrue(false); + } + } + + public function testGetUserAgent() + { + $this->assertTrue(false !== strpos(Utils::getUserAgent('CustomUserAgent'), 'CustomUserAgent')); + } + + public function testIs2xx() + { + $this->assertTrue(Utils::is2xx(200)); + $this->assertFalse(Utils::is2xx(300)); + } + + public function testIs3xx() + { + $this->assertTrue(Utils::is3xx(300)); + $this->assertFalse(Utils::is3xx(400)); + } + + public function testIs4xx() + { + $this->assertTrue(Utils::is4xx(400)); + $this->assertFalse(Utils::is4xx(500)); + } + + public function testIs5xx() + { + $this->assertTrue(Utils::is5xx(500)); + $this->assertFalse(Utils::is5xx(600)); + } + + public function testToMap() + { + $from = new RequestTest(); + $from->query = new RequestTestQuery([ + 'booleanParamInQuery' => true, + 'mapParamInQuery' => [1, 2, 3], + ]); + $this->assertTrue($from->query->booleanParamInQuery); + $this->assertEquals([1, 2, 3], $from->query->mapParamInQuery); + + $target = new RequestShrinkTest([]); + $this->convert($from, $target); + $this->assertEquals([ + 'BooleanParamInQuery' => true, + 'MapParamInQuery' => [1, 2, 3], + ], $target->query->toMap()); + + $target->query->mapParamInQueryShrink = json_encode($from->query->mapParamInQuery); + $this->assertEquals([ + 'BooleanParamInQuery' => true, + 'MapParamInQuery' => '[1,2,3]', + ], Utils::toMap($target->query)); + } + + public function testSleep() + { + $before = microtime(true) * 1000; + Utils::sleep(1000); + $after = microtime(true) * 1000; + $sub = $after - $before; + $this->assertTrue(990 <= $sub && $sub <= 1100); + } + + public function testToArray() + { + $model = new RequestTest(); + $model->query = 'foo'; + $this->assertEquals([ + ['query' => 'foo'], + ], Utils::toArray([$model])); + + $subModel = new RequestTest(); + $subModel->query = 'bar'; + $model->query = $subModel; + $this->assertEquals([ + ['query' => ['query' => 'bar']], + ], Utils::toArray([$model])); + } + + public function testAssertAsReadable() + { + $s0 = Utils::assertAsReadable('string content'); + $this->assertTrue($s0 instanceof Stream); + + $s1 = Utils::assertAsReadable($s0); + $this->assertEquals($s1, $s0); + + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('It is not a stream value.'); + Utils::assertAsReadable(0); + } + + public function testRuntimeOptions() + { + $opts = new RuntimeOptions([ + "autoretry" => false, + "ignoreSSL" => false, + "key" => "key", + "cert" => "cert", + "ca" => "ca", + "maxAttempts" => 3, + "backoffPolicy" => "backoffPolicy", + "backoffPeriod" => 10, + "readTimeout" => 3000, + "connectTimeout" => 3000, + "httpProxy" => "httpProxy", + "httpsProxy" => "httpsProxy", + "noProxy" => "noProxy", + "maxIdleConns" => 300, + "keepAlive" => true, + "extendsParameters" => new ExtendsParameters([ + "headers" => ['key' => 'value'], + "queries" => ['key' => 'value'], + ]), + ]); + $this->assertEquals(false, $opts->autoretry); + $this->assertEquals(false, $opts->ignoreSSL); + $this->assertEquals("key", $opts->key); + $this->assertEquals("cert", $opts->cert); + $this->assertEquals("ca", $opts->ca); + $this->assertEquals(3, $opts->maxAttempts); + $this->assertEquals("backoffPolicy", $opts->backoffPolicy); + $this->assertEquals(10, $opts->backoffPeriod); + $this->assertEquals(3000, $opts->readTimeout); + $this->assertEquals(3000, $opts->connectTimeout); + $this->assertEquals("httpProxy", $opts->httpProxy); + $this->assertEquals("httpsProxy", $opts->httpsProxy); + $this->assertEquals("noProxy", $opts->noProxy); + $this->assertEquals(300, $opts->maxIdleConns); + $this->assertEquals(true, $opts->keepAlive); + $this->assertEquals('value', $opts->extendsParameters->headers['key']); + $this->assertEquals('value', $opts->extendsParameters->queries['key']); + } + + private function convert($body, &$content) + { + $class = new \ReflectionClass($body); + foreach ($class->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { + $name = $property->getName(); + if (!$property->isStatic()) { + $value = $property->getValue($body); + if ($value instanceof StreamInterface) { + continue; + } + $content->{$name} = $value; + } + } + } +} + +/** + * @internal + * @coversNothing + */ +class RequestTest extends Model +{ + /** + * @var RequestTestQuery + */ + public $query; +} + +/** + * @internal + * @coversNothing + */ +class RequestShrinkTest extends Model +{ + /** + * @var RequestTestShrinkQuery + */ + public $query; +} + +class RequestTestQuery extends Model +{ + /** + * @description test + * + * @var bool + */ + public $booleanParamInQuery; + + /** + * @description test + * + * @var array + */ + public $mapParamInQuery; + protected $_name = [ + 'booleanParamInQuery' => 'BooleanParamInQuery', + 'mapParamInQuery' => 'MapParamInQuery', + ]; + + public function toMap() + { + $res = []; + if (null !== $this->booleanParamInQuery) { + $res['BooleanParamInQuery'] = $this->booleanParamInQuery; + } + if (null !== $this->mapParamInQuery) { + $res['MapParamInQuery'] = $this->mapParamInQuery; + } + + return $res; + } +} + +class RequestTestShrinkQuery extends Model +{ + /** + * @description test + * + * @var float + */ + public $booleanParamInQuery; + + /** + * @description test + * + * @var string + */ + public $mapParamInQueryShrink; + protected $_name = [ + 'booleanParamInQuery' => 'BooleanParamInQuery', + 'mapParamInQueryShrink' => 'MapParamInQuery', + ]; + + public function toMap() + { + $res = []; + if (null !== $this->booleanParamInQuery) { + $res['BooleanParamInQuery'] = $this->booleanParamInQuery; + } + if (null !== $this->mapParamInQueryShrink) { + $res['MapParamInQuery'] = $this->mapParamInQueryShrink; + } + + return $res; + } +} diff --git a/vendor/alibabacloud/tea-utils/tests/bootstrap.php b/vendor/alibabacloud/tea-utils/tests/bootstrap.php new file mode 100644 index 0000000..c62c4e8 --- /dev/null +++ b/vendor/alibabacloud/tea-utils/tests/bootstrap.php @@ -0,0 +1,3 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/alibabacloud/tea-xml/README-CN.md b/vendor/alibabacloud/tea-xml/README-CN.md new file mode 100644 index 0000000..0ac19d8 --- /dev/null +++ b/vendor/alibabacloud/tea-xml/README-CN.md @@ -0,0 +1,31 @@ +English | [简体中文](README-CN.md) + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud Tea XML Library for PHP + +## Installation + +### Composer + +```bash +composer require alibabacloud/tea-xml +``` + +## Issues + +[Opening an Issue](https://github.com/aliyun/tea-xml/issues/new), Issues not conforming to the guidelines may be closed immediately. + +## Changelog + +Detailed changes for each release are documented in the [release notes](./ChangeLog.txt). + +## References + +* [Latest Release](https://github.com/aliyun/tea-xml) + +## License + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/alibabacloud/tea-xml/README.md b/vendor/alibabacloud/tea-xml/README.md new file mode 100644 index 0000000..b0f3ea0 --- /dev/null +++ b/vendor/alibabacloud/tea-xml/README.md @@ -0,0 +1,31 @@ +[English](README.md) | 简体中文 + +![](https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg) + +## Alibaba Cloud Tea XML Library for PHP + +## 安装 + +### Composer + +```bash +composer require alibabacloud/tea-xml +``` + +## 问题 + +[提交 Issue](https://github.com/aliyun/tea-xml/issues/new),不符合指南的问题可能会立即关闭。 + +## 发行说明 + +每个版本的详细更改记录在[发行说明](./ChangeLog.txt)中。 + +## 相关 + +* [最新源码](https://github.com/aliyun/tea-xml) + +## 许可证 + +[Apache-2.0](http://www.apache.org/licenses/LICENSE-2.0) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/alibabacloud/tea-xml/composer.json b/vendor/alibabacloud/tea-xml/composer.json new file mode 100644 index 0000000..5322b04 --- /dev/null +++ b/vendor/alibabacloud/tea-xml/composer.json @@ -0,0 +1,44 @@ +{ + "name": "alibabacloud/tea-xml", + "description": "Alibaba Cloud Tea XML Library for PHP", + "type": "library", + "license": "Apache-2.0", + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "require": { + "php": ">5.5" + }, + "require-dev": { + "phpunit/phpunit": "*", + "symfony/var-dumper": "*" + }, + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\XML\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "AlibabaCloud\\Tea\\XML\\Tests\\": "tests" + } + }, + "scripts": { + "fixer": "php-cs-fixer fix ./", + "test": [ + "@clearCache", + "phpunit --colors=always" + ], + "clearCache": "rm -rf cache/*" + }, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "optimize-autoloader": true + }, + "prefer-stable": true, + "minimum-stability": "dev" +} diff --git a/vendor/alibabacloud/tea-xml/phpunit.xml b/vendor/alibabacloud/tea-xml/phpunit.xml new file mode 100644 index 0000000..d43dde9 --- /dev/null +++ b/vendor/alibabacloud/tea-xml/phpunit.xml @@ -0,0 +1,32 @@ + + + + + + tests + + + ./tests + + + + + + integration + + + + + + + + + + + + ./src + + + diff --git a/vendor/alibabacloud/tea-xml/src/ArrayToXml.php b/vendor/alibabacloud/tea-xml/src/ArrayToXml.php new file mode 100644 index 0000000..d811c63 --- /dev/null +++ b/vendor/alibabacloud/tea-xml/src/ArrayToXml.php @@ -0,0 +1,151 @@ +version = $xmlVersion; + $this->encoding = $xmlEncoding; + } + + /** + * Build an XML Data Set. + * + * @param array $data Associative Array containing values to be parsed into an XML Data Set(s) + * @param string $startElement Root Opening Tag, default data + * + * @return string XML String containing values + * @return mixed Boolean false on failure, string XML result on success + */ + public function buildXML($data, $startElement = 'data') + { + if (!\is_array($data)) { + $err = 'Invalid variable type supplied, expected array not found on line ' . __LINE__ . ' in Class: ' . __CLASS__ . ' Method: ' . __METHOD__; + trigger_error($err); + + return false; //return false error occurred + } + $xml = new XmlWriter(); + $xml->openMemory(); + $xml->startDocument($this->version, $this->encoding); + $xml->startElement($startElement); + $data = $this->writeAttr($xml, $data); + $this->writeEl($xml, $data); + $xml->endElement(); //write end element + //returns the XML results + return $xml->outputMemory(true); + } + + /** + * Write keys in $data prefixed with @ as XML attributes, if $data is an array. + * When an @ prefixed key is found, a '%' key is expected to indicate the element itself, + * and '#' prefixed key indicates CDATA content. + * + * @param XMLWriter $xml object + * @param array $data with attributes filtered out + * + * @return array $data | $nonAttributes + */ + protected function writeAttr(XMLWriter $xml, $data) + { + if (\is_array($data)) { + $nonAttributes = []; + foreach ($data as $key => $val) { + //handle an attribute with elements + if ('@' == $key[0]) { + $xml->writeAttribute(substr($key, 1), $val); + } elseif ('%' == $key[0]) { + if (\is_array($val)) { + $nonAttributes = $val; + } else { + $xml->text($val); + } + } elseif ('#' == $key[0]) { + if (\is_array($val)) { + $nonAttributes = $val; + } else { + $xml->startElement(substr($key, 1)); + $xml->writeCData($val); + $xml->endElement(); + } + } elseif ('!' == $key[0]) { + if (\is_array($val)) { + $nonAttributes = $val; + } else { + $xml->writeCData($val); + } + } //ignore normal elements + else { + $nonAttributes[$key] = $val; + } + } + + return $nonAttributes; + } + + return $data; + } + + /** + * Write XML as per Associative Array. + * + * @param XMLWriter $xml object + * @param array $data Associative Data Array + */ + protected function writeEl(XMLWriter $xml, $data) + { + foreach ($data as $key => $value) { + if (\is_array($value) && !$this->isAssoc($value)) { //numeric array + foreach ($value as $itemValue) { + if (\is_array($itemValue)) { + $xml->startElement($key); + $itemValue = $this->writeAttr($xml, $itemValue); + $this->writeEl($xml, $itemValue); + $xml->endElement(); + } else { + $itemValue = $this->writeAttr($xml, $itemValue); + $xml->writeElement($key, "{$itemValue}"); + } + } + } elseif (\is_array($value)) { //associative array + $xml->startElement($key); + $value = $this->writeAttr($xml, $value); + $this->writeEl($xml, $value); + $xml->endElement(); + } else { //scalar + $value = $this->writeAttr($xml, $value); + $xml->writeElement($key, "{$value}"); + } + } + } + + /** + * Check if array is associative with string based keys + * FROM: http://stackoverflow.com/questions/173400/php-arrays-a-good-way-to-check-if-an-array-is-associative-or-sequential/4254008#4254008. + * + * @param array $array Array to check + * + * @return bool + */ + protected function isAssoc($array) + { + return (bool) \count(array_filter(array_keys($array), 'is_string')); + } +} diff --git a/vendor/alibabacloud/tea-xml/src/XML.php b/vendor/alibabacloud/tea-xml/src/XML.php new file mode 100644 index 0000000..3550e04 --- /dev/null +++ b/vendor/alibabacloud/tea-xml/src/XML.php @@ -0,0 +1,59 @@ + $v) { + if (isset($prop[$k])) { + $target[$k] = $v; + } + } + return $target; + } + } + + public static function toXML($array) + { + $arrayToXml = new ArrayToXml(); + if (\is_object($array)) { + $tmp = explode('\\', \get_class($array)); + $rootName = $tmp[\count($tmp) - 1]; + $data = json_decode(json_encode($array), true); + } else { + $tmp = $array; + reset($tmp); + $rootName = key($tmp); + $data = $array[$rootName]; + } + ksort($data); + + return $arrayToXml->buildXML($data, $rootName); + } + + private static function parse($xml) + { + if (\PHP_VERSION_ID < 80000) { + libxml_disable_entity_loader(true); + } + + return json_decode( + json_encode( + simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA) + ), + true + ); + } +} diff --git a/vendor/alibabacloud/tea-xml/tests/XMLTest.php b/vendor/alibabacloud/tea-xml/tests/XMLTest.php new file mode 100644 index 0000000..9bc5059 --- /dev/null +++ b/vendor/alibabacloud/tea-xml/tests/XMLTest.php @@ -0,0 +1,59 @@ +\n" . + "\n" . + " test\n" . + " 1\n" . + "\n"; + + public function testParseXml() + { + $res = XML::parseXml($this->xmlStr, new tests()); + $name = $res['name']; + $value = $res['value']; + $this->assertEquals('test', $name); + $this->assertEquals(1, $value); + + $res = XML::parseXml($this->xmlStr, null); + $name = $res['name']; + $value = $res['value']; + $this->assertEquals('test', $name); + $this->assertEquals(1, $value); + } + + public function testArrayToXML() + { + $data = [ + 'tests' => [ + 'name' => 'test', + 'value' => 1, + ], + ]; + $this->assertEquals("\ntest1", XML::toXML($data)); + } + + public function testObjectToXML() + { + $obj = new tests(); + $obj->name = 'test'; + $obj->value = 1; + $this->assertEquals("\ntest1", XML::toXML($obj)); + } +} + +class tests +{ + public $name = ''; + public $value = 0; +} diff --git a/vendor/alibabacloud/tea-xml/tests/bootstrap.php b/vendor/alibabacloud/tea-xml/tests/bootstrap.php new file mode 100644 index 0000000..c62c4e8 --- /dev/null +++ b/vendor/alibabacloud/tea-xml/tests/bootstrap.php @@ -0,0 +1,3 @@ +setRiskyAllowed(true) + ->setIndent(' ') + ->setRules([ + '@PSR2' => true, + '@PhpCsFixer' => true, + '@Symfony:risky' => true, + 'concat_space' => ['spacing' => 'one'], + 'array_syntax' => ['syntax' => 'short'], + 'array_indentation' => true, + 'combine_consecutive_unsets' => true, + 'method_separation' => true, + 'single_quote' => true, + 'declare_equal_normalize' => true, + 'function_typehint_space' => true, + 'hash_to_slash_comment' => true, + 'include' => true, + 'lowercase_cast' => true, + 'no_multiline_whitespace_before_semicolons' => true, + 'no_leading_import_slash' => true, + 'no_multiline_whitespace_around_double_arrow' => true, + 'no_spaces_around_offset' => true, + 'no_unneeded_control_parentheses' => true, + 'no_unused_imports' => true, + 'no_whitespace_before_comma_in_array' => true, + 'no_whitespace_in_blank_line' => true, + 'object_operator_without_whitespace' => true, + 'single_blank_line_before_namespace' => true, + 'single_class_element_per_statement' => true, + 'space_after_semicolon' => true, + 'standardize_not_equals' => true, + 'ternary_operator_spaces' => true, + 'trailing_comma_in_multiline_array' => true, + 'trim_array_spaces' => true, + 'unary_operator_spaces' => true, + 'whitespace_after_comma_in_array' => true, + 'no_extra_consecutive_blank_lines' => [ + 'curly_brace_block', + 'extra', + 'parenthesis_brace_block', + 'square_brace_block', + 'throw', + 'use', + ], + 'binary_operator_spaces' => [ + 'align_double_arrow' => true, + 'align_equals' => true, + ], + 'braces' => [ + 'allow_single_line_closure' => true, + ], + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('tests') + ->in(__DIR__) + ); diff --git a/vendor/alibabacloud/tea/CHANGELOG.md b/vendor/alibabacloud/tea/CHANGELOG.md new file mode 100644 index 0000000..a3b6a53 --- /dev/null +++ b/vendor/alibabacloud/tea/CHANGELOG.md @@ -0,0 +1,148 @@ +# CHANGELOG + +## 3.1.22 - 2021-05-11 + +- Deprecate `stream_for` method. + +## 3.1.21 - 2021-03-15 + +- Supported set proxy&timeout on request. + +## 3.1.20 - 2020-12-02 + +- Fix the warning when the Tea::merge method received empty arguments. + +## 3.1.19 - 2020-10-09 + +- Fix the error when the code value is a string. + +## 3.1.18 - 2020-09-28 + +- Require Guzzle Version 7.0 + +## 3.1.17 - 2020-09-24 + +- TeaUnableRetryError support get error info. + +## 3.1.16 - 2020-08-31 + +- Fix the Maximum function nesting level error when repeated network requests. + +## 3.1.15 - 2020-07-28 + +- Improved validatePattern method. + +## 3.1.14 - 2020-07-03 + +- Supported set properties of TeaError with `ErrorInfo`. + +## 3.1.13 - 2020-06-09 + +- Reduce dependencies. + +## 3.1.12 - 2020-05-13 + +- Add validate method. +- Supported validate maximun&minimun of property. + +## 3.1.11 - 2020-05-07 + +- Fixed error when class is undefined. + +## 3.1.10 - 2020-05-07 + +- Fixed error when '$item' of array is null + +## 3.1.9 - 2020-04-13 + +- TeaUnableRetryError add $lastException param. + +## 3.1.8 - 2020-04-02 + +- Added some static methods of Model to validate fields of Model. + +## 3.1.7 - 2020-03-27 + +- Improve Tea::isRetryable method. + +## 3.1.6 - 2020-03-25 + +- Fixed bug when body is StreamInterface. + +## 3.1.5 - 2020-03-25 + +- Improve Model.toMap method. +- Improve Tea.merge method. +- Fixed tests. + +## 3.1.4 - 2020-03-20 + +- Added Tea::merge method. +- Change Tea::isRetryable method. + +## 3.1.3 - 2020-03-20 + +- Model: added toModel method. + +## 3.1.2 - 2020-03-19 + +- Model constructor supported array type parameter. + +## 3.1.1 - 2020-03-18 + +- Fixed bug : set method failed. +- Fixed bug : get empty contents form body. + +## 3.1.0 - 2020-03-13 + +- TeaUnableRetryError add 'lastRequest' property. +- Change Tea.send() method return. +- Fixed Tea. allowRetry() method. + +## 3.0.0 - 2020-02-14 +- Rename package name. + +## 2.0.3 - 2020-02-14 +- Improved Exception. + +## 2.0.2 - 2019-09-11 +- Supported `String`. + +## 2.0.1 - 2019-08-15 +- Supported `IteratorAggregate`. + +## 2.0.0 - 2019-08-14 +- Design `Request` as a standard `PsrRequest`. + +## 1.0.10 - 2019-08-12 +- Added `__toString` for `Response`. + +## 1.0.9 - 2019-08-01 +- Updated `Middleware`. + +## 1.0.8 - 2019-07-29 +- Supported `TransferStats`. + +## 1.0.7 - 2019-07-27 +- Improved request. + +## 1.0.6 - 2019-07-23 +- Trim key for parameter. + +## 1.0.5 - 2019-07-23 +- Supported default protocol. + +## 1.0.4 - 2019-07-22 +- Added `toArray()`. + +## 1.0.3 - 2019-05-02 +- Improved `Request`. + +## 1.0.2 - 2019-05-02 +- Added getHeader/getHeaders. + +## 1.0.1 - 2019-04-02 +- Improved design. + +## 1.0.0 - 2019-05-02 +- Initial release of the AlibabaCloud Tea Version 1.0.0 on Packagist See for more information. diff --git a/vendor/alibabacloud/tea/LICENSE.md b/vendor/alibabacloud/tea/LICENSE.md new file mode 100644 index 0000000..ec13fcc --- /dev/null +++ b/vendor/alibabacloud/tea/LICENSE.md @@ -0,0 +1,13 @@ +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/vendor/alibabacloud/tea/README.md b/vendor/alibabacloud/tea/README.md new file mode 100644 index 0000000..a8cbe66 --- /dev/null +++ b/vendor/alibabacloud/tea/README.md @@ -0,0 +1,16 @@ + +## Installation +``` +composer require alibabacloud/tea --optimize-autoloader +``` +> Some users may not be able to install due to network problems, you can try to switch the Composer mirror. + + +## Changelog +Detailed changes for each release are documented in the [release notes](CHANGELOG.md). + + +## License +[Apache-2.0](LICENSE.md) + +Copyright (c) 2009-present, Alibaba Cloud All rights reserved. diff --git a/vendor/alibabacloud/tea/composer.json b/vendor/alibabacloud/tea/composer.json new file mode 100644 index 0000000..163689e --- /dev/null +++ b/vendor/alibabacloud/tea/composer.json @@ -0,0 +1,80 @@ +{ + "name": "alibabacloud/tea", + "homepage": "https://www.alibabacloud.com/", + "description": "Client of Tea for PHP", + "keywords": [ + "tea", + "client", + "alibabacloud", + "cloud" + ], + "type": "library", + "license": "Apache-2.0", + "support": { + "source": "https://github.com/aliyun/tea-php", + "issues": "https://github.com/aliyun/tea-php/issues" + }, + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com", + "homepage": "http://www.alibabacloud.com" + } + ], + "require": { + "php": ">=5.5", + "ext-curl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "ext-simplexml": "*", + "ext-xmlwriter": "*", + "guzzlehttp/guzzle": "^6.3|^7.0", + "adbario/php-dot-notation": "^2.4" + }, + "require-dev": { + "symfony/dotenv": "^3.4", + "phpunit/phpunit": "*", + "symfony/var-dumper": "^3.4" + }, + "suggest": { + "ext-sockets": "To use client-side monitoring" + }, + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "AlibabaCloud\\Tea\\Tests\\": "tests" + } + }, + "config": { + "sort-packages": true, + "preferred-install": "dist", + "optimize-autoloader": true + }, + "prefer-stable": true, + "minimum-stability": "dev", + "scripts": { + "cs": "phpcs --standard=PSR2 -n ./", + "cbf": "phpcbf --standard=PSR2 -n ./", + "fixer": "php-cs-fixer fix ./", + "test": [ + "@clearCache", + "phpunit --colors=always" + ], + "unit": [ + "@clearCache", + "phpunit --testsuite=Unit --colors=always" + ], + "feature": [ + "@clearCache", + "phpunit --testsuite=Feature --colors=always" + ], + "clearCache": "rm -rf cache/*", + "coverage": "open cache/coverage/index.html" + } +} diff --git a/vendor/alibabacloud/tea/src/Exception/TeaError.php b/vendor/alibabacloud/tea/src/Exception/TeaError.php new file mode 100644 index 0000000..f4ef0d9 --- /dev/null +++ b/vendor/alibabacloud/tea/src/Exception/TeaError.php @@ -0,0 +1,53 @@ +errorInfo = $errorInfo; + if (!empty($errorInfo)) { + $properties = ['name', 'message', 'code', 'data', 'description', 'accessDeniedDetail']; + foreach ($properties as $property) { + if (isset($errorInfo[$property])) { + $this->{$property} = $errorInfo[$property]; + if ($property === 'data' && isset($errorInfo['data']['statusCode'])) { + $this->statusCode = $errorInfo['data']['statusCode']; + } + } + } + } + } + + /** + * @return array + */ + public function getErrorInfo() + { + return $this->errorInfo; + } +} diff --git a/vendor/alibabacloud/tea/src/Exception/TeaRetryError.php b/vendor/alibabacloud/tea/src/Exception/TeaRetryError.php new file mode 100644 index 0000000..30aa7f8 --- /dev/null +++ b/vendor/alibabacloud/tea/src/Exception/TeaRetryError.php @@ -0,0 +1,21 @@ +getErrorInfo(); + } + parent::__construct($error_info, $lastException->getMessage(), $lastException->getCode(), $lastException); + $this->lastRequest = $lastRequest; + $this->lastException = $lastException; + } + + public function getLastRequest() + { + return $this->lastRequest; + } + + public function getLastException() + { + return $this->lastException; + } +} diff --git a/vendor/alibabacloud/tea/src/Helper.php b/vendor/alibabacloud/tea/src/Helper.php new file mode 100644 index 0000000..f1c0fd4 --- /dev/null +++ b/vendor/alibabacloud/tea/src/Helper.php @@ -0,0 +1,112 @@ + $ord) { + if ($k !== $i) { + return false; + } + if (!\is_int($ord)) { + return false; + } + if ($ord < 0 || $ord > 255) { + return false; + } + ++$i; + } + + return true; + } + + /** + * Convert a bytes to string(utf8). + * + * @param array $bytes + * + * @return string the return string + */ + public static function toString($bytes) + { + $str = ''; + foreach ($bytes as $ch) { + $str .= \chr($ch); + } + + return $str; + } + + /** + * @return array + */ + public static function merge(array $arrays) + { + $result = []; + foreach ($arrays as $array) { + foreach ($array as $key => $value) { + if (\is_int($key)) { + $result[] = $value; + + continue; + } + + if (isset($result[$key]) && \is_array($result[$key])) { + $result[$key] = self::merge( + [$result[$key], $value] + ); + + continue; + } + + $result[$key] = $value; + } + } + + return $result; + } +} diff --git a/vendor/alibabacloud/tea/src/Model.php b/vendor/alibabacloud/tea/src/Model.php new file mode 100644 index 0000000..538b55c --- /dev/null +++ b/vendor/alibabacloud/tea/src/Model.php @@ -0,0 +1,114 @@ + $v) { + $this->{$k} = $v; + } + } + } + + public function getName($name = null) + { + if (null === $name) { + return $this->_name; + } + + return isset($this->_name[$name]) ? $this->_name[$name] : $name; + } + + public function toMap() + { + $map = get_object_vars($this); + foreach ($map as $k => $m) { + if (0 === strpos($k, '_')) { + unset($map[$k]); + } + } + $res = []; + foreach ($map as $k => $v) { + $name = isset($this->_name[$k]) ? $this->_name[$k] : $k; + $res[$name] = $v; + } + + return $res; + } + + public function validate() + { + $vars = get_object_vars($this); + foreach ($vars as $k => $v) { + if (isset($this->_required[$k]) && $this->_required[$k] && empty($v)) { + throw new \InvalidArgumentException("{$k} is required."); + } + } + } + + public static function validateRequired($fieldName, $field, $val = null) + { + if (true === $val && null === $field) { + throw new \InvalidArgumentException($fieldName . ' is required'); + } + } + + public static function validateMaxLength($fieldName, $field, $val = null) + { + if (null !== $field && \strlen($field) > (int) $val) { + throw new \InvalidArgumentException($fieldName . ' is exceed max-length: ' . $val); + } + } + + public static function validateMinLength($fieldName, $field, $val = null) + { + if (null !== $field && \strlen($field) < (int) $val) { + throw new \InvalidArgumentException($fieldName . ' is less than min-length: ' . $val); + } + } + + public static function validatePattern($fieldName, $field, $regex = '') + { + if (null !== $field && '' !== $field && !preg_match("/^{$regex}$/", $field)) { + throw new \InvalidArgumentException($fieldName . ' is not match ' . $regex); + } + } + + public static function validateMaximum($fieldName, $field, $val) + { + if (null !== $field && $field > $val) { + throw new \InvalidArgumentException($fieldName . ' cannot be greater than ' . $val); + } + } + + public static function validateMinimum($fieldName, $field, $val) + { + if (null !== $field && $field < $val) { + throw new \InvalidArgumentException($fieldName . ' cannot be less than ' . $val); + } + } + + /** + * @param array $map + * @param Model $model + * + * @return mixed + */ + public static function toModel($map, $model) + { + $names = $model->getName(); + $names = array_flip($names); + foreach ($map as $key => $value) { + $name = isset($names[$key]) ? $names[$key] : $key; + $model->{$name} = $value; + } + + return $model; + } +} diff --git a/vendor/alibabacloud/tea/src/Parameter.php b/vendor/alibabacloud/tea/src/Parameter.php new file mode 100644 index 0000000..324a95d --- /dev/null +++ b/vendor/alibabacloud/tea/src/Parameter.php @@ -0,0 +1,50 @@ +toArray()); + } + + /** + * @return array + */ + public function getRealParameters() + { + $array = []; + $obj = new ReflectionObject($this); + $properties = $obj->getProperties(); + + foreach ($properties as $property) { + $docComment = $property->getDocComment(); + $key = trim(Helper::findFromString($docComment, '@real', "\n")); + $value = $property->getValue($this); + $array[$key] = $value; + } + + return $array; + } + + /** + * @return array + */ + public function toArray() + { + return $this->getRealParameters(); + } +} diff --git a/vendor/alibabacloud/tea/src/Request.php b/vendor/alibabacloud/tea/src/Request.php new file mode 100644 index 0000000..db49142 --- /dev/null +++ b/vendor/alibabacloud/tea/src/Request.php @@ -0,0 +1,123 @@ +method = $method; + } + + /** + * These fields are compatible if you define other fields. + * Mainly for compatibility situations where the code generator cannot generate set properties. + * + * @return PsrRequest + */ + public function getPsrRequest() + { + $this->assertQuery($this->query); + + $request = clone $this; + + $uri = $request->getUri(); + if ($this->query) { + $uri = $uri->withQuery(http_build_query($this->query)); + } + + if ($this->port) { + $uri = $uri->withPort($this->port); + } + + if ($this->protocol) { + $uri = $uri->withScheme($this->protocol); + } + + if ($this->pathname) { + $uri = $uri->withPath($this->pathname); + } + + if (isset($this->headers['host'])) { + $uri = $uri->withHost($this->headers['host']); + } + + $request = $request->withUri($uri); + $request = $request->withMethod($this->method); + + if ('' !== $this->body && null !== $this->body) { + if ($this->body instanceof StreamInterface) { + $request = $request->withBody($this->body); + } else { + $body = $this->body; + if (Helper::isBytes($this->body)) { + $body = Helper::toString($this->body); + } + if (\function_exists('\GuzzleHttp\Psr7\stream_for')) { + // @deprecated stream_for will be removed in guzzlehttp/psr7:2.0 + $request = $request->withBody(\GuzzleHttp\Psr7\stream_for($body)); + } else { + $request = $request->withBody(\GuzzleHttp\Psr7\Utils::streamFor($body)); + } + } + } + + if ($this->headers) { + foreach ($this->headers as $key => $value) { + $request = $request->withHeader($key, $value); + } + } + + return $request; + } + + /** + * @param array $query + */ + private function assertQuery($query) + { + if (!\is_array($query) && $query !== null) { + throw new InvalidArgumentException('Query must be array.'); + } + } +} diff --git a/vendor/alibabacloud/tea/src/Response.php b/vendor/alibabacloud/tea/src/Response.php new file mode 100644 index 0000000..cb446e7 --- /dev/null +++ b/vendor/alibabacloud/tea/src/Response.php @@ -0,0 +1,372 @@ +getStatusCode(), + $response->getHeaders(), + $response->getBody(), + $response->getProtocolVersion(), + $response->getReasonPhrase() + ); + $this->headers = $response->getHeaders(); + $this->body = $response->getBody(); + $this->statusCode = $response->getStatusCode(); + if ($this->body->isSeekable()) { + $this->body->seek(0); + } + + if (Helper::isJson((string) $this->getBody())) { + $this->dot = new Dot($this->toArray()); + } else { + $this->dot = new Dot(); + } + } + + /** + * @return string + */ + public function __toString() + { + return (string) $this->getBody(); + } + + /** + * @param string $name + * + * @return null|mixed + */ + public function __get($name) + { + $data = $this->dot->all(); + if (!isset($data[$name])) { + return null; + } + + return json_decode(json_encode($data))->{$name}; + } + + /** + * @param string $name + * @param mixed $value + */ + public function __set($name, $value) + { + $this->dot->set($name, $value); + } + + /** + * @param string $name + * + * @return bool + */ + public function __isset($name) + { + return $this->dot->has($name); + } + + /** + * @param $offset + */ + public function __unset($offset) + { + $this->dot->delete($offset); + } + + /** + * @return array + */ + public function toArray() + { + return \GuzzleHttp\json_decode((string) $this->getBody(), true); + } + + /** + * @param array|int|string $keys + * @param mixed $value + */ + public function add($keys, $value = null) + { + return $this->dot->add($keys, $value); + } + + /** + * @return array + */ + public function all() + { + return $this->dot->all(); + } + + /** + * @param null|array|int|string $keys + */ + public function clear($keys = null) + { + return $this->dot->clear($keys); + } + + /** + * @param array|int|string $keys + */ + public function delete($keys) + { + return $this->dot->delete($keys); + } + + /** + * @param string $delimiter + * @param null|array $items + * @param string $prepend + * + * @return array + */ + public function flatten($delimiter = '.', $items = null, $prepend = '') + { + return $this->dot->flatten($delimiter, $items, $prepend); + } + + /** + * @param null|int|string $key + * @param mixed $default + * + * @return mixed + */ + public function get($key = null, $default = null) + { + return $this->dot->get($key, $default); + } + + /** + * @param array|int|string $keys + * + * @return bool + */ + public function has($keys) + { + return $this->dot->has($keys); + } + + /** + * @param null|array|int|string $keys + * + * @return bool + */ + public function isEmpty($keys = null) + { + return $this->dot->isEmpty($keys); + } + + /** + * @param array|self|string $key + * @param array|self $value + */ + public function merge($key, $value = []) + { + return $this->dot->merge($key, $value); + } + + /** + * @param array|self|string $key + * @param array|self $value + */ + public function mergeRecursive($key, $value = []) + { + return $this->dot->mergeRecursive($key, $value); + } + + /** + * @param array|self|string $key + * @param array|self $value + */ + public function mergeRecursiveDistinct($key, $value = []) + { + return $this->dot->mergeRecursiveDistinct($key, $value); + } + + /** + * @param null|int|string $key + * @param mixed $default + * + * @return mixed + */ + public function pull($key = null, $default = null) + { + return $this->dot->pull($key, $default); + } + + /** + * @param null|int|string $key + * @param mixed $value + * + * @return mixed + */ + public function push($key = null, $value = null) + { + return $this->dot->push($key, $value); + } + + /** + * Replace all values or values within the given key + * with an array or Dot object. + * + * @param array|self|string $key + * @param array|self $value + */ + public function replace($key, $value = []) + { + return $this->dot->replace($key, $value); + } + + /** + * Set a given key / value pair or pairs. + * + * @param array|int|string $keys + * @param mixed $value + */ + public function set($keys, $value = null) + { + return $this->dot->set($keys, $value); + } + + /** + * Replace all items with a given array. + * + * @param mixed $items + */ + public function setArray($items) + { + return $this->dot->setArray($items); + } + + /** + * Replace all items with a given array as a reference. + */ + public function setReference(array &$items) + { + return $this->dot->setReference($items); + } + + /** + * Return the value of a given key or all the values as JSON. + * + * @param mixed $key + * @param int $options + * + * @return string + */ + public function toJson($key = null, $options = 0) + { + return $this->dot->toJson($key, $options); + } + + /** + * Retrieve an external iterator. + */ + #[\ReturnTypeWillChange] + public function getIterator() + { + return $this->dot->getIterator(); + } + + /** + * Whether a offset exists. + * + * @param $offset + * + * @return bool + */ + #[\ReturnTypeWillChange] + public function offsetExists($offset) + { + return $this->dot->offsetExists($offset); + } + + /** + * Offset to retrieve. + * + * @param $offset + * + * @return mixed + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return $this->dot->offsetGet($offset); + } + + /** + * Offset to set. + * + * @param $offset + * @param $value + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + $this->dot->offsetSet($offset, $value); + } + + /** + * Offset to unset. + * + * @param $offset + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + $this->dot->offsetUnset($offset); + } + + /** + * Count elements of an object. + * + * @param null $key + * + * @return int + */ + #[\ReturnTypeWillChange] + public function count($key = null) + { + return $this->dot->count($key); + } +} diff --git a/vendor/alibabacloud/tea/src/Tea.php b/vendor/alibabacloud/tea/src/Tea.php new file mode 100644 index 0000000..a138ad9 --- /dev/null +++ b/vendor/alibabacloud/tea/src/Tea.php @@ -0,0 +1,287 @@ +getPsrRequest(); + } + + $config = self::resolveConfig($config); + + $res = self::client()->send( + $request, + $config + ); + + return new Response($res); + } + + /** + * @return PromiseInterface + */ + public static function sendAsync(RequestInterface $request, array $config = []) + { + if (method_exists($request, 'getPsrRequest')) { + $request = $request->getPsrRequest(); + } + + $config = self::resolveConfig($config); + + return self::client()->sendAsync( + $request, + $config + ); + } + + /** + * @return Client + */ + public static function client(array $config = []) + { + if (isset(self::$config['handler'])) { + $stack = self::$config['handler']; + } else { + $stack = HandlerStack::create(); + $stack->push(Middleware::mapResponse(static function (ResponseInterface $response) { + return new Response($response); + })); + } + + self::$config['handler'] = $stack; + + if (!isset(self::$config['on_stats'])) { + self::$config['on_stats'] = function (TransferStats $stats) { + Response::$info = $stats->getHandlerStats(); + }; + } + + $new_config = Helper::merge([self::$config, $config]); + + return new Client($new_config); + } + + /** + * @param string $method + * @param string|UriInterface $uri + * @param array $options + * + * @throws GuzzleException + * + * @return ResponseInterface + */ + public static function request($method, $uri, $options = []) + { + return self::client()->request($method, $uri, $options); + } + + /** + * @param string $method + * @param string $uri + * @param array $options + * + * @throws GuzzleException + * + * @return string + */ + public static function string($method, $uri, $options = []) + { + return (string) self::client()->request($method, $uri, $options) + ->getBody(); + } + + /** + * @param string $method + * @param string|UriInterface $uri + * @param array $options + * + * @return PromiseInterface + */ + public static function requestAsync($method, $uri, $options = []) + { + return self::client()->requestAsync($method, $uri, $options); + } + + /** + * @param string|UriInterface $uri + * @param array $options + * + * @throws GuzzleException + * + * @return null|mixed + */ + public static function getHeaders($uri, $options = []) + { + return self::request('HEAD', $uri, $options)->getHeaders(); + } + + /** + * @param string|UriInterface $uri + * @param string $key + * @param null|mixed $default + * + * @throws GuzzleException + * + * @return null|mixed + */ + public static function getHeader($uri, $key, $default = null) + { + $headers = self::getHeaders($uri); + + return isset($headers[$key][0]) ? $headers[$key][0] : $default; + } + + /** + * @param int $retryTimes + * @param float $now + * + * @return bool + */ + public static function allowRetry(array $runtime, $retryTimes, $now) + { + unset($now); + if (!isset($retryTimes) || null === $retryTimes || !\is_numeric($retryTimes)) { + return false; + } + if ($retryTimes > 0 && (empty($runtime) || !isset($runtime['retryable']) || !$runtime['retryable'] || !isset($runtime['maxAttempts']))) { + return false; + } + $maxAttempts = $runtime['maxAttempts']; + $retry = empty($maxAttempts) ? 0 : (int) $maxAttempts; + + return $retry >= $retryTimes; + } + + /** + * @param int $retryTimes + * + * @return int + */ + public static function getBackoffTime(array $runtime, $retryTimes) + { + $backOffTime = 0; + $policy = isset($runtime['policy']) ? $runtime['policy'] : ''; + + if (empty($policy) || 'no' == $policy) { + return $backOffTime; + } + + $period = isset($runtime['period']) ? $runtime['period'] : ''; + if (null !== $period && '' !== $period) { + $backOffTime = (int) $period; + if ($backOffTime <= 0) { + return $retryTimes; + } + } + + return $backOffTime; + } + + public static function sleep($time) + { + sleep($time); + } + + public static function isRetryable($retry, $retryTimes = 0) + { + if ($retry instanceof TeaError) { + return true; + } + if (\is_array($retry)) { + $max = isset($retry['maxAttempts']) ? (int) ($retry['maxAttempts']) : 3; + + return $retryTimes <= $max; + } + + return false; + } + + /** + * @param mixed|Model[] ...$item + * + * @return mixed + */ + public static function merge(...$item) + { + $tmp = []; + $n = 0; + foreach ($item as $i) { + if (\is_object($i)) { + if ($i instanceof Model) { + $i = $i->toMap(); + } else { + $i = json_decode(json_encode($i), true); + } + } + if (null === $i) { + continue; + } + if (\is_array($i)) { + $tmp[$n++] = $i; + } + } + + if (\count($tmp)) { + return \call_user_func_array('array_merge', $tmp); + } + + return []; + } + + private static function resolveConfig(array $config = []) + { + $options = new Dot(['http_errors' => false]); + if (isset($config['httpProxy']) && !empty($config['httpProxy'])) { + $options->set('proxy.http', $config['httpProxy']); + } + if (isset($config['httpsProxy']) && !empty($config['httpsProxy'])) { + $options->set('proxy.https', $config['httpsProxy']); + } + if (isset($config['noProxy']) && !empty($config['noProxy'])) { + $options->set('proxy.no', $config['noProxy']); + } + if (isset($config['ignoreSSL']) && !empty($config['ignoreSSL'])) { + $options->set('verify',!((bool)$config['ignoreSSL'])); + } + // readTimeout&connectTimeout unit is millisecond + $read_timeout = isset($config['readTimeout']) && !empty($config['readTimeout']) ? (int) $config['readTimeout'] : 0; + $con_timeout = isset($config['connectTimeout']) && !empty($config['connectTimeout']) ? (int) $config['connectTimeout'] : 0; + // timeout unit is second + $options->set('timeout', ($read_timeout + $con_timeout) / 1000); + + return $options->all(); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/.coveralls.yml b/vendor/aliyuncs/oss-sdk-php/.coveralls.yml new file mode 100644 index 0000000..850cc59 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/.coveralls.yml @@ -0,0 +1,2 @@ +coverage_clover: coverage.xml +json_path: coverage.json diff --git a/vendor/aliyuncs/oss-sdk-php/.gitignore b/vendor/aliyuncs/oss-sdk-php/.gitignore new file mode 100644 index 0000000..7cdb514 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/.gitignore @@ -0,0 +1,8 @@ +vendor +composer.lock +doc +output +.idea +.buildpath +.project +.settings diff --git a/vendor/aliyuncs/oss-sdk-php/.travis.yml b/vendor/aliyuncs/oss-sdk-php/.travis.yml new file mode 100644 index 0000000..0b40ba2 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/.travis.yml @@ -0,0 +1,21 @@ +language: php +php: + - 7.1 + - 7.0 + - 5.6 + - 5.5 + - 5.4 +install: + - composer self-update + - composer install --no-interaction +script: + - php vendor/bin/phpunit +after_success: + - php vendor/bin/coveralls -v +env: + global: + - secure: SzmQ854lQmhV6ZkAG7lQNTY3CkazrXnDSb6VMwPU/sdaLGxPO159AW3fJS5d0sO/XN1P8x5WNkoA4i9soDlLBRibEEISNUM/2EMnpszsRymZ9o97PrS2IgORXTUL/OF+rpATzyNVB2p+2l9hBLiGf17exMSA5iOeY7W6E+VKPGi8TFykgbGUnLKU0h1hV3rzmtfGjOXcSpvYU/hxeZD/J/+6m5Gic9b/pNS+AbfTj7Y7Ru9tNsnyUP29V/vtEYtpQir3ZxQiSiUv9idybgGnJBOMYydJofb/mpFYHhYLSWqtMKGNLpeawmqs4z8S1Tvx5U5uzW5+h/mpzhvBaFlWGpm8t89BQxun5LVX5NiYCrV7TqaLitGp1cSpMjMDnrnSTNzk1exVz+rWZZcWS7yB9ULYA681GA8StXWk167qB7Y30iK1dFK3+2mDN2cEY+qLs8+bupDowQ4eOM+eqfhxX8F8+ouKcKomETsjiIwL+CUsIe6wjvnYFWb1YlRhbsI75bblHApflohnt6gVSJ78ZPqID+u2oUMjmIWXLTnRR2Y2tgEW8uqHeIoQ8BBntLdQDmv0BO4FpnGQIwrUUwQYeNzEM0DOr3hWZhyDR6Xvl+9H0l52xjANaSqpuTZfC3zmeFTG7kIjydvxNePRrony6XAawL9BvI7aKWuVF6YVjPM= + - secure: nEhsU8aUQqsAJeuger+boh51oTpeo4YNG7vUWbKxdwVDIrcLb+l7r7RvTlxU7mt8IZTWwicgri18mh+Wi04BwX4ulBA1SCs8jPbL51KEo5izoDGGtLSd2fuPHdslYSrwagrvq90EPnDT/7fHWn/TAoT+rueZzjNyCu5IGSgL3GnXaUThsJ82NMePL2YRdP4Q1qmtZPRFBOkOQ6F0heuV8fw8sLyTO3txaCQum9YneGxrWxOl/E8zB0qtlnPwLE8ogaHZMQh2/jThmTbI5UqwRTxV4f0qoD5eJYH+j0fslsSAjsg/HPnSuVcnccK3zSU+s2sV4dPCcISzECJvZEObwipfxOGhdqt5gMcxHhn8qVsbT97iIh106pG/BJCDgQd2EeVW8WfCi6cCuCKIMipvVkMypkmjQHWU1XaqPzILl7g5diW9Ctp2C4Akq5dYdrdu8IrnVK1ShtkQVaWU+S/Bht8VU5gYP7olPW/GdTz7sceU1NOIC4NPXqmWKbfavR98U5dkHMLMvzABYL1Q87h+KhPD1c14NUyw3YENUW7REiF/X5lERRm5H0kJ/1JqAa+AgeHQEGmPVuZV2s/na4b0S1479QRVmSM/6ZzXQpU+Y8jCRfETpUFA4S331369kirHgCqDlxyIntuEKrzivD02/O+5C3eJ0WHRz6QsN2/R4qg= + - secure: ZTvzNXEZP4efl+a/3VGMmdabfUQp83v5/lecMns039Ro7UuZYPdtbPtpPnpjaTI6Htd22A4Rva5BU/3JCQJAyQvpbKNn5sGou2SmfQu3o0SyhggSB7gWjYAf707aW1j4bHYfP8IjDS5NjuVk3AqXeNSUuLRUXRmwSOB0lSYiRhiTJY+pUdBl382Hx4NbhIU/gmOzRoJCs7coTip8IURXYEHPi5dnDWluajxI+TgNXFccSgEleeQDJajYgXmpLb2EhSj8piipOnVgaCEE5bh5fbp32024Qq38SGHKcbfnwj2IInpZpZESJknRKoqAlFjdOJhork82dBcvAr5JxCBZKx5IuwXcTjxkQ6tRtBeqhPLPFuX3MQ8WrtU+wniPM0RCH/VoFkUKO7JGQDwmoi2AKago4PsuDs4P6Y6CeuOVpcso731GwwMNhIJcyrJJivXprQNEGsEw+9wLjU1qNYs6IIA3S/gPzFrNbdX5Wf8vxt0vLpgYvBNtPnLMejMtknuyfVzf5iKuVVoGPDTEz+ajs06+jfoPfm/4sLTaLghuVH7Adm74OpF769JQNnQYKwJuu4bNlcbLJChulCEMBOx7myqo/9O6RCTuqzHaGmVWNot4RGqRFHgJGl/JJf0WpAVitbhbRH3kGoyKb6jFM74CJbPsE7OORlJLDC3cdD3C8Pk= + - secure: Qr5NR4CVzBKCQgRgMH0x772TPJ1+brx3UCvtRNu8fi4j3p8bz+HDMjBaBDSFmEB09nunLI55/8mj88/5GXmnpFs8+CPTkcW+QZOcxg3cxpI4SNmxoB12/ZawlFHAqSUaRRE7RUWVkY3KL8tIGjEZcFyUBQ1DVNX3OMpiKs3NLtHa7oUIknyBxdSokm4kpLhSXYe7WmO0vhuZbMZE0S1EISToiBS6AdhGUEbTLJ/vNsIDY07fu6+Vh3HxVbyUFPqUZGlkZpQ+2xMJ3kiqPBMrXtRF/IhhPjORDil6Ns9SQ8/AAlaCddvYvRaT4Pjv2/aX+t3l28qI1qmryPtWXpce5UXecWGYqdRpSJc6Y/pEt4m4FeeGoEFWnSPGIs7FRmeiis8q2rojGZ18i4vI/k4iHmqEBnTlMp3SWnRb9L1adJ8ZAWln8aC88gkQXm67w7+1CxLycerbYj9H1ugqHENuHcxv4uHUcZgEENX3EWatu8i9+K2IUuU/2zcmpu7qtsziYcoyW8DOOmYpJfXGMLtmF9+pqp/Tp6i0tltFSEfmY3N8o7xvv3enLvFHsjL+3ElFdd1blUPSrvZJHgA9M3lJ+QF1RJZCpJqgPlQ0XOZK1Bf4P46zpEj01wKaK4JQrkLPRXhbBOuIJn5O6WlFJyPX4+SaBfwTzb4AvM4aUg2TgTg= + - secure: Inw5ftA8fxvhMHRZwoZzATxn4WICJsCq7ZX4y2gI+b/8u0JQIsbLgY9WTYV+XdSxOoNwuVa1oUxEWI0aDORtXKC3XaIXXKrwndag0zxS77JEYwWvQsjM7BhEbF7MF7MYk8rRXpn6mbfGAT/NfqEOx91RCY8UKeMzD0oPkpkBnJ9Ekuod6JBBq+7j3v4mYUItA8pxvw7b4Pdd4z2xzjgOwNhJYMOCpts50DWZI+WXj0HvTYaMXe5mJJtORK5lsr0a9cbsBqAzE6l+3zGI8XkgHn130ux5XH3DE7hZBeti3ZNaO3d2Vv+496/1EObG0rSFk+z3dmNKqjMz4nh3bYIkdLMegwmgCWs2mvQhkwYhzmnPRHVSERrgZjSWnuKn2PKnBar6tui9KaLNgpo2j3jWpwMLJ3bGAfE5JtMppxAxNqj/q+YB2UZo7Mn7EDjkTDjgxCuazTJwWqH7xxCOykWPABBI17P3JaOXQJEK39LavpfSMm3kdmU0ocpUs7FniLuFm6xL71VxY1wHG10yskczEcFHZ3iyIyGM+xum4vbt5y6Yg+zfdExYQsbrxHDDZ3HbHY3tEU0WhM55vrC42NIXRWqXqJ8OAxpl4nivfx96eoBAThiUU9xXtZmh7WRFVYsstoGtxZwfk5+bi+oeVO9kih4xabwbgHgL9BTc1TR1C4U= diff --git a/vendor/aliyuncs/oss-sdk-php/CHANGELOG.md b/vendor/aliyuncs/oss-sdk-php/CHANGELOG.md new file mode 100644 index 0000000..9cb0156 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/CHANGELOG.md @@ -0,0 +1,159 @@ +# ChangeLog - Aliyun OSS SDK for PHP + +## v2.7.2 / 2024-10-28 +* Added: presign supports response-* parameters +* Added: forcePathStyle option. + +## v2.7.1 / 2024-02-28 +* Fixed: fix deprecated + +## v2.7.0 / 2024-02-02 +* Added: support signature version 4. +* Added: support checkObjectEndcoding option. +* Added: support strictObjectName option. +* Added: support filePathCompatible option. +* Added: support path style. +* Added: support environment variables credentials provider. +* Update: add filed for some api. +* Fixed: fix some bugs. + +## v2.6.0 / 2022-08-03 +* Added: support credentials provider. +* Fixed: compatible with swoole curl handler. +* Added: support more bucket stat info. + +## v2.5.0 / 2022-05-13 +* Added: support bucket transfer acceleration. +* Added: support bucket cname token. +* Added: support listobjectsV2. + +## v2.4.3 / 2021-08-25 +* Fixed: integer overflow in PHP5.x. + +## v2.4.2 / 2021-06-04 +* Compatible with PHP8. +* Fixed: compatible with PHP5.4. +* Fixed: the signature is incorrect in some scenarios +* Update: change $requestUrl from a member variable to a local variable. + +## v2.4.1 / 2020-09-29 +* Fixed: the getBucketPolicy bug. + + +## v2.4.0 / 2020-08-31 + +* Added: disable Expect: 100-continue +* Added: support getBucketInfo +* Added: support getBucketStat +* Added: support bucket policy +* Added: support bucket encryption +* Added: support bucket tagging +* Added: support bucket worm +* Added: support versioning +* Added: support request payment +* Added: support object tagging +* Added: support code archive +* Added: support process object +* Added: support traffic limit paramter +* Added: support upload object from file handle +* Added: support getSimplifiedObjectMeta +* Fixed: the object name can not be '0' stirng. +* Update: endpoint validity check +* Update: add new pre-signed url api + + +## v2.3.1 / 2019-01-15 + +* translate chinese comments into english +* Added: endpoint validity check + +## v2.3.0 / 2018-01-05 + +* Fixed: putObject support creating empty files +* Fixed: createBucket support IA/Archive +* Added: support restoreObject +* Added: support the Symlink feature +* Added: support getBucketLocation +* Added: support getBucketMeta +* Added: support proxy server Proxy + +## v2.2.4 / 2017-04-25 + +* Fixed getObject to local file bug + +## v2.2.3 / 2017-04-14 + +* Fixed md5 check + +## v2.2.2 / 2017-01-18 + +* Resolve to run the connection number and memory bug on php7 + +## v2.2.1 / 2016-12-01 + +* No HTTP curl is allowed to automatically populate accept-encoding + +## v2.2.0 / 2016-11-22 + +* Fixed PutObject/CompleteMultipartUpload return values(#26) + +## v2.1.0 / 2016-11-12 + +* Added[RTMP](https://help.aliyun.com/document_detail/44297.html)interface +* Add support[image service](https://help.aliyun.com/document_detail/44686.html) + +## v2.0.7 / 2016-06-17 + +* Support append object + +## v2.0.6 + +* Trim access key id/secret and endpoint +* Refine tests and setup travis CI + +## v2.0.5 + +* Added Add/Delete/Get BucketCname interface + +## v2.0.4 + +* Added Put/Get Object Acl interface + +## v2.0.3 + +* Fixing the constants in Util is defined in a PHP version that is less than 5.6. + +## v2.0.2 + +* The problem of content-type cannot be specified when restoring multipart uploads + +## v2.0.1 + +* Increase the ListObjects/ListMultipartUploads special characters +* Provides the interface to get the details of the OssException + + +## 2015.11.25 + +* **Large version upgrade, no longer compatible with previous interface, new version has made great improvements to ease of use, suggesting that users migrate to a new version.** + +## Modify the content + +* PHP 5.2 is no longer supported + +### Add the cotent + +* Introduce namespace +* Interface naming and modification, using hump naming +* The interface is modified, and the common parameters are extracted from the Options parameter. +* The interface returns the result modification, processing the return result, and the user can directly get the data structure easily processed  +* OssClient's constructor changes +* The Endpoint address that support CNAME and IP formats +* Rearrange the sample file organization structure and use function to organize the function points +* Add an interface that sets the connection timeout and requests timeout +* Remove the outdated interface associated with the Object Group +* The message in the OssException is changed to English + +### Repair problem + +* The object name is not complete diff --git a/vendor/aliyuncs/oss-sdk-php/LICENSE.md b/vendor/aliyuncs/oss-sdk-php/LICENSE.md new file mode 100644 index 0000000..3183de8 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/LICENSE.md @@ -0,0 +1,21 @@ +#The MIT License (MIT) + +Copyright (c) ali-sdk and other contributors. + +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. \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/README-CN.md b/vendor/aliyuncs/oss-sdk-php/README-CN.md new file mode 100644 index 0000000..89c1e5a --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/README-CN.md @@ -0,0 +1,149 @@ +# Aliyun OSS SDK for PHP + +[![Latest Stable Version](https://poser.pugx.org/aliyuncs/oss-sdk-php/v/stable)](https://packagist.org/packages/aliyuncs/oss-sdk-php) +[![Build Status](https://travis-ci.org/aliyun/aliyun-oss-php-sdk.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-oss-php-sdk) +[![Coverage Status](https://coveralls.io/repos/github/aliyun/aliyun-oss-php-sdk/badge.svg?branch=master)](https://coveralls.io/github/aliyun/aliyun-oss-php-sdk?branch=master) + +## [README of English](https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/README.md) + +## 概述 + +阿里云对象存储(Object Storage Service,简称OSS),是阿里云对外提供的海量、安全、低成本、高可靠的云存储服务。用户可以通过调用API,在任何应用、任何时间、任何地点上传和下载数据,也可以通过用户Web控制台对数据进行简单的管理。OSS适合存放任意文件类型,适合各种网站、开发企业及开发者使用。 + + +## 运行环境 +- PHP 5.3+ +- cURL extension + +提示: + +- Ubuntu下可以使用apt-get包管理器安装php的cURL扩展 `sudo apt-get install php5-curl` + +## 安装方法 + +1. 如果您通过composer管理您的项目依赖,可以在你的项目根目录运行: + + $ composer require aliyuncs/oss-sdk-php + + 或者在你的`composer.json`中声明对Aliyun OSS SDK for PHP的依赖: + + "require": { + "aliyuncs/oss-sdk-php": "~2.0" + } + + 然后通过`composer install`安装依赖。composer安装完成后,在您的PHP代码中引入依赖即可: + + require_once __DIR__ . '/vendor/autoload.php'; + +2. 您也可以直接下载已经打包好的[phar文件][releases-page],然后在你 + 的代码中引入这个文件即可: + + require_once '/path/to/oss-sdk-php.phar'; + +3. 下载SDK源码,在您的代码中引入SDK目录下的`autoload.php`文件: + + require_once '/path/to/oss-sdk/autoload.php'; + +## 快速使用 + +### 常用类 + +| 类名 | 解释 | +|:------------------|:------------------------------------| +|OSS\OssClient | OSS客户端类,用户通过OssClient的实例调用接口 | +|OSS\Core\OssException | OSS异常类,用户在使用的过程中,只需要注意这个异常| + +### OssClient初始化 + +SDK的OSS操作通过OssClient类完成的,下面代码创建一个OssClient对象: + +```php +"; ; +$accessKeySecret = "<您从OSS获得的AccessKeySecret>"; +$endpoint = "<您选定的OSS数据中心访问域名,例如oss-cn-hangzhou.aliyuncs.com>"; +try { + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint); +} catch (OssException $e) { + print $e->getMessage(); +} +``` + +### 文件操作 + +文件(又称对象,Object)是OSS中最基本的数据单元,您可以把它简单地理解为文件,用下面代码可以实现一个Object的上传: + +```php +"; +$object = "<您使用的Object名字,注意命名规范>"; +$content = "Hello, OSS!"; // 上传的文件内容 +try { + $ossClient->putObject($bucket, $object, $content); +} catch (OssException $e) { + print $e->getMessage(); +} +``` + +### 存储空间操作 + +存储空间(又称Bucket)是一个用户用来管理所存储Object的存储空间,对于用户来说是一个管理Object的单元,所有的Object都必须隶属于某个Bucket。您可以按照下面的代码新建一个Bucket: + +```php +"; +try { + $ossClient->createBucket($bucket); +} catch (OssException $e) { + print $e->getMessage(); +} +``` + +### 返回结果处理 + +OssClient提供的接口返回返回数据分为两种: + +* Put,Delete类接口,接口返回null,如果没有OssException,即可认为操作成功 +* Get,List类接口,接口返回对应的数据,如果没有OssException,即可认为操作成功,举个例子: + +```php +listBuckets(); +$bucketList = $bucketListInfo->getBucketList(); +foreach($bucketList as $bucket) { + print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreateDate() . "\n"); +} +``` +上面代码中的$bucketListInfo的数据类型是 `OSS\Model\BucketListInfo` + + +### 运行Sample程序 + +1. 修改 `samples/Config.php`, 补充配置信息 +2. 执行 `cd samples/ && php RunAll.php` + +### 运行单元测试 + +1. 执行`composer install`下载依赖的库 +2. 设置环境变量 + + export OSS_ACCESS_KEY_ID=access-key-id + export OSS_ACCESS_KEY_SECRET=access-key-secret + export OSS_ENDPOINT=endpoint + export OSS_BUCKET=bucket-name + +3. 执行 `php vendor/bin/phpunit` + +## License + +- MIT + +## 联系我们 + +- [阿里云OSS官方网站](http://oss.aliyun.com) +- [阿里云OSS官方论坛](http://bbs.aliyun.com) +- [阿里云OSS官方文档中心](http://www.aliyun.com/product/oss#Docs) +- 阿里云官方技术支持:[提交工单](https://workorder.console.aliyun.com/#/ticket/createIndex) + +[releases-page]: https://github.com/aliyun/aliyun-oss-php-sdk/releases +[phar-composer]: https://github.com/clue/phar-composer diff --git a/vendor/aliyuncs/oss-sdk-php/README.md b/vendor/aliyuncs/oss-sdk-php/README.md new file mode 100644 index 0000000..b77a356 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/README.md @@ -0,0 +1,150 @@ +# Alibaba Cloud OSS SDK for PHP + +[![Latest Stable Version](https://poser.pugx.org/aliyuncs/oss-sdk-php/v/stable)](https://packagist.org/packages/aliyuncs/oss-sdk-php) +[![Build Status](https://travis-ci.org/aliyun/aliyun-oss-php-sdk.svg?branch=master)](https://travis-ci.org/aliyun/aliyun-oss-php-sdk) +[![Coverage Status](https://coveralls.io/repos/github/aliyun/aliyun-oss-php-sdk/badge.svg?branch=master)](https://coveralls.io/github/aliyun/aliyun-oss-php-sdk?branch=master) + +## [README of Chinese](https://github.com/aliyun/aliyun-oss-php-sdk/blob/master/README-CN.md) + +## Overview + +Alibaba Cloud Object Storage Service (OSS) is a cloud storage service provided by Alibaba Cloud, featuring a massive capacity, security, a low cost, and high reliability. You can upload and download data on any application anytime and anywhere by calling APIs, and perform simple management of data through the web console. The OSS can store any type of files and therefore applies to various websites, development enterprises and developers. + + +## Run environment +- PHP 5.3+. +- cURL extension. + +Tips: + +- In Ubuntu, you can use the ***apt-get*** package manager to install the *PHP cURL extension*: `sudo apt-get install php5-curl`. + +## Install OSS PHP SDK + +- If you use the ***composer*** to manage project dependencies, run the following command in your project's root directory: + + composer require aliyuncs/oss-sdk-php + + You can also declare the dependency on Alibaba Cloud OSS SDK for PHP in the `composer.json` file. + + "require": { + "aliyuncs/oss-sdk-php": "~2.0" + } + + Then run `composer install` to install the dependency. After the Composer Dependency Manager is installed, import the dependency in your PHP code: + + require_once __DIR__ . '/vendor/autoload.php'; + +- You can also directly download the packaged [PHAR File][releases-page], and + introduce the file to your code: + + require_once '/path/to/oss-sdk-php.phar'; + +- Download the SDK source code, and introduce the `autoload.php` file under the SDK directory to your code: + + require_once '/path/to/oss-sdk/autoload.php'; + +## Quick use + +### Common classes + +| Class | Explanation | +|:------------------|:------------------------------------| +|OSS\OssClient | OSS client class. An OssClient instance can be used to call the interface. | +|OSS\Core\OssException |OSS Exception class . You only need to pay attention to this exception when you use the OssClient. | + +### Initialize an OssClient + +The SDK's operations for the OSS are performed through the OssClient class. The code below creates an OssClient object: + +```php +"; +$accessKeySecret = ""; +$endpoint = ""; +try { + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint); +} catch (OssException $e) { + print $e->getMessage(); +} +``` + +### Operations on objects + +Objects are the most basic data units on the OSS. You can simply consider objects as files. The following code uploads an object: + +```php +"; +$object = ""; +$content = "Hello, OSS!"; // Content of the uploaded file +try { + $ossClient->putObject($bucket, $object, $content); +} catch (OssException $e) { + print $e->getMessage(); +} +``` + +### Operations on buckets + +Buckets are the space that you use to manage the stored objects. It is an object management unit for users. Each object must belong to a bucket. You can create a bucket with the following code: + +```php +"; +try { + $ossClient->createBucket($bucket); +} catch (OssException $e) { + print $e->getMessage(); +} +``` + +### Handle returned results + +The OssClient provides the following two types of returned data from interfaces: + +- Put and Delete interfaces: The *PUT* and *DELETE* operations are deemed successful if *null* is returned by the interfaces without *OSSException*. +- Get and List interfaces: The *GET* and *LIST* operations are deemed successful if the desired data is returned by the interfaces without *OSSException*. For example, + + ```php + listBuckets(); + $bucketList = $bucketListInfo->getBucketList(); + foreach($bucketList as $bucket) { + print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreateDate() . "\n"); + } + ``` +In the above code, $bucketListInfo falls into the 'OSS\Model\BucketListInfo' data type. + + +### Run a sample project + +- Modify `samples/Config.php` to complete the configuration information. +- Run `cd samples/ && php RunAll.php`. + +### Run a unit test + +- Run `composer install` to download the dependent libraries. +- Set the environment variable. + + export OSS_ACCESS_KEY_ID=access-key-id + export OSS_ACCESS_KEY_SECRET=access-key-secret + export OSS_ENDPOINT=endpoint + export OSS_BUCKET=bucket-name + +- Run `php vendor/bin/phpunit` + +## License + +- MIT + +## Contact us + +- [Alibaba Cloud OSS official website](http://oss.aliyun.com). +- [Alibaba Cloud OSS official forum](http://bbs.aliyun.com). +- [Alibaba Cloud OSS official documentation center](http://www.aliyun.com/product/oss#Docs). +- Alibaba Cloud official technical support: [Submit a ticket](https://workorder.console.aliyun.com/#/ticket/createIndex). + +[releases-page]: https://github.com/aliyun/aliyun-oss-php-sdk/releases +[phar-composer]: https://github.com/clue/phar-composer + diff --git a/vendor/aliyuncs/oss-sdk-php/autoload.php b/vendor/aliyuncs/oss-sdk-php/autoload.php new file mode 100644 index 0000000..ec13201 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/autoload.php @@ -0,0 +1,11 @@ +=5.3" + }, + "require-dev" : { + "phpunit/phpunit": "*", + "php-coveralls/php-coveralls": "*" + }, + "minimum-stability": "stable", + "autoload": { + "psr-4": {"OSS\\": "src/OSS"} + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/example.jpg b/vendor/aliyuncs/oss-sdk-php/example.jpg new file mode 100644 index 0000000..ffd46a2 Binary files /dev/null and b/vendor/aliyuncs/oss-sdk-php/example.jpg differ diff --git a/vendor/aliyuncs/oss-sdk-php/index.php b/vendor/aliyuncs/oss-sdk-php/index.php new file mode 100644 index 0000000..cdc28bc --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/index.php @@ -0,0 +1,3 @@ + + + + + + + ./src + + + + + + + + ./tests + ./tests/OSS/Tests/BucketCnameTest.php + + + diff --git a/vendor/aliyuncs/oss-sdk-php/samples/Bucket.php b/vendor/aliyuncs/oss-sdk-php/samples/Bucket.php new file mode 100644 index 0000000..a54b74e --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/Bucket.php @@ -0,0 +1,254 @@ +createBucket($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); +Common::println("bucket $bucket created"); + +// Check whether a bucket exists +$doesExist = $ossClient->doesBucketExist($bucket); +Common::println("bucket $bucket exist? " . ($doesExist ? "yes" : "no")); + +// Get the region of bucket +$regions = $ossClient->getBucketLocation($bucket); +Common::println("bucket $bucket region: " .print_r($regions,true)); + +// Get the meta of a bucket +$metas = $ossClient->getBucketMeta($bucket); +Common::println("bucket $bucket meta: " .print_r($metas,true)); + +// Get the info of bucket +$info = $ossClient->getBucketInfo($bucket); +Common::println("bucket name:".$info->getName()."\n"); +Common::println("bucket location:". $info->getLocation()."\n"); +Common::println("bucket creation time:".$info->getCreateDate()."\n"); +Common::println("bucket storage class:".$info->getStorageClass()."\n"); +Common::println("bucket extranet endpoint:".$info->getExtranetEndpoint()."\n"); +Common::println("bucket intranet endpoint:".$info->getIntranetEndpoint()."\n"); + + +// Get the bucket list +$bucketListInfo = $ossClient->listBuckets(); + +// Set bucket ACL +$ossClient->putBucketAcl($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); +Common::println("bucket $bucket acl put"); +// Get bucket ACL +$acl = $ossClient->getBucketAcl($bucket); +Common::println("bucket $bucket acl get: " . $acl); + + +//******************************* For complete usage, see the following functions **************************************************** + +createBucket($ossClient, $bucket); +doesBucketExist($ossClient, $bucket); +getBucketLocation($ossClient, $bucket); +getBucketMeta($ossClient,$bucket); +getBucketInfo($ossClient, $bucket); +deleteBucket($ossClient, $bucket); +putBucketAcl($ossClient, $bucket); +getBucketAcl($ossClient, $bucket); +listBuckets($ossClient); + +/** + * Create a new bucket + * acl indicates the access permission of a bucket, including: private, public-read-only/private-read-write, and public read-write. + * Private indicates that only the bucket owner or authorized users can access the data.. + * The three permissions are separately defined by (OssClient::OSS_ACL_TYPE_PRIVATE,OssClient::OSS_ACL_TYPE_PUBLIC_READ, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE) + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function createBucket($ossClient, $bucket) +{ + try { + $ossClient->createBucket($bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Check whether a bucket exists. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + */ +function doesBucketExist($ossClient, $bucket) +{ + try { + $res = $ossClient->doesBucketExist($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + if ($res === true) { + print(__FUNCTION__ . ": OK" . "\n"); + } else { + print(__FUNCTION__ . ": FAILED" . "\n"); + } +} + +/** + * Get the info of bucket + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + */ +function getBucketInfo($ossClient, $bucket) +{ + try { + $info = $ossClient->getBucketInfo($bucket); + printf("bucket name:%s\n", $info->getName()); + printf("bucket location:%s\n", $info->getLocation()); + printf("bucket creation time:%s\n", $info->getCreateDate()); + printf("bucket storage class:%s\n", $info->getStorageClass()); + printf("bucket extranet endpoint:%s\n", $info->getExtranetEndpoint()); + printf("bucket intranet endpoint:%s\n", $info->getIntranetEndpoint()); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Get the meta of a bucket + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + */ +function getBucketLocation($ossClient, $bucket) +{ + try { + $regions = $ossClient->getBucketLocation($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print("bucket $bucket region: " .print_r($regions,true)); + +} + + +/** + * Get the bucket's meta + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + */ +function getBucketMeta($ossClient, $bucket) +{ + try { + $metas = $ossClient->getBucketMeta($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + print("bucket $bucket meta: " .print_r($metas,true)); +} + +/** + * Delete a bucket. If the bucket is not empty, the deletion fails. + * A bucket which is not empty indicates that it does not contain any objects or parts that are not completely uploaded during multipart upload + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to delete + * @return null + */ +function deleteBucket($ossClient, $bucket) +{ + try { + $ossClient->deleteBucket($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Set bucket ACL + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function putBucketAcl($ossClient, $bucket) +{ + $acl = OssClient::OSS_ACL_TYPE_PRIVATE; + try { + $ossClient->putBucketAcl($bucket, $acl); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Get bucket ACL + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getBucketAcl($ossClient, $bucket) +{ + try { + $res = $ossClient->getBucketAcl($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + print('acl: ' . $res); +} + + +/** + * List all buckets + * + * @param OssClient $ossClient OssClient instance + * @return null + */ +function listBuckets($ossClient) +{ + $bucketList = null; + try { + $bucketListInfo = $ossClient->listBuckets(); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + $bucketList = $bucketListInfo->getBucketList(); + foreach ($bucketList as $bucket) { + print($bucket->getLocation() . "\t" . $bucket->getName() . "\t" . $bucket->getCreatedate() . "\n"); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketCname.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketCname.php new file mode 100644 index 0000000..c39eb40 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketCname.php @@ -0,0 +1,91 @@ +'; +$ossClient->addBucketCname($bucket, $myDomain); + +// View cname records +$cnameConfig = $ossClient->getBucketCname($bucket); +Common::println("bucket $bucket cname:" . $cnameConfig->serializeToXml()); + +// Delete bucket cname +$myDomain = ''; +$ossClient->deleteBucketCname($bucket,$myDomain); +Common::println("bucket $bucket cname deleted"); + +//******************************* For complete usage, see the following functions **************************************************** + +addBucketCname($ossClient, $bucket); +getBucketCname($ossClient, $bucket); +deleteBucketCname($ossClient, $bucket); + +/** + * Set bucket cname + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function addBucketCname($ossClient, $bucket) +{ + // Set up a custom domain name. + $myDomain = ''; + try { + $ossClient->addBucketCname($bucket, $myDomain); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get bucket cname + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getBucketCname($ossClient, $bucket) +{ + try { + $cnameConfig = $ossClient->getBucketCname($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + print($cnameConfig->serializeToXml() . "\n"); +} + +/** + * Delete bucket cname + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteBucketCname($ossClient, $bucket) +{ + $myDomain = ''; + try { + $ossClient->deleteBucketCname($bucket, $myDomain); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketCors.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketCors.php new file mode 100644 index 0000000..f5f8f21 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketCors.php @@ -0,0 +1,171 @@ +addAllowedHeader("x-oss-header"); +$rule->addAllowedOrigin("http://www.b.com"); +$rule->addAllowedMethod("POST"); +$rule->setMaxAgeSeconds(10); +$corsConfig->addRule($rule); +$ossClient->putBucketCors($bucket, $corsConfig); +Common::println("bucket $bucket corsConfig created:" . $corsConfig->serializeToXml()); + +// Get cors configuration +$corsConfig = $ossClient->getBucketCors($bucket); + +if ($corsConfig->getResponseVary()){ + printf("Response Vary : true" .PHP_EOL); +}else{ + printf("Response Vary : false" .PHP_EOL); +} + +foreach ($corsConfig->getRules() as $key => $rule){ + if($rule->getAllowedHeaders()){ + foreach($rule->getAllowedHeaders() as $header){ + printf("Allowed Headers :" .$header .PHP_EOL); + } + } + if ($rule->getAllowedMethods()){ + foreach($rule->getAllowedMethods() as $method){ + printf("Allowed Methods :" .$method . PHP_EOL); + } + + } + if($rule->getAllowedOrigins()){ + foreach($rule->getAllowedOrigins() as $origin){ + printf("Allowed Origins :" .$origin , PHP_EOL); + } + + } + if($rule->getExposeHeaders()){ + foreach($rule->getExposeHeaders() as $exposeHeader){ + printf("Expose Headers :" .$exposeHeader . PHP_EOL); + } + } + printf("Max Age Seconds :" .$rule->getMaxAgeSeconds() .PHP_EOL); + +} + +// Delete cors configuration +$ossClient->deleteBucketCors($bucket); +Common::println("bucket $bucket corsConfig deleted"); + +//******************************* For complete usage, see the following functions ***************************************************** + +putBucketCors($ossClient, $bucket); +getBucketCors($ossClient, $bucket); +deleteBucketCors($ossClient, $bucket); +getBucketCors($ossClient, $bucket); + +/** + * Set bucket cores + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function putBucketCors($ossClient, $bucket) +{ + $corsConfig = new CorsConfig(); + $rule = new CorsRule(); + $rule->addAllowedHeader("x-oss-header"); + $rule->addAllowedOrigin("http://www.b.com"); + $rule->addAllowedMethod("POST"); + $rule->setMaxAgeSeconds(10); + $corsConfig->addRule($rule); + + try { + $ossClient->putBucketCors($bucket, $corsConfig); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get and print the cors configuration of a bucket + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getBucketCors($ossClient, $bucket) +{ + $corsConfig = null; + try { + $corsConfig = $ossClient->getBucketCors($bucket); + + if ($corsConfig->getResponseVary()){ + printf("Response Vary : true" .PHP_EOL); + }else{ + printf("Response Vary : false" .PHP_EOL); + } + foreach ($corsConfig->getRules() as $key => $rule){ + if($rule->getAllowedHeaders()){ + foreach($rule->getAllowedHeaders() as $header){ + printf("Allowed Headers :" .$header .PHP_EOL); + } + } + if ($rule->getAllowedMethods()){ + foreach($rule->getAllowedMethods() as $method){ + printf("Allowed Methods :" .$method . PHP_EOL); + } + + } + if($rule->getAllowedOrigins()){ + foreach($rule->getAllowedOrigins() as $origin){ + printf("Allowed Origins :" .$origin , PHP_EOL); + } + + } + if($rule->getExposeHeaders()){ + foreach($rule->getExposeHeaders() as $exposeHeader){ + printf("Expose Headers :" .$exposeHeader . PHP_EOL); + } + } + printf("Max Age Seconds :" .$rule->getMaxAgeSeconds() .PHP_EOL); + + } + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Delete all cors configuraiton of a bucket + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteBucketCors($ossClient, $bucket) +{ + try { + $ossClient->deleteBucketCors($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketEncryption.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketEncryption.php new file mode 100644 index 0000000..0e61d5b --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketEncryption.php @@ -0,0 +1,98 @@ +putBucketEncryption($bucket, $config); +Common::println("bucket $bucket encryoption created"); + +$config = $ossClient->getBucketEncryption($bucket); +Common::println("bucket $bucket encryoption:".$config->serializeToXml()); + +$config = $ossClient->deleteBucketEncryption($bucket); +Common::println("bucket $bucket encryoption has deleted"); + +//******************************* For complete usage, see the following functions **************************************************** +putBucketEncryption($ossClient, $bucket); +getBucketEncryption($ossClient, $bucket); +deleteBucketEncryption($ossClient, $bucket); + +/** + * Configure Bucket encryption + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ + +function putBucketEncryption($ossClient,$bucket){ + try { + // Set Bucket's default server-side encryption method to OSS fully managed encryption (SSE-OSS). + $config = new ServerSideEncryptionConfig("AES256"); + // Set Bucket's default server-side encryption method to KMS, and do not specify a CMK ID. + //$config = new ServerSideEncryptionConfig("KMS"); + // Set Bucket's default server-side encryption method to KMS, and specify the CMK ID. + //$config = new ServerSideEncryptionConfig("KMS", "your kms id"); + $ossClient->putBucketEncryption($bucket, $config); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get Bucket encryption + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ + +function getBucketEncryption($ossClient,$bucket){ + try { + $config = $ossClient->getBucketEncryption($bucket); + print($config->getSSEAlgorithm()); + print($config->getKMSMasterKeyID()); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Delete Bucket encryption + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ + +function deleteBucketEncryption($ossClient,$bucket){ + try { + $ossClient->deleteBucketEncryption($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketLifecycle.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketLifecycle.php new file mode 100644 index 0000000..04d2edd --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketLifecycle.php @@ -0,0 +1,109 @@ +addRule($lifecycleRule); +$ossClient->putBucketLifecycle($bucket, $lifecycleConfig); +Common::println("bucket $bucket lifecycleConfig created:" . $lifecycleConfig->serializeToXml()); + +// Get lifecycle configuration +$lifecycleConfig = $ossClient->getBucketLifecycle($bucket); +Common::println("bucket $bucket lifecycleConfig fetched:" . $lifecycleConfig->serializeToXml()); + +// Delete bucket lifecycle configuration +$ossClient->deleteBucketLifecycle($bucket); +Common::println("bucket $bucket lifecycleConfig deleted"); + + +//***************************** For complete usage, see the following functions *********************************************** + +putBucketLifecycle($ossClient, $bucket); +getBucketLifecycle($ossClient, $bucket); +deleteBucketLifecycle($ossClient, $bucket); +getBucketLifecycle($ossClient, $bucket); + +/** + * Set bucket lifecycle configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function putBucketLifecycle($ossClient, $bucket) +{ + $lifecycleConfig = new LifecycleConfig(); + $actions = array(); + $actions[] = new LifecycleAction(OssClient::OSS_LIFECYCLE_EXPIRATION, OssClient::OSS_LIFECYCLE_TIMING_DAYS, 3); + $lifecycleRule = new LifecycleRule("delete obsoleted files", "obsoleted/", "Enabled", $actions); + $lifecycleConfig->addRule($lifecycleRule); + $actions = array(); + $actions[] = new LifecycleAction(OssClient::OSS_LIFECYCLE_EXPIRATION, OssClient::OSS_LIFECYCLE_TIMING_DATE, '2022-10-12T00:00:00.000Z'); + $lifecycleRule = new LifecycleRule("delete temporary files", "temporary/", "Enabled", $actions); + $lifecycleConfig->addRule($lifecycleRule); + try { + $ossClient->putBucketLifecycle($bucket, $lifecycleConfig); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get bucket lifecycle configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getBucketLifecycle($ossClient, $bucket) +{ + $lifecycleConfig = null; + try { + $lifecycleConfig = $ossClient->getBucketLifecycle($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + print($lifecycleConfig->serializeToXml() . "\n"); +} + +/** + * Delete bucket lifecycle configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteBucketLifecycle($ossClient, $bucket) +{ + try { + $ossClient->deleteBucketLifecycle($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + + diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketLogging.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketLogging.php new file mode 100644 index 0000000..eef71f2 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketLogging.php @@ -0,0 +1,95 @@ +putBucketLogging($bucket, $bucket, "access.log", array()); +Common::println("bucket $bucket lifecycleConfig created"); + +// Get bucket access logging rules +$loggingConfig = $ossClient->getBucketLogging($bucket, array()); +Common::println("bucket $bucket lifecycleConfig fetched:" . $loggingConfig->serializeToXml()); + +// Delete bucket access logging rules +$loggingConfig = $ossClient->getBucketLogging($bucket, array()); +Common::println("bucket $bucket lifecycleConfig deleted"); + +//******************************* For complete usage, see the following functions **************************************************** + +putBucketLogging($ossClient, $bucket); +getBucketLogging($ossClient, $bucket); +deleteBucketLogging($ossClient, $bucket); +getBucketLogging($ossClient, $bucket); + +/** + * Set bucket logging configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function putBucketLogging($ossClient, $bucket) +{ + $option = array(); + // Access logs are stored in the same bucket. + $targetBucket = $bucket; + $targetPrefix = "access.log"; + + try { + $ossClient->putBucketLogging($bucket, $targetBucket, $targetPrefix, $option); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get bucket logging configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getBucketLogging($ossClient, $bucket) +{ + $loggingConfig = null; + $options = array(); + try { + $loggingConfig = $ossClient->getBucketLogging($bucket, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + print($loggingConfig->serializeToXml() . "\n"); +} + +/** + * Delete bucket logging configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteBucketLogging($ossClient, $bucket) +{ + try { + $ossClient->deleteBucketLogging($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketPayment.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketPayment.php new file mode 100644 index 0000000..ad04555 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketPayment.php @@ -0,0 +1,116 @@ +putBucketRequestPayment($bucket, "Requester"); + +//Get requester payment mode configuration +$payer = $ossClient->getBucketRequestPayment($bucket); +Common::println("bucket $bucket Payer:".$payer.PHP_EOL); + +//Third-party paid access to Object +$options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => 'requester', + )); + +$content = "hello"; +$object = "object"; + +//PutObject interface to specify the payer +$ossClient->putObject($bucket, $object, $content, $options); + +// GetObject interface to specify the payer +$ossClient->getObject($bucket, $object, $options); + +// DeleteObject interface to specify the payer +$ossClient->deleteObject($bucket, $object, $options); + +//******************************* For complete usage, see the following functions **************************************************** + +putBucketRequestPayment($ossClient,$bucket); +getBucketRequestPayment($ossClient,$bucket); +setObjectPayment($ossClient,$bucket); + +/** + * Set requester payment mode + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function putBucketRequestPayment($ossClient, $bucket) +{ + try { + $ossClient->putBucketRequestPayment($bucket, "Requester"); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Get payment mode of bucket + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function getBucketRequestPayment($ossClient, $bucket) +{ + try { + $payer = $ossClient->getBucketRequestPayment($bucket); + print("bucket $bucket Payer:".$payer.PHP_EOL); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Set payment mode of object + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function setObjectPayment($ossClient,$bucket){ + // Specify the payment model for the requester. + $options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => 'requester', + )); + + try { + + $content = "hello"; + $object = "object"; + //PutObject interface to specify the payer + $ossClient->putObject($bucket, $object, $content, $options); + // GetObject interface to specify the payer + $ossClient->getObject($bucket, $object, $options); + // DeleteObject interface to specify the payer + $ossClient->deleteObject($bucket, $object, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketPolicy.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketPolicy.php new file mode 100644 index 0000000..333efac --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketPolicy.php @@ -0,0 +1,123 @@ +putBucketPolicy($bucket, $policy); + +// Get bucket pllicy +$policy = $ossClient->getBucketPolicy($bucket); +Common::println("bucket $bucket policy: " . $policy); + + +// Delete bucket pllicy +$policy = $ossClient->deleteBucketPolicy($bucket); + +//******************************* For complete usage, see the following functions **************************************************** + +putBucketPolicy($ossClient, $bucket); +getBucketPolicy($ossClient, $bucket); +deleteBucketPolicy($ossClient, $bucket); + +/** + * Set Bucket Policy + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function putBucketPolicy($ossClient, $bucket) +{ + $policy = <<< BBBB +{ + "Version":"1", + "Statement":[ + { + "Action":[ + "oss:PutObject", + "oss:GetObject" + ], + "Effect":"Allow", + "Resource":["acs:oss:*:*:*/user1/*"] + } + ] +} +BBBB; + + try { + $ossClient->putBucketPolicy($bucket, $policy); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Get Bucket Policy + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function getBucketPolicy($ossClient, $bucket) +{ + try { + $policy = $ossClient->getBucketPolicy($bucket); + print($policy); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Delete Bucket Policy + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function deleteBucketPolicy($ossClient, $bucket) +{ + try { + $ossClient->deleteBucketPolicy($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketReferer.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketReferer.php new file mode 100644 index 0000000..628f784 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketReferer.php @@ -0,0 +1,101 @@ +setAllowEmptyReferer(true); +$refererConfig->addReferer("www.aliiyun.com"); +$refererConfig->addReferer("www.aliiyuncs.com"); +$ossClient->putBucketReferer($bucket, $refererConfig); +Common::println("bucket $bucket refererConfig created:" . $refererConfig->serializeToXml()); +// Get referer whitelist +$refererConfig = $ossClient->getBucketReferer($bucket); +Common::println("bucket $bucket refererConfig fetched:" . $refererConfig->serializeToXml()); + +// Delete referrer whitelist +$refererConfig = new RefererConfig(); +$ossClient->putBucketReferer($bucket, $refererConfig); +Common::println("bucket $bucket refererConfig deleted"); + + +//******************************* For complete usage, see the following functions **************************************************** + +putBucketReferer($ossClient, $bucket); +getBucketReferer($ossClient, $bucket); +deleteBucketReferer($ossClient, $bucket); +getBucketReferer($ossClient, $bucket); + +/** + * Set bucket referer configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function putBucketReferer($ossClient, $bucket) +{ + $refererConfig = new RefererConfig(); + $refererConfig->setAllowEmptyReferer(true); + $refererConfig->addReferer("www.aliiyun.com"); + $refererConfig->addReferer("www.aliiyuncs.com"); + try { + $ossClient->putBucketReferer($bucket, $refererConfig); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get bucket referer configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getBucketReferer($ossClient, $bucket) +{ + $refererConfig = null; + try { + $refererConfig = $ossClient->getBucketReferer($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + print($refererConfig->serializeToXml() . "\n"); +} + +/** + * Delete bucket referer configuration + * Referer whitelist cannot be directly deleted. So use a empty one to overwrite it. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteBucketReferer($ossClient, $bucket) +{ + $refererConfig = new RefererConfig(); + try { + $ossClient->putBucketReferer($bucket, $refererConfig); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketStat.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketStat.php new file mode 100644 index 0000000..43c03e6 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketStat.php @@ -0,0 +1,65 @@ +getBucketStat($bucket); +Common::println("Bucket ".$bucket." current storage is:".$stat->getStorage().PHP_EOL); +Common::println("Bucket ".$bucket." object count is:".$stat->getObjectCount().PHP_EOL); +Common::println("Bucket ".$bucket." multipart upload count is:".$stat->getMultipartUploadCount().PHP_EOL); +Common::println("Bucket ".$bucket." live channel count is:".$stat->getLiveChannelCount().PHP_EOL); +Common::println("Bucket ".$bucket." last modified time is:".$stat->getLastModifiedTime().PHP_EOL); +Common::println("Bucket ".$bucket." standard storage is:".$stat->getStandardStorage().PHP_EOL); +Common::println("Bucket ".$bucket." standard object count is:".$stat->getStandardObjectCount().PHP_EOL); +Common::println("Bucket ".$bucket." infrequent access storage is:".$stat->getInfrequentAccessStorage().PHP_EOL); +Common::println("Bucket ".$bucket." infrequent access real storage is:".$stat->getInfrequentAccessRealStorage().PHP_EOL); +Common::println("Bucket ".$bucket." infrequent access object count is:".$stat->getInfrequentAccessObjectCount().PHP_EOL); +Common::println("Bucket ".$bucket." archive storage is:".$stat->getArchiveStorage().PHP_EOL); +Common::println("Bucket ".$bucket." archive real storage is:".$stat->getArchiveRealStorage().PHP_EOL); +Common::println("Bucket ".$bucket." archive object count is:".$stat->getArchiveObjectCount().PHP_EOL); +Common::println("Bucket ".$bucket." cold archive storage is:".$stat->getColdArchiveStorage().PHP_EOL); +Common::println("Bucket ".$bucket." cold archive real storage is:".$stat->getColdArchiveRealStorage().PHP_EOL); +Common::println("Bucket ".$bucket." cold archive object count is:".$stat->getColdArchiveObjectCount().PHP_EOL); + +//******************************* For complete usage, see the following functions **************************************************** +getBucketStat($ossClient,$bucket); +/** + * get bucket stat + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function getBucketStat($ossClient, $bucket) +{ + try { + $stat = $ossClient->getBucketStat($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + printf("Bucket ".$bucket." current storage is:".$stat->getStorage().PHP_EOL); + printf("Bucket ".$bucket." object count is:".$stat->getObjectCount().PHP_EOL); + printf("Bucket ".$bucket." multipart upload count is:".$stat->getMultipartUploadCount().PHP_EOL); + printf("Bucket ".$bucket." live channel count is:".$stat->getLiveChannelCount().PHP_EOL); + printf("Bucket ".$bucket." last modified time is:".$stat->getLastModifiedTime().PHP_EOL); + printf("Bucket ".$bucket." standard storage is:".$stat->getStandardStorage().PHP_EOL); + printf("Bucket ".$bucket." standard object count is:".$stat->getStandardObjectCount().PHP_EOL); + printf("Bucket ".$bucket." infrequent access storage is:".$stat->getInfrequentAccessStorage().PHP_EOL); + printf("Bucket ".$bucket." infrequent access real storage is:".$stat->getInfrequentAccessRealStorage().PHP_EOL); + printf("Bucket ".$bucket." infrequent access object count is:".$stat->getInfrequentAccessObjectCount().PHP_EOL); + printf("Bucket ".$bucket." archive storage is:".$stat->getArchiveStorage().PHP_EOL); + printf("Bucket ".$bucket." archive real storage is:".$stat->getArchiveRealStorage().PHP_EOL); + printf("Bucket ".$bucket." archive object count is:".$stat->getArchiveObjectCount().PHP_EOL); + printf("Bucket ".$bucket." cold archive storage is:".$stat->getColdArchiveStorage().PHP_EOL); + printf("Bucket ".$bucket." cold archive real storage is:".$stat->getColdArchiveRealStorage().PHP_EOL); + printf("Bucket ".$bucket." cold archive object count is:".$stat->getColdArchiveObjectCount().PHP_EOL); + print(__FUNCTION__ . ": OK" . "\n"); +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketTags.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketTags.php new file mode 100644 index 0000000..e361eaa --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketTags.php @@ -0,0 +1,112 @@ +addTag(new Tag("key1", "value1")); +$config->addTag(new Tag("key2", "value2")); +$ossClient->putBucketTags($bucket, $config); + +// Get bucket tags +$config = $ossClient->getBucketTags($bucket); +Common::println("bucket $bucket tags: ".$config->serializeToXml()); + +// Delete bucket tags + +// Delete the specified tag of the bucket. +$tags = array(); +$tags[] = new Tag("key1", "value1"); +$tags[] = new Tag("key2", "value2"); +$ossClient->deleteBucketTags($bucket, $tags); + +// Delete all tags in the bucket. +$ossClient->deleteBucketTags($bucket); + +//******************************* For complete usage, see the following functions **************************************************** + +putBucketTags($ossClient, $bucket); +getBucketTags($ossClient, $bucket); +deleteBucketTags($ossClient, $bucket); + + +/** + * Create bucket tag + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function putBucketTags($ossClient, $bucket) +{ + try { + // 设置Bucket标签。 + $config = new TaggingConfig(); + $config->addTag(new Tag("key1", "value1")); + $config->addTag(new Tag("key2", "value2")); + $ossClient->putBucketTags($bucket, $config); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * get bucket tag + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function getBucketTags($ossClient, $bucket) +{ + try { + $config = $ossClient->getBucketTags($bucket); + print_r($config->getTags()); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * delete bucket tag + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function deleteBucketTags($ossClient, $bucket) +{ + try { + // Delete the specified tag of the bucket. + $tags = array(); + $tags[] = new Tag("key1", "value1"); + $tags[] = new Tag("key2", "value2"); + $ossClient->deleteBucketTags($bucket, $tags); + + // Delete all tags in the bucket. + //$ossClient->deleteBucketTags($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketTransferAcceleration.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketTransferAcceleration.php new file mode 100644 index 0000000..ee112db --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketTransferAcceleration.php @@ -0,0 +1,61 @@ +sfer acceleration +$enabled = true; // set true to enable transfer acceleration; set false to disalbe transfer acceleration +$ossClient->putBucketTransferAcceleration($bucket, $enabled); +printf('putBucketTransferAcceleration SUCCESS' . "\n"); + + +// get transfer acceleration +$result = $ossClient->getBucketTransferAcceleration($bucket); +printf('getBucketTransferAcceleration Status:%s'."\n",$result); + + +//******************************* For complete usage, see the following functions **************************************************** +putBucketTransferAcceleration($ossClient,$bucket); +getBucketTransferAcceleration($bucket); + +/** + * @param $ossClient OssClient + * @param $bucket bucket_name string + * @param $enabled string + */ +function putBucketTransferAcceleration($ossClient, $bucket, $enabled) +{ + try{ + $enabled = true; // set true to enable transfer acceleration; set false to disalbe transfer acceleration + $ossClient->putBucketTransferAcceleration($bucket,$enabled); + printf('putBucketTransferAcceleration SUCCESS' . "\n"); + } catch(OssException $e) { + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * @param $ossClient OssClient + * @param $bucket bucket_name string + */ +function getBucketTransferAcceleration($ossClient, $bucket) +{ + try{ + $result = $ossClient->getBucketTransferAcceleration($bucket); + printf('getBucketTransferAcceleration Status:%s'."\n",$result); + } catch(OssException $e) { + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketVersion.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketVersion.php new file mode 100644 index 0000000..a1b4ed6 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketVersion.php @@ -0,0 +1,235 @@ +putBucketVersioning($bucket, "Enabled"); +Common::println("bucket $bucket version Enabled"); +// show all object list +$option = array( + OssClient::OSS_KEY_MARKER => null, + OssClient::OSS_VERSION_ID_MARKER => null +); +$bool = true; +while ($bool) { + $result = $ossClient->listObjectVersions($bucket, $option); + ## View the version information of the listed object. + foreach ($result->getObjectVersionList() as $key => $info) { + Common::println("key name: " . $info->getKey()); + Common::println("versionid: " . $info->getVersionId()); + Common::println("Is latest: " . $info->getIsLatest()); + } + + ## View the version information that lists the deletion flags. + foreach ($result->getDeleteMarkerList() as $key => $info) { + Common::println("del_maker key name: " . $info->getKey()); + Common::println("del_maker versionid: " . $info->getVersionId()); + Common::println("del_maker Is latest: " . $info->getIsLatest()); + } + + if ($result->getIsTruncated() === 'true') { + $option = array( + OssClient::OSS_KEY_MARKER => $result->getNextKeyMarker(), + OssClient::OSS_VERSION_ID_MARKER => $result->getNextVersionIdMarker() + ); + } else { + $bool = false; + } +} + +// show the prefix object + +$option = array( + OssClient::OSS_KEY_MARKER => null, + OssClient::OSS_VERSION_ID_MARKER => null, + OssClient::OSS_PREFIX => "test" +); +$bool = true; +while ($bool) { + $result = $ossClient->listObjectVersions($bucket, $option); + ## View the version information of the listed object. + foreach ($result->getObjectVersionList() as $key => $info) { + Common::println("key name: " . $info->getKey()); + Common::println("versionid: " . $info->getVersionId()); + Common::println("Is latest: " . $info->getIsLatest()); + } + + ## View the version information that lists the deletion flags. + foreach ($result->getDeleteMarkerList() as $key => $info) { + Common::println("del_maker key name: " . $info->getKey()); + Common::println("del_maker versionid: " . $info->getVersionId()); + Common::println("del_maker Is latest: " . $info->getIsLatest()); + } + + if ($result->getIsTruncated() === 'true') { + $option[OssClient::OSS_KEY_MARKER] = $result->getNextKeyMarker(); + $option[OssClient::OSS_VERSION_ID_MARKER] = $result->getNextVersionIdMarker(); + } else { + $bool = false; + } +} + +// list the number of objects + +$option = array( + OssClient::OSS_KEY_MARKER => null, + OssClient::OSS_VERSION_ID_MARKER => null, + OssClient::OSS_MAX_KEYS => 200 +); + +$result = $ossClient->listObjectVersions($bucket, $option); +## View the version information of the listed object. +foreach ($result->getObjectVersionList() as $key => $info) { + Common::println("key name: " . $info->getKey()); + Common::println("versionid: " . $info->getVersionId()); + Common::println("Is latest: " . $info->getIsLatest()); +} + +## View the version information that lists the deletion flags. +foreach ($result->getDeleteMarkerList() as $key => $info) { + Common::println("del_maker key name: " . $info->getKey()); + Common::println("del_maker versionid: " . $info->getVersionId()); + Common::println("del_maker Is latest: " . $info->getIsLatest()); +} + + +// show root folder list +$option = array( + OssClient::OSS_KEY_MARKER => null, + OssClient::OSS_VERSION_ID_MARKER => null, + OssClient::OSS_DELIMITER => "/", +); +$bool = true; +while ($bool) { + $result = $ossClient->listObjectVersions($bucket, $option); + ## View the version information of the listed object. + foreach ($result->getObjectVersionList() as $key => $info) { + Common::println("key name: " . $info->getKey()); + Common::println("versionid: " . $info->getVersionId()); + Common::println("Is latest: " . $info->getIsLatest()); + } + + ## View the version information that lists the deletion flags. + foreach ($result->getDeleteMarkerList() as $key => $info) { + Common::println("del_maker key name: " . $info->getKey()); + Common::println("del_maker versionid: " . $info->getVersionId()); + Common::println("del_maker Is latest: " . $info->getIsLatest()); + } + + if ($result->getIsTruncated() === 'true') { + $option[OssClient::OSS_KEY_MARKER] = $result->getNextKeyMarker(); + $option[OssClient::OSS_VERSION_ID_MARKER] = $result->getNextVersionIdMarker(); + } else { + $bool = false; + } +} + +// Show subfolder objects list +$option = array( + OssClient::OSS_KEY_MARKER => null, + OssClient::OSS_VERSION_ID_MARKER => null, + OssClient::OSS_DELIMITER => "/", + OssClient::OSS_PREFIX => "test/", +); +$bool = true; +while ($bool) { + $result = $ossClient->listObjectVersions($bucket, $option); + ## View the version information of the listed object. + foreach ($result->getObjectVersionList() as $key => $info) { + Common::println("key name: " . $info->getKey()); + Common::println("versionid: " . $info->getVersionId()); + Common::println("Is latest: " . $info->getIsLatest()); + } + + ## View the version information that lists the deletion flags. + foreach ($result->getDeleteMarkerList() as $key => $info) { + Common::println("del_maker key name: " . $info->getKey()); + Common::println("del_maker versionid: " . $info->getVersionId()); + Common::println("del_maker Is latest: " . $info->getIsLatest()); + } + + if ($result->getIsTruncated() === 'true') { + $option[OssClient::OSS_KEY_MARKER] = $result->getNextKeyMarker(); + $option[OssClient::OSS_VERSION_ID_MARKER] = $result->getNextVersionIdMarker(); + } else { + $bool = false; + } +} + + +//******************************* For complete usage, see the following functions **************************************************** + +listObjectVersions($ossClient, $bucket); +putBucketVersioning($ossClient, $bucket); +/** + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function listObjectVersions($ossClient, $bucket) +{ + try { + $option = array( + OssClient::OSS_KEY_MARKER => null, + OssClient::OSS_VERSION_ID_MARKER => null, + ); + $bool = true; + while ($bool) { + $result = $ossClient->listObjectVersions($bucket, $option); + ## View the version information of the listed object. + foreach ($result->getObjectVersionList() as $key => $info) { + Common::println("key name: " . $info->getKey()); + Common::println("versionid: " . $info->getVersionId()); + Common::println("Is latest: " . $info->getIsLatest()); + } + + ## View the version information that lists the deletion flags. + foreach ($result->getDeleteMarkerList() as $key => $info) { + Common::println("del_maker key name: " . $info->getKey()); + Common::println("del_maker versionid: " . $info->getVersionId()); + Common::println("del_maker Is latest: " . $info->getIsLatest()); + } + + if ($result->getIsTruncated() === 'true') { + $option[OssClient::OSS_KEY_MARKER] = $result->getNextKeyMarker(); + $option[OssClient::OSS_VERSION_ID_MARKER] = $result->getNextVersionIdMarker(); + } else { + $bool = false; + } + } + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Enabled or Suspended bucket version + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function putBucketVersioning($ossClient, $bucket) +{ + try { + //Set the storage space version control to enable version control (Enabled) or suspend version control (Suspended). + $ossClient->putBucketVersioning($bucket, "Enabled"); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketWebsite.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketWebsite.php new file mode 100644 index 0000000..6c387e6 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketWebsite.php @@ -0,0 +1,92 @@ +putBucketWebsite($bucket, $websiteConfig); +Common::println("bucket $bucket websiteConfig created:" . $websiteConfig->serializeToXml()); + +// Get bucket static website configuration +$websiteConfig = $ossClient->getBucketWebsite($bucket); +Common::println("bucket $bucket websiteConfig fetched:" . $websiteConfig->serializeToXml()); + +// Delete bucket static website configuration +$ossClient->deleteBucketWebsite($bucket); +Common::println("bucket $bucket websiteConfig deleted"); + +//******************************* For complete usage, see the following functions **************************************************** + +putBucketWebsite($ossClient, $bucket); +getBucketWebsite($ossClient, $bucket); +deleteBucketWebsite($ossClient, $bucket); +getBucketWebsite($ossClient, $bucket); + +/** + * Sets bucket static website configuration + * + * @param $ossClient OssClient + * @param $bucket string bucket name + * @return null + */ +function putBucketWebsite($ossClient, $bucket) +{ + $websiteConfig = new WebsiteConfig("index.html", "error.html"); + try { + $ossClient->putBucketWebsite($bucket, $websiteConfig); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get bucket static website configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getBucketWebsite($ossClient, $bucket) +{ + $websiteConfig = null; + try { + $websiteConfig = $ossClient->getBucketWebsite($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + print($websiteConfig->serializeToXml() . "\n"); +} + +/** + * Delete bucket static website configuration + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteBucketWebsite($ossClient, $bucket) +{ + try { + $ossClient->deleteBucketWebsite($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} diff --git a/vendor/aliyuncs/oss-sdk-php/samples/BucketWorm.php b/vendor/aliyuncs/oss-sdk-php/samples/BucketWorm.php new file mode 100644 index 0000000..c4b0fb9 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/BucketWorm.php @@ -0,0 +1,145 @@ +initiateBucketWorm($bucket, 30); +Common::println("bucket $bucket wormId: " . $wormId.PHP_EOL); + +// Cancel an unlocked compliance retention policy +$ossClient->abortBucketWorm($bucket); + +//Lock compliant retention policy +$wormId = $ossClient->initiateBucketWorm($bucket, 30); +$ossClient->completeBucketWorm($bucket, $wormId); + +// Get compliant retention policy +$config = $ossClient->getBucketWorm($bucket); +Common::println("WormId:".$config->getWormId().PHP_EOL); +Common::println("State:". $config->getState().PHP_EOL); +Common::println("Day:". $config->getDay().PHP_EOL); + +// Extend the retention days of objects +$wormId = ""; +// Extend the retention days of objects in the locked compliance retention policy to 120 days. +$ossClient->extendBucketWorm($bucket, $wormId, 120); + +//******************************* For complete usage, see the following functions **************************************************** + +initiateBucketWorm($ossClient, $bucket); +abortBucketWorm($ossClient, $bucket); +completeBucketWorm($ossClient, $bucket); +getBucketWorm($ossClient, $bucket); +extendBucketWorm($ossClient, $bucket); + +/** + * Set Bucket Worm Ploicy + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function initiateBucketWorm($ossClient, $bucket) +{ + try { + $wormId = $ossClient->initiateBucketWorm($bucket,30); + print("bucket $bucket wormId: " . $wormId.PHP_EOL); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Cancel an unlocked compliance retention policy + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket Name of the bucket to create + * @return null + */ +function abortBucketWorm($ossClient, $bucket) +{ + try { + $ossClient->abortBucketWorm($bucket); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Complete Bucket Worm + * @param $ossClient $ossClient OssClient instance + * @param $bucket $bucket Name of the bucket to create + */ +function completeBucketWorm($ossClient, $bucket) +{ + try { + $wormId = $ossClient->initiateBucketWorm($bucket, 30); + $ossClient->completeBucketWorm($bucket, $wormId); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get Bucket Worm + * @param $ossClient $ossClient OssClient instance + * @param $bucket $bucket Name of the bucket to create + */ +function getBucketWorm($ossClient, $bucket) +{ + try { + $config = $ossClient->getBucketWorm($bucket); + + printf("WormId:%s\n", $config->getWormId()); + printf("State:%s\n", $config->getState()); + printf("Day:%d\n", $config->getDay()); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Extend the retention days of objects + * @param $ossClient $ossClient OssClient instance + * @param $bucket $bucket Name of the bucket to create + */ +function extendBucketWorm($ossClient, $bucket) +{ + $wormId = ""; + try { + $ossClient->ExtendBucketWorm($bucket, $wormId, 120); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/samples/Callback.php b/vendor/aliyuncs/oss-sdk-php/samples/Callback.php new file mode 100644 index 0000000..4b7bc41 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/Callback.php @@ -0,0 +1,83 @@ + $url, + OssClient::OSS_CALLBACK_VAR => $var + ); +$result = $ossClient->putObject($bucket, "b.file", "random content", $options); +Common::println($result['body']); +Common::println($result['info']['http_code']); + +/** + * completeMultipartUpload Upload content to an OSS file using callback. + * callbackurl specifies the server url for the request callback + * The callbackbodytype can be application/json or application/x-www-form-urlencoded,the optional parameters,the default for the application/x - WWW - form - urlencoded + * Users can choose not to set OSS_BACK_VAR. + */ +$object = "multipart-callback-test.txt"; +$copiedObject = "multipart-callback-test.txt.copied"; +$ossClient->putObject($bucket, $copiedObject, file_get_contents(__FILE__)); + +/** + * step 1. Initialize a block upload event, that is, a multipart upload process to get an upload id + */ +$upload_id = $ossClient->initiateMultipartUpload($bucket, $object); + +/** + * step 2. uploadPartCopy + */ +$copyId = 1; +$eTag = $ossClient->uploadPartCopy($bucket, $copiedObject, $bucket, $object, $copyId, $upload_id); +$upload_parts[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); +$listPartsInfo = $ossClient->listParts($bucket, $object, $upload_id); + +/** + * step 3. + */ +$json = + '{ + "callbackUrl":"callback.oss-demo.com:23450", + "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size},\"x:var1\":${x:var1},\"x:var2\":${x:var2}}", + "callbackBodyType":"application/json" + }'; +$var = + '{ + "x:var1":"value1", + "x:var2":"值2" + }'; +$options = array(OssClient::OSS_CALLBACK => $json, + OssClient::OSS_CALLBACK_VAR => $var); + +$result = $ossClient->completeMultipartUpload($bucket, $object, $upload_id, $upload_parts, $options); +Common::println($result['body']); +Common::println($result['info']['http_code']); diff --git a/vendor/aliyuncs/oss-sdk-php/samples/Common.php b/vendor/aliyuncs/oss-sdk-php/samples/Common.php new file mode 100644 index 0000000..49bd493 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/Common.php @@ -0,0 +1,84 @@ +getMessage() . "\n"); + return null; + } + return $ossClient; + } + + public static function getBucketName() + { + return self::bucket; + } + + /** + * A tool function which creates a bucket and exists the process if there are exceptions + */ + public static function createBucket() + { + $ossClient = self::getOssClient(); + if (is_null($ossClient)) exit(1); + $bucket = self::getBucketName(); + $acl = OssClient::OSS_ACL_TYPE_PUBLIC_READ; + try { + $ossClient->createBucket($bucket, $acl); + } catch (OssException $e) { + + $message = $e->getMessage(); + if (\OSS\Core\OssUtil::startsWith($message, 'http status: 403')) { + echo "Please Check your AccessKeyId and AccessKeySecret" . "\n"; + exit(0); + } elseif (strpos($message, "BucketAlreadyExists") !== false) { + echo "Bucket already exists. Please check whether the bucket belongs to you, or it was visited with correct endpoint. " . "\n"; + exit(0); + } + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + } + + public static function println($message) + { + if (!empty($message)) { + echo strval($message) . "\n"; + } + } +} + +# Common::createBucket(); diff --git a/vendor/aliyuncs/oss-sdk-php/samples/Config.php b/vendor/aliyuncs/oss-sdk-php/samples/Config.php new file mode 100644 index 0000000..fc3a167 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/Config.php @@ -0,0 +1,15 @@ +warpper = $credential; + } + public function getCredentials(){ + $ak = $this->warpper->getAccessKeyId(); + $sk = $this->warpper->getAccessKeySecret(); + $token = $this->warpper->getSecurityToken(); + return new StaticCredentialsProvider($ak, $sk, $token); + } +} + +$bucket = Common::getBucketName(); + +//AccessKey Credentials demo +$credential = new Credential(array( + 'type' => 'access_key', + 'access_key_id' => '', + 'access_key_secret' => '', +)); +$providerWarpper = new AlibabaCloudCredentialsWrapper($credential); +$config = array( + 'provider' => $providerWarpper, + 'endpoint'=> '' +); +try { + $ossClient = new OssClient($config); + $ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of access key'); + $result = $ossClient->getObject($bucket,'c.file'); + var_dump($result); +} catch (OssException $e) { + printf($e->getMessage() . "\n"); + return; +} + + +// EcsRamRole Credentials demo +$ecsRamRole = new Credential(array( + 'type' => 'ecs_ram_role', + 'role_name' => 'EcsRamRoleOssTest', +)); +$providerWarpper = new AlibabaCloudCredentialsWrapper($ecsRamRole); +$bucket = 'oss-bucket-cd-yp-test'; +$config = array( + 'provider' => $providerWarpper, + 'endpoint'=> '' +); +try { + $ossClient = new OssClient($config); + $ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of EcsRamRole'); + $result = $ossClient->getObject($bucket,'c.file'); + var_dump($result); +} catch (OssException $e) { + printf($e->getMessage() . "\n"); + return; +} diff --git a/vendor/aliyuncs/oss-sdk-php/samples/CredentialsProvider.php b/vendor/aliyuncs/oss-sdk-php/samples/CredentialsProvider.php new file mode 100644 index 0000000..8a96b44 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/CredentialsProvider.php @@ -0,0 +1,63 @@ +'; +$secret = ''; +$provider = new StaticCredentialsProvider($id,$secret); +$config = array( + 'provider' => $provider, + 'endpoint'=>'' +); +try { + $ossClient = new OssClient($config); + $ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of access key provider'); + $result = $ossClient->getObject($bucket,'c.file'); + var_dump($result); +} catch (OssException $e) { + printf($e->getMessage() . "\n"); + return; +} + +// Sts provider demo +$id = ''; +$secret = ''; +$token = ''; +$provider = new StaticCredentialsProvider($id,$secret,$token); +$config = array( + 'provider' => $provider, + 'endpoint'=> "" +); + +try { + $ossClient = new OssClient($config); + $ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of sts provider'); + $result = $ossClient->getObject($bucket,'c.file'); + var_dump($result); +} catch (OssException $e) { + printf($e->getMessage() . "\n"); + return; +} + +// read from env +$envProvider = new EnvironmentVariableCredentialsProvider(); +$config = array( + 'provider' => $envProvider, + 'endpoint'=> "" +); + +try { + $ossClient = new OssClient($config); + $ossClient->putObject($bucket,'c.file','hi oss,this is credentials test of sts provider'); + $result = $ossClient->getObject($bucket,'c.file'); + var_dump($result); +} catch (OssException $e) { + printf($e->getMessage() . "\n"); + return; +} diff --git a/vendor/aliyuncs/oss-sdk-php/samples/Image.php b/vendor/aliyuncs/oss-sdk-php/samples/Image.php new file mode 100644 index 0000000..8531733 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/Image.php @@ -0,0 +1,87 @@ +uploadFile($bucketName, $object, "example.jpg"); + +// Image resize +$options = array( + OssClient::OSS_FILE_DOWNLOAD => $download_file, + OssClient::OSS_PROCESS => "image/resize,m_fixed,h_100,w_100", ); +$ossClient->getObject($bucketName, $object, $options); +printImage("imageResize",$download_file); + +// Image crop +$options = array( + OssClient::OSS_FILE_DOWNLOAD => $download_file, + OssClient::OSS_PROCESS => "image/crop,w_100,h_100,x_100,y_100,r_1", ); +$ossClient->getObject($bucketName, $object, $options); +printImage("iamgeCrop", $download_file); + +// Image rotate +$options = array( + OssClient::OSS_FILE_DOWNLOAD => $download_file, + OssClient::OSS_PROCESS => "image/rotate,90", ); +$ossClient->getObject($bucketName, $object, $options); +printImage("imageRotate", $download_file); + +// Image sharpen +$options = array( + OssClient::OSS_FILE_DOWNLOAD => $download_file, + OssClient::OSS_PROCESS => "image/sharpen,100", ); +$ossClient->getObject($bucketName, $object, $options); +printImage("imageSharpen", $download_file); + +// Add watermark into a image +$options = array( + OssClient::OSS_FILE_DOWNLOAD => $download_file, + OssClient::OSS_PROCESS => "image/watermark,text_SGVsbG8g5Zu-54mH5pyN5YqhIQ", ); +$ossClient->getObject($bucketName, $object, $options); +printImage("imageWatermark", $download_file); + +// Image format convertion +$options = array( + OssClient::OSS_FILE_DOWNLOAD => $download_file, + OssClient::OSS_PROCESS => "image/format,png", ); +$ossClient->getObject($bucketName, $object, $options); +printImage("imageFormat", $download_file); + +// Get image information +$options = array( + OssClient::OSS_FILE_DOWNLOAD => $download_file, + OssClient::OSS_PROCESS => "image/info", ); +$ossClient->getObject($bucketName, $object, $options); +printImage("imageInfo", $download_file); + + +/** + * Generate a signed url which could be used in browser to access the object. The expiration time is 1 hour. + */ + $timeout = 3600; +$options = array( + OssClient::OSS_PROCESS => "image/resize,m_lfit,h_100,w_100", + ); +$signedUrl = $ossClient->signUrl($bucketName, $object, $timeout, "GET", $options); +Common::println("rtmp url: \n" . $signedUrl); + +// Finally delete the $object uploaded. +$ossClient->deleteObject($bucketName, $object); + +function printImage($func, $imageFile) +{ + $array = getimagesize($imageFile); + Common::println("$func, image width: " . $array[0]); + Common::println("$func, image height: " . $array[1]); + Common::println("$func, image type: " . ($array[2] === 2 ? 'jpg' : 'png')); + Common::println("$func, image size: " . ceil(sprintf('%u',filesize($imageFile)))); +} diff --git a/vendor/aliyuncs/oss-sdk-php/samples/LiveChannel.php b/vendor/aliyuncs/oss-sdk-php/samples/LiveChannel.php new file mode 100644 index 0000000..67bb541 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/LiveChannel.php @@ -0,0 +1,131 @@ + 'live channel test', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); +$info = $ossClient->putBucketLiveChannel($bucket, 'test_rtmp_live', $config); +Common::println("bucket $bucket liveChannel created:\n" . +"live channel name: ". $info->getName() . "\n" . +"live channel description: ". $info->getDescription() . "\n" . +"publishurls: ". $info->getPublishUrls()[0] . "\n" . +"playurls: ". $info->getPlayUrls()[0] . "\n"); + +/** + * You can use listBucketLiveChannels to list and manage all existing live channels. + * Prefix can be used to filter listed live channels by prefix. + * Max_keys indicates the maximum numbers of live channels that can be listed in an iterator at one time. Its value is 1000 in maximum and 100 by default. + */ +$list = $ossClient->listBucketLiveChannels($bucket); +Common::println("bucket $bucket listLiveChannel:\n" . +"list live channel prefix: ". $list->getPrefix() . "\n" . +"list live channel marker: ". $list->getMarker() . "\n" . +"list live channel maxkey: ". $list->getMaxKeys() . "\n" . +"list live channel IsTruncated: ". $list->getIsTruncated() . "\n" . +"list live channel getNextMarker: ". $list->getNextMarker() . "\n"); + +foreach($list->getChannelList() as $list) +{ + Common::println("bucket $bucket listLiveChannel:\n" . + "list live channel IsTruncated: ". $list->getName() . "\n" . + "list live channel Description: ". $list->getDescription() . "\n" . + "list live channel Status: ". $list->getStatus() . "\n" . + "list live channel getNextMarker: ". $list->getLastModified() . "\n"); +} +/** + * Obtain the play_url (url used for rtmp stream pushing. + * If the the bucket is not globally readable and writable, + * the url must be signed as shown in the following.) and pulish_url (the url included in the m3u8 file generated in stream pushing) used to push streams. + */ +$play_url = $ossClient->signRtmpUrl($bucket, "test_rtmp_live", 3600, array('params' => array('playlistName' => 'playlist.m3u8'))); +Common::println("bucket $bucket rtmp url: \n" . $play_url); +$play_url = $ossClient->signRtmpUrl($bucket, "test_rtmp_live", 3600); +Common::println("bucket $bucket rtmp url: \n" . $play_url); + +/** + * If you want to disable a created live channel (disable the pushing streaming or do not allow stream pushing to an IP address), call putLiveChannelStatus to change the channel status to "Disabled". + * If you want to enable a disabled live channel, call PutLiveChannelStatus to chanage the channel status to "Enabled". + */ +$resp = $ossClient->putLiveChannelStatus($bucket, "test_rtmp_live", "enabled"); + +/** + * You can callLiveChannelInfo to get the information about a live channel. + */ +$info = $ossClient->getLiveChannelInfo($bucket, 'test_rtmp_live'); +Common::println("bucket $bucket LiveChannelInfo:\n" . +"live channel info description: ". $info->getDescription() . "\n" . +"live channel info status: ". $info->getStatus() . "\n" . +"live channel info type: ". $info->getType() . "\n" . +"live channel info fragDuration: ". $info->getFragDuration() . "\n" . +"live channel info fragCount: ". $info->getFragCount() . "\n" . +"live channel info playListName: ". $info->getPlayListName() . "\n"); + +/** + * Gets the historical pushing streaming records by calling getLiveChannelHistory. Now the max records to return is 10. + */ +$history = $ossClient->getLiveChannelHistory($bucket, "test_rtmp_live"); +if (count($history->getLiveRecordList()) != 0) +{ + foreach($history->getLiveRecordList() as $recordList) + { + Common::println("bucket $bucket liveChannelHistory:\n" . + "live channel history startTime: ". $recordList->getStartTime() . "\n" . + "live channel history endTime: ". $recordList->getEndTime() . "\n" . + "live channel history remoteAddr: ". $recordList->getRemoteAddr() . "\n"); + } +} + +/** + * Get the live channel's status by calling getLiveChannelStatus. + * If the live channel is receiving the pushing stream, all attributes in stat_result are valid. + * If the live channel is idle or disabled, then the status is idle or Disabled and other attributes have no meaning. + */ +$status = $ossClient->getLiveChannelStatus($bucket, "test_rtmp_live"); +Common::println("bucket $bucket listLiveChannel:\n" . +"live channel status status: ". $status->getStatus() . "\n" . +"live channel status ConnectedTime: ". $status->getConnectedTime() . "\n" . +"live channel status VideoWidth: ". $status->getVideoWidth() . "\n" . +"live channel status VideoHeight: ". $status->getVideoHeight() . "\n" . +"live channel status VideoFrameRate: ". $status->getVideoFrameRate() . "\n" . +"live channel status VideoBandwidth: ". $status->getVideoBandwidth() . "\n" . +"live channel status VideoCodec: ". $status->getVideoCodec() . "\n" . +"live channel status AudioBandwidth: ". $status->getAudioBandwidth() . "\n" . +"live channel status AudioSampleRate: ". $status->getAudioSampleRate() . "\n" . +"live channel status AdioCodec: ". $status->getAudioCodec() . "\n"); + +/** + * If you want to generate a play url from the ts files generated from pushing streaming, call postVodPlayList. + * Specify the start time to 60 seconds before the current time and the end time to the current time, which means that a video of 60 seconds is generated. + * The playlist file is specified to “vod_playlist.m3u8”, which means that a palylist file named vod_playlist.m3u8 is created after the interface is called. + */ +$current_time = time(); +$ossClient->postVodPlaylist($bucket, + "test_rtmp_live", "vod_playlist.m3u8", + array('StartTime' => $current_time - 60, + 'EndTime' => $current_time) +); + +/** + * Call delete_live_channel to delete a live channel if it will no longer be in used. + */ +$ossClient->deleteBucketLiveChannel($bucket, "test_rtmp_live"); diff --git a/vendor/aliyuncs/oss-sdk-php/samples/MultipartUpload.php b/vendor/aliyuncs/oss-sdk-php/samples/MultipartUpload.php new file mode 100644 index 0000000..dd4b7fd --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/MultipartUpload.php @@ -0,0 +1,182 @@ +multiuploadFile($bucket, "file.php", __FILE__, array()); +Common::println("local file " . __FILE__ . " is uploaded to the bucket $bucket, file.php"); + + +// Upload local directory's data into target dir +$ossClient->uploadDir($bucket, "targetdir", __DIR__); +Common::println("local dir " . __DIR__ . " is uploaded to the bucket $bucket, targetdir/"); + + +// List the incomplete multipart uploads +$listMultipartUploadInfo = $ossClient->listMultipartUploads($bucket, array()); + + +//******************************* For complete usage, see the following functions **************************************************** + +multiuploadFile($ossClient, $bucket); +putObjectByRawApis($ossClient, $bucket); +uploadDir($ossClient, $bucket); +listMultipartUploads($ossClient, $bucket); + +/** + * Upload files using multipart upload + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function multiuploadFile($ossClient, $bucket) +{ + $object = "test/multipart-test.txt"; + $file = __FILE__; + $options = array(); + + try { + $ossClient->multiuploadFile($bucket, $object, $file, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Use basic multipart upload for file upload. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @throws OssException + */ +function putObjectByRawApis($ossClient, $bucket) +{ + $object = "test/multipart-test.txt"; + /** + * step 1. Initialize a block upload event, that is, a multipart upload process to get an upload id + */ + try { + $uploadId = $ossClient->initiateMultipartUpload($bucket, $object); + } catch (OssException $e) { + printf(__FUNCTION__ . ": initiateMultipartUpload FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": initiateMultipartUpload OK" . "\n"); + /* + * step 2. Upload parts + */ + $partSize = 10 * 1024 * 1024; + $uploadFile = __FILE__; + $uploadFileSize = sprintf('%u',filesize($uploadFile)); + $pieces = $ossClient->generateMultiuploadParts($uploadFileSize, $partSize); + $responseUploadPart = array(); + $uploadPosition = 0; + $isCheckMd5 = true; + foreach ($pieces as $i => $piece) { + $fromPos = $uploadPosition + (integer)$piece[$ossClient::OSS_SEEK_TO]; + $toPos = (integer)$piece[$ossClient::OSS_LENGTH] + $fromPos - 1; + $upOptions = array( + $ossClient::OSS_FILE_UPLOAD => $uploadFile, + $ossClient::OSS_PART_NUM => ($i + 1), + $ossClient::OSS_SEEK_TO => $fromPos, + $ossClient::OSS_LENGTH => $toPos - $fromPos + 1, + $ossClient::OSS_CHECK_MD5 => $isCheckMd5, + ); + if ($isCheckMd5) { + $contentMd5 = OssUtil::getMd5SumForFile($uploadFile, $fromPos, $toPos); + $upOptions[$ossClient::OSS_CONTENT_MD5] = $contentMd5; + } + //2. Upload each part to OSS + try { + $responseUploadPart[] = $ossClient->uploadPart($bucket, $object, $uploadId, $upOptions); + } catch (OssException $e) { + printf(__FUNCTION__ . ": initiateMultipartUpload, uploadPart - part#{$i} FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + printf(__FUNCTION__ . ": initiateMultipartUpload, uploadPart - part#{$i} OK\n"); + } + $uploadParts = array(); + foreach ($responseUploadPart as $i => $eTag) { + $uploadParts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $eTag, + ); + } + /** + * step 3. Complete the upload + */ + try { + $ossClient->completeMultipartUpload($bucket, $object, $uploadId, $uploadParts); + } catch (OssException $e) { + printf(__FUNCTION__ . ": completeMultipartUpload FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + printf(__FUNCTION__ . ": completeMultipartUpload OK\n"); +} + +/** + * Upload by directories + * + * @param OssClient $ossClient OssClient + * @param string $bucket bucket name + * + */ +function uploadDir($ossClient, $bucket) +{ + $localDirectory = "."; + $prefix = "samples/codes"; + try { + $ossClient->uploadDir($bucket, $prefix, $localDirectory); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + printf(__FUNCTION__ . ": completeMultipartUpload OK\n"); +} + +/** + * Get ongoing multipart uploads + * + * @param $ossClient OssClient + * @param $bucket string + */ +function listMultipartUploads($ossClient, $bucket) +{ + $options = array( + 'max-uploads' => 100, + 'key-marker' => '', + 'prefix' => '', + 'upload-id-marker' => '' + ); + try { + $listMultipartUploadInfo = $ossClient->listMultipartUploads($bucket, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": listMultipartUploads FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + printf(__FUNCTION__ . ": listMultipartUploads OK\n"); + $listUploadInfo = $listMultipartUploadInfo->getUploads(); + var_dump($listUploadInfo); +} diff --git a/vendor/aliyuncs/oss-sdk-php/samples/Object.php b/vendor/aliyuncs/oss-sdk-php/samples/Object.php new file mode 100644 index 0000000..5d83efa --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/Object.php @@ -0,0 +1,765 @@ +putObject($bucket, "b.file", "hi, oss"); +Common::println("b.file is created"); +Common::println($result['x-oss-request-id']); +Common::println($result['etag']); +Common::println($result['content-md5']); +Common::println($result['body']); + +// Uploads a local file to an OSS file +$result = $ossClient->uploadFile($bucket, "c.file", __FILE__); +Common::println("c.file is created"); +Common::println("b.file is created"); +Common::println($result['x-oss-request-id']); +Common::println($result['etag']); +Common::println($result['content-md5']); +Common::println($result['body']); + +// Download an oss object as an in-memory variable +$content = $ossClient->getObject($bucket, "b.file"); +Common::println("b.file is fetched, the content is: " . $content); + +// Add a symlink to an object +$content = $ossClient->putSymlink($bucket, "test-symlink", "b.file"); +Common::println("test-symlink is created"); +Common::println($result['x-oss-request-id']); +Common::println($result['etag']); + +// Get a symlink +$content = $ossClient->getSymlink($bucket, "test-symlink"); +Common::println("test-symlink refer to : " . $content[OssClient::OSS_SYMLINK_TARGET]); + +// Download an object to a local file. +$options = array( + OssClient::OSS_FILE_DOWNLOAD => "./c.file.localcopy", +); +$ossClient->getObject($bucket, "c.file", $options); +Common::println("b.file is fetched to the local file: c.file.localcopy"); +Common::println("b.file is created"); + + +// Restore Object +$day = 3; +$tier = 'Expedited'; +$config = new RestoreConfig($day,$tier); +$options = array( + OssClient::OSS_RESTORE_CONFIG => $config +); +$ossClient->restoreObject($bucket, 'b.file',$options); + + +// Copy an object +$result = $ossClient->copyObject($bucket, "c.file", $bucket, "c.file.copy"); +Common::println("lastModifiedTime: " . $result[0]); +Common::println("ETag: " . $result[1]); + +// Check whether an object exists +$doesExist = $ossClient->doesObjectExist($bucket, "c.file.copy"); +Common::println("file c.file.copy exist? " . ($doesExist ? "yes" : "no")); + +// Delete an object +$result = $ossClient->deleteObject($bucket, "c.file.copy"); +Common::println("c.file.copy is deleted"); +Common::println("b.file is created"); +Common::println($result['x-oss-request-id']); + +// Check whether an object exists +$doesExist = $ossClient->doesObjectExist($bucket, "c.file.copy"); +Common::println("file c.file.copy exist? " . ($doesExist ? "yes" : "no")); + +// Delete multiple objects in batch +$result = $ossClient->deleteObjects($bucket, array("b.file", "c.file")); +foreach($result as $object) + Common::println($object); + +sleep(2); +unlink("c.file.localcopy"); + +// Normal upload and download speed limit +$object= "b.file"; +$content = "hello world"; + +// The speed limit is 100 KB/s, which is 819200 bit/s. +$options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_TRAFFIC_LIMIT => 819200, + )); +// Speed limit upload. +$ossClient->putObject($bucket, $object, $content, $options); + +// Speed limit download. +$ossClient->getObject($bucket, $object, $options); + +// Signed URL upload and download speed limit + +// Create a URL for uploading with a limited rate, and the validity period is 60s. +$timeout = 60; +$signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options); +Common::println("b.file speed limit upload url:".$signedUrl.PHP_EOL); + +// Create a URL for speed-limited downloads, with a validity period of 120s. +$timeout = 120; +$signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "GET", $options); +Common::println("b.file speed limit download url:".$signedUrl.PHP_EOL); + +//******************************* For complete usage, see the following functions **************************************************** + +listObjects($ossClient, $bucket); +listObjectsV2($ossClient, $bucket); +listAllObjects($ossClient, $bucket); +createObjectDir($ossClient, $bucket); +putObject($ossClient, $bucket); +uploadFile($ossClient, $bucket); +getObject($ossClient, $bucket); +getObjectToLocalFile($ossClient, $bucket); +copyObject($ossClient, $bucket); +modifyMetaForObject($ossClient, $bucket); +getObjectMeta($ossClient, $bucket); +deleteObject($ossClient, $bucket); +deleteObjects($ossClient, $bucket); +doesObjectExist($ossClient, $bucket); +getSymlink($ossClient, $bucket); +putSymlink($ossClient, $bucket); +putObjectSpeed($ossClient, $bucket); +getObjectSpeed($ossClient, $bucket); +signUrlSpeedUpload($ossClient, $bucket); +signUrlSpeedDownload($ossClient, $bucket); +restoreObject($ossClient,$bucket); +/** + * Create a 'virtual' folder + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function createObjectDir($ossClient, $bucket) +{ + try { + $ossClient->createObjectDir($bucket, "dir"); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Upload in-memory data to oss + * + * Simple upload---upload specified in-memory data to an OSS object + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function putObject($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $content = file_get_contents(__FILE__); + $options = array(); + try { + $ossClient->putObject($bucket, $object, $content, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Uploads a local file to OSS + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function uploadFile($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $filePath = __FILE__; + $options = array(); + + try { + $ossClient->uploadFile($bucket, $object, $filePath, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Lists all files and folders in the bucket. + * Note if there's more items than the max-keys specified, the caller needs to use the nextMarker returned as the value for the next call's maker paramter. + * Loop through all the items returned from ListObjects. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function listObjects($ossClient, $bucket) +{ + $prefix = 'oss-php-sdk-test/'; + $delimiter = '/'; + $nextMarker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $nextMarker, + ); + try { + $listObjectInfo = $ossClient->listObjects($bucket, $options); + printf("Bucket Name: %s". "\n",$listObjectInfo->getBucketName()); + printf("Prefix: %s". "\n",$listObjectInfo->getPrefix()); + printf("Marker: %s". "\n",$listObjectInfo->getMarker()); + printf("Next Marker: %s". "\n",$listObjectInfo->getNextMarker()); + printf("Max Keys: %s". "\n",$listObjectInfo->getMaxKeys()); + printf("Delimiter: %s". "\n",$listObjectInfo->getDelimiter()); + printf("Is Truncated: %s". "\n",$listObjectInfo->getIsTruncated()); + $objectList = $listObjectInfo->getObjectList(); // object list + $prefixList = $listObjectInfo->getPrefixList(); // directory list + if (!empty($objectList)) { + print("objectList:\n"); + foreach ($objectList as $objectInfo) { + printf("Object Name: %s". "\n",$objectInfo->getKey()); + printf("Object Size: %s". "\n",$objectInfo->getSize()); + printf("Object Type: %s". "\n",$objectInfo->getType()); + printf("Object ETag: %s". "\n",$objectInfo->getETag()); + printf("Object Last Modified: %s". "\n",$objectInfo->getLastModified()); + printf("Object Storage Class: %s". "\n",$objectInfo->getStorageClass()); + + if ($objectInfo->getRestoreInfo()){ + printf("Restore Info: %s". "\n",$objectInfo->getRestoreInfo() ); + } + + if($objectInfo->getOwner()){ + printf("Owner Id:".$objectInfo->getOwner()->getId() . "\n"); + printf("Owner Name:".$objectInfo->getOwner()->getDisplayName() . "\n"); + } + } + } + if (!empty($prefixList)) { + print("prefixList: \n"); + foreach ($prefixList as $prefixInfo) { + printf("Common Prefix:%s\n",$prefixInfo->getPrefix()); + } + } + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Lists all files and folders in the bucket. + * Note if there's more items than the max-keys specified, the caller needs to use the nextMarker returned as the value for the next call's maker paramter. + * Loop through all the items returned from ListObjects. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function listObjectsV2($ossClient, $bucket) +{ + $prefix = 'oss-php-sdk-test/'; + $delimiter = '/'; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'start-after' =>'test-object', + 'fetch-owner' =>'true', + ); + try { + $listObjectInfo = $ossClient->listObjectsV2($bucket, $options); + printf("Bucket Name: %s". "\n",$listObjectInfo->getBucketName()); + printf("Prefix: %s". "\n",$listObjectInfo->getPrefix()); + printf("Next Continuation Token: %s". "\n",$listObjectInfo->getNextContinuationToken()); + printf("Continuation Token: %s". "\n",$listObjectInfo->getContinuationToken()); + printf("Max Keys: %s". "\n",$listObjectInfo->getMaxKeys()); + printf("Key Count: %s". "\n",$listObjectInfo->getKeyCount()); + printf("Delimiter: %s". "\n",$listObjectInfo->getDelimiter()); + printf("Is Truncated: %s". "\n",$listObjectInfo->getIsTruncated()); + printf("Start After: %s". "\n",$listObjectInfo->getStartAfter()); + $objectList = $listObjectInfo->getObjectList(); // object list + $prefixList = $listObjectInfo->getPrefixList(); // directory list + if (!empty($objectList)) { + print("objectList:\n"); + foreach ($objectList as $objectInfo) { + printf("Object Name: %s". "\n",$objectInfo->getKey()); + printf("Object Size: %s". "\n",$objectInfo->getSize()); + printf("Object Type: %s". "\n",$objectInfo->getType()); + printf("Object ETag: %s". "\n",$objectInfo->getETag()); + printf("Object Last Modified: %s". "\n",$objectInfo->getLastModified()); + printf("Object Storage Class: %s". "\n",$objectInfo->getStorageClass()); + + if ($objectInfo->getRestoreInfo()){ + printf("Restore Info: %s". "\n",$objectInfo->getRestoreInfo() ); + } + + if($objectInfo->getOwner()){ + printf("Owner Id:".$objectInfo->getOwner()->getId() . "\n"); + printf("Owner Name:".$objectInfo->getOwner()->getDisplayName() . "\n"); + } + } + } + if (!empty($prefixList)) { + print("prefixList: \n"); + foreach ($prefixList as $prefixInfo) { + printf("Common Prefix:%s\n",$prefixInfo->getPrefix()); + } + } + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Lists all folders and files under the bucket. Use nextMarker repeatedly to get all objects. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function listAllObjects($ossClient, $bucket) +{ + // Create dir/obj 'folder' and put some files into it. + for ($i = 0; $i < 100; $i += 1) { + $ossClient->putObject($bucket, "dir/obj" . strval($i), "hi"); + $ossClient->createObjectDir($bucket, "dir/obj" . strval($i)); + } + + $prefix = 'dir/'; + $delimiter = '/'; + $nextMarker = ''; + $maxkeys = 30; + + while (true) { + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $nextMarker, + ); + var_dump($options); + try { + $listObjectInfo = $ossClient->listObjects($bucket, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + // Get the nextMarker, and it would be used as the next call's marker parameter to resume from the last call + $nextMarker = $listObjectInfo->getNextMarker(); + $listObject = $listObjectInfo->getObjectList(); + $listPrefix = $listObjectInfo->getPrefixList(); + var_dump(count($listObject)); + var_dump(count($listPrefix)); + if ($nextMarker === '') { + break; + } + } +} + +/** + * Get the content of an object. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getObject($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $options = array(); + try { + $content = $ossClient->getObject($bucket, $object, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + if (file_get_contents(__FILE__) === $content) { + print(__FUNCTION__ . ": FileContent checked OK" . "\n"); + } else { + print(__FUNCTION__ . ": FileContent checked FAILED" . "\n"); + } +} + +/** + * Put symlink + * + * @param OssClient $ossClient The Instance of OssClient + * @param string $bucket bucket name + * @return null + */ +function putSymlink($ossClient, $bucket) +{ + $symlink = "test-samples-symlink"; + $object = "test-samples-object"; + try { + $ossClient->putObject($bucket, $object, 'test-content'); + $ossClient->putSymlink($bucket, $symlink, $object); + $content = $ossClient->getObject($bucket, $symlink); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + if ($content == 'test-content') { + print(__FUNCTION__ . ": putSymlink checked OK" . "\n"); + } else { + print(__FUNCTION__ . ": putSymlink checked FAILED" . "\n"); + } +} + +/** + * Get symlink + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getSymlink($ossClient, $bucket) +{ + $symlink = "test-samples-symlink"; + $object = "test-samples-object"; + try { + $ossClient->putObject($bucket, $object, 'test-content'); + $ossClient->putSymlink($bucket, $symlink, $object); + $content = $ossClient->getSymlink($bucket, $symlink); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + if ($content[OssClient::OSS_SYMLINK_TARGET]) { + print(__FUNCTION__ . ": getSymlink checked OK" . "\n"); + } else { + print(__FUNCTION__ . ": getSymlink checked FAILED" . "\n"); + } +} + +/** + * Get_object_to_local_file + * + * Get object + * Download object to a specified file. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getObjectToLocalFile($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $localfile = "upload-test-object-name.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $ossClient->getObject($bucket, $object, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK, please check localfile: 'upload-test-object-name.txt'" . "\n"); + if (file_get_contents($localfile) === file_get_contents(__FILE__)) { + print(__FUNCTION__ . ": FileContent checked OK" . "\n"); + } else { + print(__FUNCTION__ . ": FileContent checked FAILED" . "\n"); + } + if (file_exists($localfile)) { + unlink($localfile); + } +} + +/** + * Copy object + * When the source object is same as the target one, copy operation will just update the metadata. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function copyObject($ossClient, $bucket) +{ + $fromBucket = $bucket; + $fromObject = "oss-php-sdk-test/upload-test-object-name.txt"; + $toBucket = $bucket; + $toObject = $fromObject . '.copy'; + $options = array(); + + try { + $ossClient->copyObject($fromBucket, $fromObject, $toBucket, $toObject, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Update Object Meta + * it leverages the feature of copyObject: when the source object is just the target object, the metadata could be updated via copy + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function modifyMetaForObject($ossClient, $bucket) +{ + $fromBucket = $bucket; + $fromObject = "oss-php-sdk-test/upload-test-object-name.txt"; + $toBucket = $bucket; + $toObject = $fromObject; + $copyOptions = array( + OssClient::OSS_HEADERS => array( + 'Cache-Control' => 'max-age=60', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + try { + $ossClient->copyObject($fromBucket, $fromObject, $toBucket, $toObject, $copyOptions); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Get object meta, that is, getObjectMeta + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getObjectMeta($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $objectMeta = $ossClient->getObjectMeta($bucket, $object); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + if (isset($objectMeta[strtolower('Content-Disposition')]) && + 'attachment; filename="xxxxxx"' === $objectMeta[strtolower('Content-Disposition')] + ) { + print(__FUNCTION__ . ": ObjectMeta checked OK" . "\n"); + } else { + print(__FUNCTION__ . ": ObjectMeta checked FAILED" . "\n"); + } +} + +/** + * Delete an object + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteObject($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $ossClient->deleteObject($bucket, $object); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * Delete multiple objects in batch + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function deleteObjects($ossClient, $bucket) +{ + $objects = array(); + $objects[] = "oss-php-sdk-test/upload-test-object-name.txt"; + $objects[] = "oss-php-sdk-test/upload-test-object-name.txt.copy"; + try { + $ossClient->deleteObjects($bucket, $objects); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Check whether an object exists + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function doesObjectExist($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $exist = $ossClient->doesObjectExist($bucket, $object); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + var_dump($exist); +} + +/** + * Speed limit upload. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function putObjectSpeed($ossClient, $bucket) +{ + $object = "upload-test-object-name.txt"; + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_TRAFFIC_LIMIT => 819200, + )); + try { + $ossClient->putObject($bucket, $object, $content, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Speed limit download. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function getObjectSpeed($ossClient, $bucket) +{ + $object = "upload-test-object-name.txt"; + $options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_TRAFFIC_LIMIT => 819200, + )); + try { + $ossClient->getObject($bucket, $object, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Speed limit download. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function signUrlSpeedUpload($ossClient, $bucket) +{ + $object = "upload-test-object-name.txt"; + $timeout = 120; + $options = array( + OssClient::OSS_TRAFFIC_LIMIT => 819200, + ); + $timeout = 60; + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options); + print($signedUrl); +} + + +/** + * Speed limit download. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function signUrlSpeedDownload($ossClient, $bucket) +{ + $object = "upload-test-object-name.txt"; + $timeout = 120; + $options = array( + OssClient::OSS_TRAFFIC_LIMIT => 819200, + ); + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "GET", $options); + print($signedUrl); + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Restore object + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + */ +function restoreObject($ossClient, $bucket) +{ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $day = 3; + $tier = 'Expedited'; + $config = new RestoreConfig($day,$tier); + $options = array( + OssClient::OSS_RESTORE_CONFIG => $config + ); + try { + $ossClient->restoreObject($bucket, $object,$options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); +} diff --git a/vendor/aliyuncs/oss-sdk-php/samples/ObjectTagging.php b/vendor/aliyuncs/oss-sdk-php/samples/ObjectTagging.php new file mode 100644 index 0000000..adc283b --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/ObjectTagging.php @@ -0,0 +1,366 @@ + array( + 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', + ) +); +$result = $ossClient->putObject($bucket, $object, __FILE__,$options); +Common::println("b.file is created"); +Common::println("tag is:".$result['oss-requestheaders']['x-oss-tagging']); + +// Add object tags when uploading parts + +$object = "b.file"; +$file = __FILE__; +$options = array( + OssClient::OSS_CHECK_MD5 => true, + OssClient::OSS_PART_SIZE => 1, + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', + ), +); +$result = $ossClient->multiuploadFile($bucket, $object, $file, $options); +Common::println("b.file is created"); +Common::println("tag is:".$result['oss-requestheaders']['x-oss-tagging']); + +// get tags from object + +$object = "a.txt"; +$result = $ossClient->getObjectTagging($bucket,$object); +printf($object.'tags is: '.$result->serializeToXml().PHP_EOL); + + +// Add or change object tags to uploaded objects +$config = new TaggingConfig(); +$config->addTag(new Tag("key1", "value1")); +$config->addTag(new Tag("key2", "value2")); + +$ossClient->putObjectTagging($bucket, $object, $config); +// Add object tags when uploading +$object = "a.txt"; +$filePath = "D:\\localpath\\b.txt"; +$filePath1 = "D:\\localpath\\c.txt"; +$options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2', + ) +); +$position = $ossClient->appendObject($bucket, $object,'content one',0,$options); +printf('Content one append object Success'.PHP_EOL); +$position = $ossClient->appendObject($bucket, $object, 'content two',$position,$options); +printf('Content two append object Success'.PHP_EOL); + +// delete tags +$object = "g.file"; +$ossClient->deleteObjectTagging($bucket, $object); +printf($object.' tags has deleted'.PHP_EOL); + +// Copy a small file +$fromBucket = $bucket; +$fromObject = "a.file"; +$toBucket = $bucket; +$toObject = $fromObject . '.copy'; +$options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging-directive' => 'Replace', + 'x-oss-tagging'=>'key1=value1&key2=value2&key3=value3', + )); +$ossClient->copyObject($fromBucket, $fromObject, $toBucket, $toObject, $options); +$config = $ossClient->getObjectTagging($bucket, $toObject); +Common::println('object tags is:'.$config->serializeToXml()); + +// Copy a large file +$fromBucket = $bucket; +$fromObject = "a.file"; +$toBucket = $bucket; +$toObject = $fromObject . '.copy'; +$options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging'=>'key1=value1&key2=value2&key3=value3', + )); + +$part_size = 256*1024*1024; +$objectMeta = $ossClient->getObjectMeta($fromBucket, $fromObject); +$length = $objectMeta['content-length']; +$upload_id = $ossClient->initiateMultipartUpload($toBucket, $toObject,$options); +$pieces = $ossClient->generateMultiuploadParts($length, $part_size); +$response_upload_part = array(); +$copyId = 1; +$upload_position = 0; +foreach ($pieces as $i => $piece) { + $from_pos = $upload_position + (integer)$piece['seekTo']; + $to_pos = (integer)$piece['length'] + $from_pos - 1; + $up_options = array( + 'start' => $from_pos, + 'end' => $to_pos, + ); + $response_upload_part[] = $ossClient->uploadPartCopy( $fromBucket, $fromObject, $toBucket, $toObject, $copyId, $upload_id, $up_options); + printf("initiateMultipartUpload, uploadPartCopy - part#{$copyId} OK\n"); + $copyId = $copyId + 1; +} +$upload_parts = array(); +foreach ($response_upload_part as $i => $etag) { + $upload_parts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $etag, + ); +} +$result = $ossClient->completeMultipartUpload($toBucket, $toObject, $upload_id, $upload_parts); +$config = $ossClient->getObjectTagging($bucket, $toObject); +Common::println($toObject.' tags is:'.$config->serializeToXml()); + + + +//******************************* For complete usage, see the following functions **************************************************** + +putObject($ossClient,$bucket); +multiuploadFile($ossClient,$bucket); +appendObject($ossClient,$bucket); +putObjectTagging($ossClient,$bucket); +getObjectTagging($ossClient,$bucket); +deleteObjectTagging($ossClient,$bucket); +copyObjectSmall($ossClient,$bucket); +copyObjectLarge($ossClient,$bucket); +/** + * Upload Object add tag + * @param $ossClient OssClient + * @param $bucket bucket_name + */ +function putObject($ossClient,$bucket){ + $object = "b.file"; + $options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', + )); + try { + // 通过简单上传的方式上传Object。 + $result = $ossClient->putObject($bucket, $object, __FILE__,$options); + Common::println("b.file is created".PHP_EOL); + Common::println("tag is:".$result['oss-requestheaders']['x-oss-tagging'].PHP_EOL); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Add object tags when uploading parts + * @param $ossClient OssClient + * @param $bucket bucket_name + */ +function multiuploadFile($ossClient,$bucket){ + $object = "b.file"; + $file = __FILE__; + $options = array( + OssClient::OSS_CHECK_MD5 => true, + OssClient::OSS_PART_SIZE => 1, + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', + ), + ); + + try { + $result = $ossClient->multiuploadFile($bucket, $object, $file, $options); + Common::println("b.file is created".PHP_EOL); + Common::println("tag is:".$result['oss-requestheaders']['x-oss-tagging'].PHP_EOL); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Add object tags when uploading + * @param $ossClient OssClient + * @param $bucket bucket_name string + */ +function appendObject($ossClient,$bucket){ + $object = "g.file"; + $content_array = array('Hello OSS', 'Hi OSS'); + $options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2', + )); + + try { + $position = $ossClient->appendObject($bucket, $object, $content_array[0], 0, $options); + printf($content_array[0].' append object Success'.PHP_EOL); + $position = $ossClient->appendObject($bucket, $object, $content_array[1], $position); + printf($content_array[1].' append object Success'.PHP_EOL); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * @param $ossClient OssClient + * @param $bucket bucket_name string + * @throws OssException + */ +function putObjectTagging($ossClient,$bucket){ + $object = "g.file"; + $config = new TaggingConfig(); + $config->addTag(new Tag("key1", "value1")); + $config->addTag(new Tag("key2", "value2")); + + try { + $ossClient->putObjectTagging($bucket, $object, $config); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * get object tags + * @param $ossClient OssClient + * @param $bucket bucket_name string + */ +function getObjectTagging($ossClient,$bucket){ + $object = "g.file"; + try { + $config = $ossClient->getObjectTagging($bucket, $object); + printf($object." tags is:".$config->serializeToXml().PHP_EOL); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + + +/** + * get object tags + * @param $ossClient OssClient + * @param $bucket bucket_name string + */ +function deleteObjectTagging($ossClient,$bucket){ + $object = "g.file"; + try { + $ossClient->deleteObjectTagging($bucket, $object); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Copy small files + * @param $ossClient OssClient + * @param $bucket bucket_name string + */ +function copyObjectSmall($ossClient,$bucket){ + $fromBucket = $bucket; + $fromObject = "a.file"; + $toBucket = $bucket; + $toObject = $fromObject . '.copy'; + $options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging-directive' => 'Replace', + 'x-oss-tagging'=>'key1=value1&key2=value2&key3=value3', + )); + + try { + $ossClient->copyObject($fromBucket, $fromObject, $toBucket, $toObject, $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + + $config = $ossClient->getObjectTagging($bucket, $toObject); + Common::println('object tags is:'.$config->serializeToXml()); + print(__FUNCTION__ . ": OK" . "\n"); +} + +/** + * Copy a large file + * @param $ossClient OssClient + * @param $bucket bucket_name string + */ +function copyObjectLarge($ossClient,$bucket){ + $fromBucket = $bucket; + $fromObject = "a.file"; + $toBucket = $bucket; + $toObject = $fromObject . '.copy'; + $options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging'=>'key1=value1&key2=value2&key3=value3', + )); + + $part_size = 256*1024*1024; + try{ + $objectMeta = $ossClient->getObjectMeta($fromBucket, $fromObject); + $length = $objectMeta['content-length']; + $upload_id = $ossClient->initiateMultipartUpload($toBucket, $toObject,$options); + $pieces = $ossClient->generateMultiuploadParts($length, $part_size); + $response_upload_part = array(); + $copyId = 1; + $upload_position = 0; + foreach ($pieces as $i => $piece) { + $from_pos = $upload_position + (integer)$piece['seekTo']; + $to_pos = (integer)$piece['length'] + $from_pos - 1; + $up_options = array( + 'start' => $from_pos, + 'end' => $to_pos, + ); + $response_upload_part[] = $ossClient->uploadPartCopy( $fromBucket, $fromObject, $toBucket, $toObject, $copyId, $upload_id, $up_options); + printf("initiateMultipartUpload, uploadPartCopy - part#{$copyId} OK\n"); + $copyId = $copyId + 1; + } + $upload_parts = array(); + foreach ($response_upload_part as $i => $etag) { + $upload_parts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $etag, + ); + } + $result = $ossClient->completeMultipartUpload($toBucket, $toObject, $upload_id, $upload_parts); + printf('copy success'. "\n"); + } catch(OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + + + } + $config = $ossClient->getObjectTagging($bucket, $toObject); + Common::println($toObject.' tags is:'.$config->serializeToXml()); + print(__FUNCTION__ . ": OK" . "\n"); +} + diff --git a/vendor/aliyuncs/oss-sdk-php/samples/RunAll.php b/vendor/aliyuncs/oss-sdk-php/samples/RunAll.php new file mode 100644 index 0000000..0cd7ec1 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/samples/RunAll.php @@ -0,0 +1,13 @@ +uploadFile($bucket, "a.file", __FILE__); + +// Generate a signed url for getting an object. The URL can be used in browser directly to download the file. +$signedUrl = $ossClient->signUrl($bucket, "a.file", 3600); +Common::println($signedUrl); + +// Generate the signed url for putting an object. User can use put method with this url to upload a file to "a.file". +$signedUrl = $ossClient->signUrl($bucket, "a.file", "3600", "PUT"); +Common::println($signedUrl); + +// Generate the signed url for putting an object from local file. The url can be used directly to upload the file to "a.file". +$signedUrl = $ossClient->signUrl($bucket, "a.file", 3600, "PUT", array('Content-Type' => 'txt')); +Common::println($signedUrl); + +//******************************* For complete usage, see the following functions **************************************************** + +getSignedUrlForPuttingObject($ossClient, $bucket); +getSignedUrlForPuttingObjectFromFile($ossClient, $bucket); +getSignedUrlForGettingObject($ossClient, $bucket); + +/** + * Generate the signed url for getObject() to control read accesses under private privilege + * + * @param $ossClient OssClient OssClient instance + * @param $bucket string bucket name + * @return null + */ +function getSignedUrlForGettingObject($ossClient, $bucket) +{ + $object = "test/test-signature-test-upload-and-download.txt"; + $timeout = 3600; + try { + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n"); + /** + * Use similar code to access the object by url, or use browser to access the object. + */ + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + if ($res->isOK()) { + print(__FUNCTION__ . ": OK" . "\n"); + } else { + print(__FUNCTION__ . ": FAILED" . "\n"); + }; +} + +/** + * Generate the signed url for PutObject to control write accesses under private privilege. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @return null + * @throws OssException + */ +function getSignedUrlForPuttingObject($ossClient, $bucket) +{ + $object = "test/test-signature-test-upload-and-download.txt"; + $timeout = 3600; + $options = NULL; + try { + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT"); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n"); + $content = file_get_contents(__FILE__); + + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + if ($res->isOK()) { + print(__FUNCTION__ . ": OK" . "\n"); + } else { + print(__FUNCTION__ . ": FAILED" . "\n"); + }; +} + +/** + * Generate the signed url for PutObject's signed url. User could use the signed url to upload file directly. + * + * @param OssClient $ossClient OssClient instance + * @param string $bucket bucket name + * @throws OssException + */ +function getSignedUrlForPuttingObjectFromFile($ossClient, $bucket) +{ + $file = __FILE__; + $object = "test/test-signature-test-upload-and-download.txt"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": signedUrl: " . $signedUrl . "\n"); + + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', 'txt'); + $request->set_read_file($file); + $request->set_read_stream_size(sprintf('%u',filesize($file))); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + if ($res->isOK()) { + print(__FUNCTION__ . ": OK" . "\n"); + } else { + print(__FUNCTION__ . ": FAILED" . "\n"); + }; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php new file mode 100644 index 0000000..17685c3 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/MimeTypes.php @@ -0,0 +1,263 @@ + 1) { + $ext = strtolower(end($parts)); + if (isset(self::$mime_types[$ext])) { + return self::$mime_types[$ext]; + } + } + + return null; + } + + private static $mime_types = array( + 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', + 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', + 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', + 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', + 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', + 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', + 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', + 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', + 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', + 'apk' => 'application/vnd.android.package-archive', + 'hqx' => 'application/mac-binhex40', + 'cpt' => 'application/mac-compactpro', + 'doc' => 'application/msword', + 'ogg' => 'audio/ogg', + 'pdf' => 'application/pdf', + 'rtf' => 'text/rtf', + 'mif' => 'application/vnd.mif', + 'xls' => 'application/vnd.ms-excel', + 'ppt' => 'application/vnd.ms-powerpoint', + 'odc' => 'application/vnd.oasis.opendocument.chart', + 'odb' => 'application/vnd.oasis.opendocument.database', + 'odf' => 'application/vnd.oasis.opendocument.formula', + 'odg' => 'application/vnd.oasis.opendocument.graphics', + 'otg' => 'application/vnd.oasis.opendocument.graphics-template', + 'odi' => 'application/vnd.oasis.opendocument.image', + 'odp' => 'application/vnd.oasis.opendocument.presentation', + 'otp' => 'application/vnd.oasis.opendocument.presentation-template', + 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', + 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', + 'odt' => 'application/vnd.oasis.opendocument.text', + 'odm' => 'application/vnd.oasis.opendocument.text-master', + 'ott' => 'application/vnd.oasis.opendocument.text-template', + 'oth' => 'application/vnd.oasis.opendocument.text-web', + 'sxw' => 'application/vnd.sun.xml.writer', + 'stw' => 'application/vnd.sun.xml.writer.template', + 'sxc' => 'application/vnd.sun.xml.calc', + 'stc' => 'application/vnd.sun.xml.calc.template', + 'sxd' => 'application/vnd.sun.xml.draw', + 'std' => 'application/vnd.sun.xml.draw.template', + 'sxi' => 'application/vnd.sun.xml.impress', + 'sti' => 'application/vnd.sun.xml.impress.template', + 'sxg' => 'application/vnd.sun.xml.writer.global', + 'sxm' => 'application/vnd.sun.xml.math', + 'sis' => 'application/vnd.symbian.install', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'wmlsc' => 'application/vnd.wap.wmlscriptc', + 'bcpio' => 'application/x-bcpio', + 'torrent' => 'application/x-bittorrent', + 'bz2' => 'application/x-bzip2', + 'vcd' => 'application/x-cdlink', + 'pgn' => 'application/x-chess-pgn', + 'cpio' => 'application/x-cpio', + 'csh' => 'application/x-csh', + 'dvi' => 'application/x-dvi', + 'spl' => 'application/x-futuresplash', + 'gtar' => 'application/x-gtar', + 'hdf' => 'application/x-hdf', + 'jar' => 'application/java-archive', + 'jnlp' => 'application/x-java-jnlp-file', + 'js' => 'application/javascript', + 'json' => 'application/json', + 'ksp' => 'application/x-kspread', + 'chrt' => 'application/x-kchart', + 'kil' => 'application/x-killustrator', + 'latex' => 'application/x-latex', + 'rpm' => 'application/x-rpm', + 'sh' => 'application/x-sh', + 'shar' => 'application/x-shar', + 'swf' => 'application/x-shockwave-flash', + 'sit' => 'application/x-stuffit', + 'sv4cpio' => 'application/x-sv4cpio', + 'sv4crc' => 'application/x-sv4crc', + 'tar' => 'application/x-tar', + 'tcl' => 'application/x-tcl', + 'tex' => 'application/x-tex', + 'man' => 'application/x-troff-man', + 'me' => 'application/x-troff-me', + 'ms' => 'application/x-troff-ms', + 'ustar' => 'application/x-ustar', + 'src' => 'application/x-wais-source', + 'zip' => 'application/zip', + 'm3u' => 'audio/x-mpegurl', + 'ra' => 'audio/x-pn-realaudio', + 'wav' => 'audio/x-wav', + 'wma' => 'audio/x-ms-wma', + 'wax' => 'audio/x-ms-wax', + 'pdb' => 'chemical/x-pdb', + 'xyz' => 'chemical/x-xyz', + 'bmp' => 'image/bmp', + 'gif' => 'image/gif', + 'ief' => 'image/ief', + 'png' => 'image/png', + 'wbmp' => 'image/vnd.wap.wbmp', + 'ras' => 'image/x-cmu-raster', + 'pnm' => 'image/x-portable-anymap', + 'pbm' => 'image/x-portable-bitmap', + 'pgm' => 'image/x-portable-graymap', + 'ppm' => 'image/x-portable-pixmap', + 'rgb' => 'image/x-rgb', + 'xbm' => 'image/x-xbitmap', + 'xpm' => 'image/x-xpixmap', + 'xwd' => 'image/x-xwindowdump', + 'css' => 'text/css', + 'rtx' => 'text/richtext', + 'tsv' => 'text/tab-separated-values', + 'jad' => 'text/vnd.sun.j2me.app-descriptor', + 'wml' => 'text/vnd.wap.wml', + 'wmls' => 'text/vnd.wap.wmlscript', + 'etx' => 'text/x-setext', + 'mxu' => 'video/vnd.mpegurl', + 'flv' => 'video/x-flv', + 'wm' => 'video/x-ms-wm', + 'wmv' => 'video/x-ms-wmv', + 'wmx' => 'video/x-ms-wmx', + 'wvx' => 'video/x-ms-wvx', + 'avi' => 'video/x-msvideo', + 'movie' => 'video/x-sgi-movie', + 'ice' => 'x-conference/x-cooltalk', + '3gp' => 'video/3gpp', + 'ai' => 'application/postscript', + 'aif' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'asc' => 'text/plain', + 'atom' => 'application/atom+xml', + 'au' => 'audio/basic', + 'bin' => 'application/octet-stream', + 'cdf' => 'application/x-netcdf', + 'cgm' => 'image/cgm', + 'class' => 'application/octet-stream', + 'dcr' => 'application/x-director', + 'dif' => 'video/x-dv', + 'dir' => 'application/x-director', + 'djv' => 'image/vnd.djvu', + 'djvu' => 'image/vnd.djvu', + 'dll' => 'application/octet-stream', + 'dmg' => 'application/octet-stream', + 'dms' => 'application/octet-stream', + 'dtd' => 'application/xml-dtd', + 'dv' => 'video/x-dv', + 'dxr' => 'application/x-director', + 'eps' => 'application/postscript', + 'exe' => 'application/octet-stream', + 'ez' => 'application/andrew-inset', + 'gram' => 'application/srgs', + 'grxml' => 'application/srgs+xml', + 'gz' => 'application/x-gzip', + 'htm' => 'text/html', + 'html' => 'text/html', + 'ico' => 'image/x-icon', + 'ics' => 'text/calendar', + 'ifb' => 'text/calendar', + 'iges' => 'model/iges', + 'igs' => 'model/iges', + 'jp2' => 'image/jp2', + 'jpe' => 'image/jpeg', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'kar' => 'audio/midi', + 'lha' => 'application/octet-stream', + 'lzh' => 'application/octet-stream', + 'm4a' => 'audio/mp4a-latm', + 'm4p' => 'audio/mp4a-latm', + 'm4u' => 'video/vnd.mpegurl', + 'm4v' => 'video/x-m4v', + 'mac' => 'image/x-macpaint', + 'mathml' => 'application/mathml+xml', + 'mesh' => 'model/mesh', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mov' => 'video/quicktime', + 'mp2' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'mp4' => 'video/mp4', + 'mpe' => 'video/mpeg', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpga' => 'audio/mpeg', + 'msh' => 'model/mesh', + 'nc' => 'application/x-netcdf', + 'oda' => 'application/oda', + 'ogv' => 'video/ogv', + 'pct' => 'image/pict', + 'pic' => 'image/pict', + 'pict' => 'image/pict', + 'pnt' => 'image/x-macpaint', + 'pntg' => 'image/x-macpaint', + 'ps' => 'application/postscript', + 'qt' => 'video/quicktime', + 'qti' => 'image/x-quicktime', + 'qtif' => 'image/x-quicktime', + 'ram' => 'audio/x-pn-realaudio', + 'rdf' => 'application/rdf+xml', + 'rm' => 'application/vnd.rn-realmedia', + 'roff' => 'application/x-troff', + 'sgm' => 'text/sgml', + 'sgml' => 'text/sgml', + 'silo' => 'model/mesh', + 'skd' => 'application/x-koan', + 'skm' => 'application/x-koan', + 'skp' => 'application/x-koan', + 'skt' => 'application/x-koan', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'snd' => 'audio/basic', + 'so' => 'application/octet-stream', + 'svg' => 'image/svg+xml', + 't' => 'application/x-troff', + 'texi' => 'application/x-texinfo', + 'texinfo' => 'application/x-texinfo', + 'tif' => 'image/tiff', + 'tiff' => 'image/tiff', + 'tr' => 'application/x-troff', + 'txt' => 'text/plain', + 'vrml' => 'model/vrml', + 'vxml' => 'application/voicexml+xml', + 'webm' => 'video/webm', + 'webp' => 'image/webp', + 'wrl' => 'model/vrml', + 'xht' => 'application/xhtml+xml', + 'xhtml' => 'application/xhtml+xml', + 'xml' => 'application/xml', + 'xsl' => 'application/xml', + 'xslt' => 'application/xslt+xml', + 'xul' => 'application/vnd.mozilla.xul+xml', + ); +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php new file mode 100644 index 0000000..2320c9e --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssException.php @@ -0,0 +1,54 @@ +details = $details; + } else { + $message = $details; + parent::__construct($message); + } + } + + public function getHTTPStatus() + { + return isset($this->details['status']) ? $this->details['status'] : ''; + } + + public function getRequestId() + { + return isset($this->details['request-id']) ? $this->details['request-id'] : ''; + } + + public function getErrorCode() + { + return isset($this->details['code']) ? $this->details['code'] : ''; + } + + public function getErrorMessage() + { + return isset($this->details['message']) ? $this->details['message'] : ''; + } + + public function getDetails() + { + return isset($this->details['body']) ? $this->details['body'] : ''; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php new file mode 100644 index 0000000..e70609a --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Core/OssUtil.php @@ -0,0 +1,543 @@ + $value) { + if (is_string($key) && !is_array($value)) { + if (strlen($value) > 0) { + $temp[] = rawurlencode($key) . '=' . rawurlencode($value); + } else { + $temp[] = rawurlencode($key); + } + } + } + return implode('&', $temp); + } + + /** + * Html encoding '<', '>', '&', '\', '"' in subject parameter. + * + * @param string $subject + * @return string + */ + public static function sReplace($subject) + { + $search = array('<', '>', '&', '\'', '"'); + $replace = array('<', '>', '&', ''', '"'); + return str_replace($search, $replace, $subject); + } + + /** + * Check whether the string includes any chinese character + * + * @param $str + * @return int + */ + public static function chkChinese($str) + { + return preg_match('/[\x80-\xff]./', $str); + } + + /** + * Checks if the string is encoded by GB2312. + * + * @param string $str + * @return boolean false UTF-8 encoding TRUE GB2312 encoding + */ + public static function isGb2312($str) + { + for ($i = 0; $i < strlen($str); $i++) { + $v = ord($str[$i]); + if ($v > 127) { + if (($v >= 228) && ($v <= 233)) { + if (($i + 2) >= (strlen($str) - 1)) return true; // not enough characters + $v1 = ord($str[$i + 1]); + $v2 = ord($str[$i + 2]); + if (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191)) + return false; + else + return true; + } + } + } + return false; + } + + /** + * Checks if the string is encoded by GBK + * + * @param string $str + * @param boolean $gbk + * @return boolean + */ + public static function checkChar($str, $gbk = true) + { + for ($i = 0; $i < strlen($str); $i++) { + $v = ord($str[$i]); + if ($v > 127) { + if (($v >= 228) && ($v <= 233)) { + if (($i + 2) >= (strlen($str) - 1)) return $gbk ? true : FALSE; // not enough characters + $v1 = ord($str[$i + 1]); + $v2 = ord($str[$i + 2]); + if ($gbk) { + return (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191)) ? FALSE : TRUE;//GBK + } else { + return (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191)) ? TRUE : FALSE; + } + } + } + } + return $gbk ? TRUE : FALSE; + } + + /** + * Checks if the bucket name is valid + * bucket naming rules + * 1. Can only include lowercase letters, numbers, or dashes + * 2. Must start and end with lowercase letters or numbers + * 3. Must be within a length from 3 to 63 bytes. + * + * @param string $bucket Bucket name + * @return boolean + */ + public static function validateBucket($bucket) + { + $pattern = '/^[a-z0-9][a-z0-9-]{2,62}$/'; + if (!preg_match($pattern, $bucket)) { + return false; + } + return true; + } + + /** + * Checks if object name is valid + * object naming rules: + * 1. Must be within a length from 1 to 1023 bytes + * 2. Cannot start with '/' or '\\'. + * 3. Must be encoded in UTF-8. + * + * @param string $object Object名称 + * @return boolean + */ + public static function validateObject($object) + { + $pattern = '/^.{1,1023}$/'; + if (!preg_match($pattern, $object) || + self::startsWith($object, '/') || self::startsWith($object, '\\') + ) { + return false; + } + return true; + } + + + /** + * Checks if $str starts with $findMe + * + * @param string $str + * @param string $findMe + * @return bool + */ + public static function startsWith($str, $findMe) + { + if (strpos($str, $findMe) === 0) { + return true; + } else { + return false; + } + } + + + /** + * Generate the xml message of createBucketXmlBody. + * + * @param string $storageClass + * @return string + */ + public static function createBucketXmlBody($storageClass) + { + $xml = new \SimpleXMLElement(''); + $xml->addChild('StorageClass', $storageClass); + return $xml->asXML(); + } + + /** + * validate $options + * + * @param array $options + * @throws OssException + */ + public static function validateOptions($options) + { + //$options + if ($options != NULL && !is_array($options)) { + throw new OssException ($options . ':' . 'option must be array'); + } + } + + /** + * check whether the Content is valid. + * + * @param $content string + * @throws OssException + */ + public static function validateContent($content) + { + if (empty($content)) { + throw new OssException("http body content is invalid"); + } + } + + /** + * Check if BUCKET/OBJECT/OBJECT GROUP is empty. + * + * @param string $name + * @param string $errMsg + * @throws OssException + * @return void + */ + public static function throwOssExceptionWithMessageIfEmpty($name, $errMsg) + { + if (empty($name)) { + if (is_string($name) && $name == '0') + return; + throw new OssException($errMsg); + } + } + + /** + * This is a method for test only. DO NOT USE. + * + * @param $filename + * @param $size + */ + public static function generateFile($filename, $size) + { + if (file_exists($filename) && $size == sprintf('%u',filesize($filename))) { + echo $filename . " already exists, no need to create again. "; + return; + } + $part_size = 1 * 1024 * 1024; + $fp = fopen($filename, "w"); + $characters = << 0) { + if ($size < $part_size) { + $write_size = $size; + } else { + $write_size = $part_size; + } + $size -= $write_size; + $a = $characters[rand(0, $charactersLength - 1)]; + $content = str_repeat($a, $write_size); + $flag = fwrite($fp, $content); + if (!$flag) { + echo "write to " . $filename . " failed.
"; + break; + } + } + } else { + echo "open " . $filename . " failed.
"; + } + fclose($fp); + } + + /** + * Get MD5 of the file. + * + * @param $filename + * @param $from_pos + * @param $to_pos + * @return string + */ + public static function getMd5SumForFile($filename, $from_pos, $to_pos) + { + $content_md5 = ""; + if (($to_pos - $from_pos) > self::OSS_MAX_PART_SIZE) { + return $content_md5; + } + $filesize = sprintf('%u',filesize($filename)); + if ($from_pos >= $filesize || $to_pos >= $filesize || $from_pos < 0 || $to_pos < 0) { + return $content_md5; + } + + $total_length = $to_pos - $from_pos + 1; + $buffer = 8192; + $left_length = $total_length; + if (!file_exists($filename)) { + return $content_md5; + } + + if (false === $fh = fopen($filename, 'rb')) { + return $content_md5; + } + + fseek($fh, $from_pos); + $data = ''; + while (!feof($fh)) { + if ($left_length >= $buffer) { + $read_length = $buffer; + } else { + $read_length = $left_length; + } + if ($read_length <= 0) { + break; + } else { + $data .= fread($fh, $read_length); + $left_length = $left_length - $read_length; + } + } + fclose($fh); + $content_md5 = base64_encode(md5($data, true)); + return $content_md5; + } + + /** + * Check if the OS is Windows. The default encoding in Windows is GBK. + * + * @return bool + */ + public static function isWin() + { + return strtoupper(substr(PHP_OS, 0, 3)) == "WIN"; + } + + /** + * Encodes the file path from GBK to UTF-8. + * The default encoding in Windows is GBK. + * And if the file path is in Chinese, the file would not be found without the transcoding to UTF-8. + * + * @param $file_path + * @return string + */ + public static function encodePath($file_path) + { + if (self::chkChinese($file_path) && self::isWin()) { + $file_path = iconv('utf-8', 'gbk', $file_path); + } + return $file_path; + } + + /** + * Check if the endpoint is in the IPv4 format, such as xxx.xxx.xxx.xxx:port or xxx.xxx.xxx.xxx. + * + * @param string $endpoint The endpoint to check. + * @return boolean + */ + public static function isIPFormat($endpoint) + { + $ip_array = explode(":", $endpoint); + $hostname = $ip_array[0]; + $ret = filter_var($hostname, FILTER_VALIDATE_IP); + if (!$ret) { + return false; + } else { + return true; + } + } + + /** + * Get the host:port from endpoint. + * + * @param string $endpoint the endpoint. + * @return string + * @throws OssException + */ + public static function getHostPortFromEndpoint($endpoint) + { + $str = $endpoint; + $pos = strpos($str, "://"); + if ($pos !== false) { + $str = substr($str, $pos+3); + } + + $pos = strpos($str, '#'); + if ($pos !== false) { + $str = substr($str, 0, $pos); + } + + $pos = strpos($str, '?'); + if ($pos !== false) { + $str = substr($str, 0, $pos); + } + + $pos = strpos($str, '/'); + if ($pos !== false) { + $str = substr($str, 0, $pos); + } + + $pos = strpos($str, '@'); + if ($pos !== false) { + $str = substr($str, $pos+1); + } + + if (!preg_match('/^[\w.-]+(:[0-9]+)?$/', $str)) { + throw new OssException("endpoint is invalid:" . $endpoint); + } + + return $str; + } + + /** + * Generate the xml message of DeleteMultiObjects. + * + * @param string[] $objects + * @param bool $quiet + * @return string + */ + public static function createDeleteObjectsXmlBody($objects, $quiet) + { + $xml = new \SimpleXMLElement(''); + $xml->addChild('Quiet', $quiet); + foreach ($objects as $object) { + $sub_object = $xml->addChild('Object'); + $object = OssUtil::sReplace($object); + $sub_object->addChild('Key', $object); + } + return $xml->asXML(); + } + + /** + * Generate the xml message of DeleteMultiObjects. + * + * @param DeleteObjectInfo[] $objects + * @param bool $quiet + * @return string + */ + public static function createDeleteObjectVersionsXmlBody($objects, $quiet) + { + $xml = new \SimpleXMLElement(''); + $xml->addChild('Quiet', $quiet); + foreach ($objects as $object) { + $sub_object = $xml->addChild('Object'); + $key = OssUtil::sReplace($object->getKey()); + $sub_object->addChild('Key', $key); + $versionId = $object->getVersionId(); + if (!empty($versionId)) { + $sub_object->addChild('VersionId', $object->getVersionId()); + } + } + return $xml->asXML(); + } + + /** + * Generate the xml message of CompleteMultipartUpload. + * + * @param array[] $listParts + * @return string + */ + public static function createCompleteMultipartUploadXmlBody($listParts) + { + $xml = new \SimpleXMLElement(''); + foreach ($listParts as $node) { + $part = $xml->addChild('Part'); + $part->addChild('PartNumber', $node['PartNumber']); + $part->addChild('ETag', $node['ETag']); + } + return $xml->asXML(); + } + + /** + * Read the directory, return a associative array in which the MD5 is the named key and the is the value. + * + * @param string $dir + * @param string $exclude + * @param bool $recursive + * @return string[] + */ + public static function readDir($dir, $exclude = ".|..|.svn|.git", $recursive = false) + { + $file_list_array = array(); + $base_path = $dir; + $exclude_array = explode("|", $exclude); + $exclude_array = array_unique(array_merge($exclude_array, array('.', '..'))); + + if ($recursive) { + foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir)) as $new_file) { + if ($new_file->isDir()) continue; + $object = str_replace($base_path, '', $new_file); + if (!in_array(strtolower($object), $exclude_array)) { + $object = ltrim($object, '/'); + if (is_file($new_file)) { + $key = md5($new_file . $object, false); + $file_list_array[$key] = array('path' => $new_file, 'file' => $object,); + } + } + } + } else if ($handle = opendir($dir)) { + while (false !== ($file = readdir($handle))) { + if (!in_array(strtolower($file), $exclude_array)) { + $new_file = $dir . '/' . $file; + $object = $file; + $object = ltrim($object, '/'); + if (is_file($new_file)) { + $key = md5($new_file . $object, false); + $file_list_array[$key] = array('path' => $new_file, 'file' => $object,); + } + } + } + closedir($handle); + } + return $file_list_array; + } + + /** + * Decode key based on the encoding type + * + * @param string $key + * @param string $encoding + * @return string + */ + public static function decodeKey($key, $encoding) + { + if ($encoding == "") { + return $key; + } + + if ($encoding == "url") { + return rawurldecode($key); + } else { + throw new OssException("Unrecognized encoding type: " . $encoding); + } + } + + public static function unparseUrl($parsed_url) { + $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; + $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; + $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : ''; + $path = isset($parsed_url['path']) ? $parsed_url['path'] : ''; + $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : ''; + return "$scheme$host$port$path$query"; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/Credentials.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/Credentials.php new file mode 100644 index 0000000..2a8ffb5 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/Credentials.php @@ -0,0 +1,63 @@ +key = trim($key); + $this->secret = trim($secret); + $this->token = $token; + } + + + /** + * @return string + */ + public function getAccessKeyId() + { + return $this->key; + } + + /** + * @return string + */ + public function getAccessKeySecret() + { + return $this->secret; + } + + /** + * @return string|null + */ + public function getSecurityToken() + { + return $this->token; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/CredentialsProvider.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/CredentialsProvider.php new file mode 100644 index 0000000..b2fde83 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Credentials/CredentialsProvider.php @@ -0,0 +1,11 @@ +credentials = new Credentials($key, $secret, $token); + } + + /** + * @return Credentials + */ + public function getCredentials() + { + return $this->credentials; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/LICENSE b/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/LICENSE new file mode 100644 index 0000000..49b38bd --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/LICENSE @@ -0,0 +1,25 @@ +Copyright (c) 2006-2010 Ryan Parman, Foleeo Inc., and contributors. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are +permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of + conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, this list + of conditions and the following disclaimer in the documentation and/or other materials + provided with the distribution. + + * Neither the name of Ryan Parman, Foleeo Inc. nor the names of its contributors may be used to + endorse or promote products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS +AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore.php new file mode 100644 index 0000000..58bb215 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore.php @@ -0,0 +1,898 @@ +). + */ + public $request_class = 'OSS\Http\RequestCore'; + + /** + * The default class to use for HTTP Responses (defaults to ). + */ + public $response_class = 'OSS\Http\ResponseCore'; + + /** + * Default useragent string to use. + */ + public $useragent = 'RequestCore/1.4.3'; + + /** + * File to read from while streaming up. + */ + public $read_file = null; + + /** + * The resource to read from while streaming up. + */ + public $read_stream = null; + + /** + * The size of the stream to read from. + */ + public $read_stream_size = null; + + /** + * The length already read from the stream. + */ + public $read_stream_read = 0; + + /** + * File to write to while streaming down. + */ + public $write_file = null; + + /** + * The resource to write to while streaming down. + */ + public $write_stream = null; + + /** + * Stores the intended starting seek position. + */ + public $seek_position = null; + + /** + * The location of the cacert.pem file to use. + */ + public $cacert_location = false; + + /** + * The state of SSL certificate verification. + */ + public $ssl_verification = true; + + /** + * The user-defined callback function to call when a stream is read from. + */ + public $registered_streaming_read_callback = null; + + /** + * The user-defined callback function to call when a stream is written to. + */ + public $registered_streaming_write_callback = null; + + /** + * The request timeout time, which is 5,184,000 seconds,that is, 60 days by default + * + * @var int + */ + public $timeout = 5184000; + + /** + * The connection timeout time, which is 10 seconds by default + * + * @var int + */ + public $connect_timeout = 10; + + /*%******************************************************************************************%*/ + // CONSTANTS + + /** + * GET HTTP Method + */ + const HTTP_GET = 'GET'; + + /** + * POST HTTP Method + */ + const HTTP_POST = 'POST'; + + /** + * PUT HTTP Method + */ + const HTTP_PUT = 'PUT'; + + /** + * DELETE HTTP Method + */ + const HTTP_DELETE = 'DELETE'; + + /** + * HEAD HTTP Method + */ + const HTTP_HEAD = 'HEAD'; + + + /*%******************************************************************************************%*/ + // CONSTRUCTOR/DESTRUCTOR + + /** + * Construct a new instance of this class. + * + * @param string $url (Optional) The URL to request or service endpoint to query. + * @param string $proxy (Optional) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port` + * @param array $helpers (Optional) An associative array of classnames to use for request, and response functionality. Gets passed in automatically by the calling class. + * @return $this A reference to the current instance. + */ + public function __construct($url = null, $proxy = null, $helpers = null) + { + // Set some default values. + $this->request_url = $url; + $this->method = self::HTTP_GET; + $this->request_headers = array(); + $this->request_body = ''; + + // Set a new Request class if one was set. + if (isset($helpers['request']) && !empty($helpers['request'])) { + $this->request_class = $helpers['request']; + } + + // Set a new Request class if one was set. + if (isset($helpers['response']) && !empty($helpers['response'])) { + $this->response_class = $helpers['response']; + } + + if ($proxy) { + $this->set_proxy($proxy); + } + + return $this; + } + + /** + * Destruct the instance. Closes opened file handles. + * + * @return $this A reference to the current instance. + */ + public function __destruct() + { + if (isset($this->read_file) && isset($this->read_stream)) { + fclose($this->read_stream); + } + + if (isset($this->write_file) && isset($this->write_stream)) { + fclose($this->write_stream); + } + + return $this; + } + + + /*%******************************************************************************************%*/ + // REQUEST METHODS + + /** + * Set the credentials to use for authentication. + * + * @param string $user (Required) The username to authenticate with. + * @param string $pass (Required) The password to authenticate with. + * @return $this A reference to the current instance. + */ + public function set_credentials($user, $pass) + { + $this->username = $user; + $this->password = $pass; + return $this; + } + + /** + * Add a custom HTTP header to the cURL request. + * + * @param string $key (Required) The custom HTTP header to set. + * @param mixed $value (Required) The value to assign to the custom HTTP header. + * @return $this A reference to the current instance. + */ + public function add_header($key, $value) + { + $this->request_headers[$key] = $value; + return $this; + } + + /** + * Remove an HTTP header from the cURL request. + * + * @param string $key (Required) The custom HTTP header to set. + * @return $this A reference to the current instance. + */ + public function remove_header($key) + { + if (isset($this->request_headers[$key])) { + unset($this->request_headers[$key]); + } + return $this; + } + + /** + * Set the method type for the request. + * + * @param string $method (Required) One of the following constants: , , , , . + * @return $this A reference to the current instance. + */ + public function set_method($method) + { + $this->method = strtoupper($method); + return $this; + } + + /** + * Set a custom useragent string for the class. + * + * @param string $ua (Required) The useragent string to use. + * @return $this A reference to the current instance. + */ + public function set_useragent($ua) + { + $this->useragent = $ua; + return $this; + } + + /** + * Set the body to send in the request. + * + * @param string $body (Required) The textual content to send along in the body of the request. + * @return $this A reference to the current instance. + */ + public function set_body($body) + { + $this->request_body = $body; + return $this; + } + + /** + * Set the URL to make the request to. + * + * @param string $url (Required) The URL to make the request to. + * @return $this A reference to the current instance. + */ + public function set_request_url($url) + { + $this->request_url = $url; + return $this; + } + + /** + * Set additional CURLOPT settings. These will merge with the default settings, and override if + * there is a duplicate. + * + * @param array $curlopts (Optional) A set of key-value pairs that set `CURLOPT` options. These will merge with the existing CURLOPTs, and ones passed here will override the defaults. Keys should be the `CURLOPT_*` constants, not strings. + * @return $this A reference to the current instance. + */ + public function set_curlopts($curlopts) + { + $this->curlopts = $curlopts; + return $this; + } + + /** + * Set the length in bytes to read from the stream while streaming up. + * + * @param integer $size (Required) The length in bytes to read from the stream. + * @return $this A reference to the current instance. + */ + public function set_read_stream_size($size) + { + $this->read_stream_size = $size; + + return $this; + } + + /** + * Set the resource to read from while streaming up. Reads the stream from its current position until + * EOF or `$size` bytes have been read. If `$size` is not given it will be determined by and + * . + * + * @param resource $resource (Required) The readable resource to read from. + * @param integer $size (Optional) The size of the stream to read. + * @return $this A reference to the current instance. + */ + public function set_read_stream($resource, $size = null) + { + if (!isset($size) || $size < 0) { + $stats = fstat($resource); + + if ($stats && $stats['size'] >= 0) { + $position = ftell($resource); + + if ($position !== false && $position >= 0) { + $size = $stats['size'] - $position; + } + } + } + + $this->read_stream = $resource; + + return $this->set_read_stream_size($size); + } + + /** + * Set the file to read from while streaming up. + * + * @param string $location (Required) The readable location to read from. + * @return $this A reference to the current instance. + */ + public function set_read_file($location) + { + $this->read_file = $location; + $read_file_handle = fopen($location, 'r'); + + return $this->set_read_stream($read_file_handle); + } + + /** + * Set the resource to write to while streaming down. + * + * @param resource $resource (Required) The writeable resource to write to. + * @return $this A reference to the current instance. + */ + public function set_write_stream($resource) + { + $this->write_stream = $resource; + + return $this; + } + + /** + * Set the file to write to while streaming down. + * + * @param string $location (Required) The writeable location to write to. + * @return $this A reference to the current instance. + */ + public function set_write_file($location) + { + $this->write_file = $location; + } + + /** + * Set the proxy to use for making requests. + * + * @param string $proxy (Required) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port` + * @return $this A reference to the current instance. + */ + public function set_proxy($proxy) + { + $proxy = parse_url($proxy); + $proxy['user'] = isset($proxy['user']) ? $proxy['user'] : null; + $proxy['pass'] = isset($proxy['pass']) ? $proxy['pass'] : null; + $proxy['port'] = isset($proxy['port']) ? $proxy['port'] : null; + $this->proxy = $proxy; + return $this; + } + + /** + * Set the intended starting seek position. + * + * @param integer $position (Required) The byte-position of the stream to begin reading from. + * @return $this A reference to the current instance. + */ + public function set_seek_position($position) + { + $this->seek_position = isset($position) ? (integer)$position : null; + + return $this; + } + + /** + * A callback function that is invoked by cURL for streaming up. + * + * @param resource $curl_handle (Required) The cURL handle for the request. + * @param resource $header_content (Required) The header callback result. + * @return headers from a stream. + */ + public function streaming_header_callback($curl_handle, $header_content) + { + $code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE); + + if (isset($this->write_file) && intval($code) / 100 == 2 && !isset($this->write_file_handle)) + { + $this->write_file_handle = fopen($this->write_file, 'w'); + $this->set_write_stream($this->write_file_handle); + } + + $this->response_raw_headers .= $header_content; + return strlen($header_content); + } + + + /** + * Register a callback function to execute whenever a data stream is read from using + * . + * + * The user-defined callback function should accept three arguments: + * + *
    + *
  • $curl_handle - resource - Required - The cURL handle resource that represents the in-progress transfer.
  • + *
  • $file_handle - resource - Required - The file handle resource that represents the file on the local file system.
  • + *
  • $length - integer - Required - The length in kilobytes of the data chunk that was transferred.
  • + *
+ * + * @param string|array|function $callback (Required) The callback function is called by , so you can pass the following values:
    + *
  • The name of a global function to execute, passed as a string.
  • + *
  • A method to execute, passed as array('ClassName', 'MethodName').
  • + *
  • An anonymous function (PHP 5.3+).
+ * @return $this A reference to the current instance. + */ + public function register_streaming_read_callback($callback) + { + $this->registered_streaming_read_callback = $callback; + + return $this; + } + + /** + * Register a callback function to execute whenever a data stream is written to using + * . + * + * The user-defined callback function should accept two arguments: + * + *
    + *
  • $curl_handle - resource - Required - The cURL handle resource that represents the in-progress transfer.
  • + *
  • $length - integer - Required - The length in kilobytes of the data chunk that was transferred.
  • + *
+ * + * @param string|array|function $callback (Required) The callback function is called by , so you can pass the following values:
    + *
  • The name of a global function to execute, passed as a string.
  • + *
  • A method to execute, passed as array('ClassName', 'MethodName').
  • + *
  • An anonymous function (PHP 5.3+).
+ * @return $this A reference to the current instance. + */ + public function register_streaming_write_callback($callback) + { + $this->registered_streaming_write_callback = $callback; + + return $this; + } + + + /*%******************************************************************************************%*/ + // PREPARE, SEND, AND PROCESS REQUEST + + /** + * A callback function that is invoked by cURL for streaming up. + * + * @param resource $curl_handle (Required) The cURL handle for the request. + * @param resource $file_handle (Required) The open file handle resource. + * @param integer $length (Required) The maximum number of bytes to read. + * @return binary Binary data from a stream. + */ + public function streaming_read_callback($curl_handle, $file_handle, $length) + { + // Once we've sent as much as we're supposed to send... + if ($this->read_stream_read >= $this->read_stream_size) { + // Send EOF + return ''; + } + + // If we're at the beginning of an upload and need to seek... + if ($this->read_stream_read == 0 && isset($this->seek_position) && $this->seek_position !== ftell($this->read_stream)) { + if (fseek($this->read_stream, $this->seek_position) !== 0) { + throw new RequestCore_Exception('The stream does not support seeking and is either not at the requested position or the position is unknown.'); + } + } + + $read = fread($this->read_stream, min($this->read_stream_size - $this->read_stream_read, $length)); // Remaining upload data or cURL's requested chunk size + $this->read_stream_read += strlen($read); + + $out = $read === false ? '' : $read; + + // Execute callback function + if ($this->registered_streaming_read_callback) { + call_user_func($this->registered_streaming_read_callback, $curl_handle, $file_handle, $out); + } + + return $out; + } + + /** + * A callback function that is invoked by cURL for streaming down. + * + * @param resource $curl_handle (Required) The cURL handle for the request. + * @param binary $data (Required) The data to write. + * @return integer The number of bytes written. + */ + public function streaming_write_callback($curl_handle, $data) + { + $code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE); + + if (intval($code) / 100 != 2) + { + $this->response_error_body .= $data; + return strlen($data); + } + + $length = strlen($data); + $written_total = 0; + $written_last = 0; + + while ($written_total < $length) { + $written_last = fwrite($this->write_stream, substr($data, $written_total)); + + if ($written_last === false) { + return $written_total; + } + + $written_total += $written_last; + } + + // Execute callback function + if ($this->registered_streaming_write_callback) { + call_user_func($this->registered_streaming_write_callback, $curl_handle, $written_total); + } + + return $written_total; + } + + /** + * Prepare and adds the details of the cURL request. This can be passed along to a + * function. + * + * @return resource The handle for the cURL object. + * + */ + public function prep_request() + { + $curl_handle = curl_init(); + + // Set default options. + curl_setopt($curl_handle, CURLOPT_URL, $this->request_url); + curl_setopt($curl_handle, CURLOPT_FILETIME, true); + curl_setopt($curl_handle, CURLOPT_FRESH_CONNECT, false); +// curl_setopt($curl_handle, CURLOPT_CLOSEPOLICY, CURLCLOSEPOLICY_LEAST_RECENTLY_USED); + curl_setopt($curl_handle, CURLOPT_MAXREDIRS, 5); + curl_setopt($curl_handle, CURLOPT_HEADER, true); + curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true); + curl_setopt($curl_handle, CURLOPT_TIMEOUT, $this->timeout); + curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, $this->connect_timeout); + curl_setopt($curl_handle, CURLOPT_NOSIGNAL, true); + curl_setopt($curl_handle, CURLOPT_REFERER, $this->request_url); + curl_setopt($curl_handle, CURLOPT_USERAGENT, $this->useragent); + curl_setopt($curl_handle, CURLOPT_HEADERFUNCTION, array($this, 'streaming_header_callback')); + curl_setopt($curl_handle, CURLOPT_READFUNCTION, array($this, 'streaming_read_callback')); + + // Verification of the SSL cert + if ($this->ssl_verification) { + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, true); + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, 2); + } else { + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, false); + } + + // chmod the file as 0755 + if ($this->cacert_location === true) { + curl_setopt($curl_handle, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem'); + } elseif (is_string($this->cacert_location)) { + curl_setopt($curl_handle, CURLOPT_CAINFO, $this->cacert_location); + } + + // Debug mode + if ($this->debug_mode) { + curl_setopt($curl_handle, CURLOPT_VERBOSE, true); + } + + // Handle open_basedir & safe mode + if (!ini_get('safe_mode') && !ini_get('open_basedir')) { + curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true); + } + + // Enable a proxy connection if requested. + if ($this->proxy) { + $host = $this->proxy['host']; + $host .= ($this->proxy['port']) ? ':' . $this->proxy['port'] : ''; + curl_setopt($curl_handle, CURLOPT_PROXY, $host); + + if (isset($this->proxy['user']) && isset($this->proxy['pass'])) { + curl_setopt($curl_handle, CURLOPT_PROXYUSERPWD, $this->proxy['user'] . ':' . $this->proxy['pass']); + } + } + + // Set credentials for HTTP Basic/Digest Authentication. + if ($this->username && $this->password) { + curl_setopt($curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY); + curl_setopt($curl_handle, CURLOPT_USERPWD, $this->username . ':' . $this->password); + } + + // Handle the encoding if we can. + if (extension_loaded('zlib')) { + curl_setopt($curl_handle, CURLOPT_ENCODING, ''); + } + + // Process custom headers + if (isset($this->request_headers) && count($this->request_headers)) { + $temp_headers = array(); + + foreach ($this->request_headers as $k => $v) { + $temp_headers[] = $k . ': ' . $v; + } + + // fix "Expect: 100-continue" + $temp_headers[] = 'Expect:'; + curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $temp_headers); + } + + switch ($this->method) { + case self::HTTP_PUT: + //unset($this->read_stream); + curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, 'PUT'); + if (isset($this->read_stream)) { + if (!isset($this->read_stream_size) || $this->read_stream_size < 0) { + throw new RequestCore_Exception('The stream size for the streaming upload cannot be determined.'); + } + curl_setopt($curl_handle, CURLOPT_INFILESIZE, $this->read_stream_size); + curl_setopt($curl_handle, CURLOPT_UPLOAD, true); + } else { + curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body); + } + break; + + case self::HTTP_POST: + curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, 'POST'); + if (isset($this->read_stream)) { + if (!isset($this->read_stream_size) || $this->read_stream_size < 0) { + throw new RequestCore_Exception('The stream size for the streaming upload cannot be determined.'); + } + curl_setopt($curl_handle, CURLOPT_INFILESIZE, $this->read_stream_size); + curl_setopt($curl_handle, CURLOPT_UPLOAD, true); + } else { + curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body); + } + break; + + case self::HTTP_HEAD: + curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, self::HTTP_HEAD); + curl_setopt($curl_handle, CURLOPT_NOBODY, 1); + break; + + default: // Assumed GET + curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, $this->method); + if (isset($this->write_stream) || isset($this->write_file)) { + curl_setopt($curl_handle, CURLOPT_WRITEFUNCTION, array($this, 'streaming_write_callback')); + curl_setopt($curl_handle, CURLOPT_HEADER, false); + } else { + curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body); + } + break; + } + + // Merge in the CURLOPTs + if (isset($this->curlopts) && sizeof($this->curlopts) > 0) { + foreach ($this->curlopts as $k => $v) { + curl_setopt($curl_handle, $k, $v); + } + } + + return $curl_handle; + } + + /** + * Take the post-processed cURL data and break it down into useful header/body/info chunks. Uses the + * data stored in the `curl_handle` and `response` properties unless replacement data is passed in via + * parameters. + * + * @param resource|\CurlHandle|null|false $curl_handle (Optional) The reference to the already executed cURL request. Receive CurlHandle instance from PHP8.0 + * @param string $response (Optional) The actual response content itself that needs to be parsed. + * @return ResponseCore A object containing a parsed HTTP response. + */ + public function process_response($curl_handle = null, $response = null) + { + // Accept a custom one if it's passed. + if ($curl_handle && $response) { + $this->response = $response; + } + + // As long as this came back as a valid resource or CurlHandle instance... + if (is_resource($curl_handle) || (is_object($curl_handle) && in_array(get_class($curl_handle),array('CurlHandle','Swoole\Curl\Handler', 'Swoole\Coroutine\Curl\Handle'),true))) { + // Determine what's what. + $header_size = curl_getinfo($curl_handle, CURLINFO_HEADER_SIZE); + $this->response_headers = substr($this->response, 0, $header_size); + $this->response_body = substr($this->response, $header_size); + $this->response_code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE); + $this->response_info = curl_getinfo($curl_handle); + + if (intval($this->response_code) / 100 != 2 && isset($this->write_file)) + { + $this->response_headers = $this->response_raw_headers; + $this->response_body = $this->response_error_body; + } + + // Parse out the headers + $this->response_headers = explode("\r\n\r\n", trim($this->response_headers)); + $this->response_headers = array_pop($this->response_headers); + $this->response_headers = explode("\r\n", $this->response_headers); + array_shift($this->response_headers); + + // Loop through and split up the headers. + $header_assoc = array(); + foreach ($this->response_headers as $header) { + $kv = explode(': ', $header); + $header_assoc[strtolower($kv[0])] = isset($kv[1]) ? $kv[1] : ''; + } + + // Reset the headers to the appropriate property. + $this->response_headers = $header_assoc; + $this->response_headers['info'] = $this->response_info; + $this->response_headers['info']['method'] = $this->method; + + if ($curl_handle && $response) { + return new ResponseCore($this->response_headers, $this->response_body, $this->response_code); + } + } + + // Return false + return false; + } + + /** + * Send the request, calling necessary utility functions to update built-in properties. + * + * @param boolean $parse (Optional) Whether to parse the response with ResponseCore or not. + * @return string The resulting unparsed data from the request. + */ + public function send_request($parse = false) + { + set_time_limit(0); + + $curl_handle = $this->prep_request(); + $this->response = curl_exec($curl_handle); + + if ($this->response === false) { + throw new RequestCore_Exception('cURL error: ' . curl_error($curl_handle) . ' (' . curl_errno($curl_handle) . ')'); + } + + $parsed_response = $this->process_response($curl_handle, $this->response); + + curl_close($curl_handle); + unset($curl_handle); + + if ($parse) { + return $parsed_response; + } + + return $this->response; + } + + /*%******************************************************************************************%*/ + // RESPONSE METHODS + + /** + * Get the HTTP response headers from the request. + * + * @param string $header (Optional) A specific header value to return. Defaults to all headers. + * @return string|array All or selected header values. + */ + public function get_response_header($header = null) + { + if ($header) { + return $this->response_headers[strtolower($header)]; + } + return $this->response_headers; + } + + /** + * Get the HTTP response body from the request. + * + * @return string The response body. + */ + public function get_response_body() + { + return $this->response_body; + } + + /** + * Get the HTTP response code from the request. + * + * @return string The HTTP response code. + */ + public function get_response_code() + { + return $this->response_code; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore_Exception.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore_Exception.php new file mode 100644 index 0000000..cb4e83c --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Http/RequestCore_Exception.php @@ -0,0 +1,8 @@ +). + * @param string $body (Required) XML-formatted response from OSS. + * @param integer $status (Optional) HTTP response status code from the request. + * @return Mixed Contains an `header` property (HTTP headers as an associative array), a or `body` property, and an `status` code. + */ + public function __construct($header, $body, $status = null) + { + $this->header = $header; + $this->body = $body; + $this->status = $status; + + return $this; + } + + /** + * Did we receive the status code we expected? + * + * @param integer|array $codes (Optional) The status code(s) to expect. Pass an for a single acceptable value, or an of integers for multiple acceptable values. + * @return boolean Whether we received the expected status code or not. + */ + public function isOK($codes = array(200, 201, 204, 206)) + { + if (is_array($codes)) { + return in_array($this->status, $codes); + } + + return $this->status === $codes; + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php new file mode 100644 index 0000000..e211eed --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketInfo.php @@ -0,0 +1,181 @@ +location = $location; + $this->createDate = $createDate; + $this->name = $name; + } + + /** + * Get bucket location + * + * @return string + */ + public function getLocation() + { + return $this->location; + } + + /** + * Get bucket name + * + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * Get bucket creation time. + * + * @return string + */ + public function getCreateDate() + { + return $this->createDate; + } + + /** + * Get bucket storage class. + * + * @return string + */ + public function getStorageClass() + { + return $this->storageClass; + } + + /** + * Get bucket extranet endpoint. + * + * @return string + */ + public function getExtranetEndpoint() + { + return $this->extranetEndpoint; + } + + /** + * Get bucket intranet endpoint. + * + * @return string + */ + public function getIntranetEndpoint() + { + return $this->intranetEndpoint; + } + + /** + * Get bucket intranet endpoint. + * + * @return string + */ + public function getRegion() + { + return $this->region; + } + + + /** + * Parse bucket information from node. + * + * @param xml $xml + * @throws OssException + * @return null + */ + public function parseFromXmlNode($xml) + { + if (isset($xml->Location)) { + $this->location = strval($xml->Location); + } + if (isset($xml->Name)) { + $this->name = strval($xml->Name); + } + if (isset($xml->CreationDate)) { + $this->createDate = strval($xml->CreationDate); + } + if (isset($xml->StorageClass)) { + $this->storageClass = strval($xml->StorageClass); + } + if (isset($xml->ExtranetEndpoint)) { + $this->extranetEndpoint = strval($xml->ExtranetEndpoint); + } + if (isset($xml->IntranetEndpoint)) { + $this->intranetEndpoint = strval($xml->IntranetEndpoint); + } + if (isset($xml->IntranetEndpoint)) { + $this->intranetEndpoint = strval($xml->IntranetEndpoint); + } + if (isset($xml->Region)) { + $this->region = strval($xml->Region); + } + } + + /** + * bucket region + * + * @var string + */ + private $location; + /** + * bucket name + * + * @var string + */ + private $name; + + /** + * bucket creation time + * + * @var string + */ + private $createDate; + + /** + * bucket storage class + * + * @var string + */ + private $storageClass; + + /** + * bucket extranet endpoint + * + * @var string + */ + private $extranetEndpoint; + + /** + * bucket intranet endpoint + * + * @var string + */ + private $intranetEndpoint; + + /** + * bucket region + * + * @var string + */ + private $region; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php new file mode 100644 index 0000000..ce03a0d --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketListInfo.php @@ -0,0 +1,39 @@ +bucketList = $bucketList; + } + + /** + * Get the BucketInfo list + * + * @return BucketInfo[] + */ + public function getBucketList() + { + return $this->bucketList; + } + + /** + * BucketInfo list + * + * @var array + */ + private $bucketList = array(); +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketStat.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketStat.php new file mode 100644 index 0000000..60c7e55 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/BucketStat.php @@ -0,0 +1,331 @@ +storage; + } + + /** + * Get object count + * + * @return int + */ + public function getObjectCount() + { + return $this->objectCount; + } + + /** + * Get multipart upload count. + * + * @return int + */ + public function getMultipartUploadCount() + { + return $this->multipartUploadCount; + } + + /** + * Get live channel count + * + * @return int + */ + public function getLiveChannelCount() + { + return $this->liveChannelCount; + } + + /** + * Get last modified time + * + * @return int + */ + public function getLastModifiedTime() + { + return $this->lastModifiedTime; + } + + /** + * Get standard storage + * + * @return int + */ + public function getStandardStorage() + { + return $this->standardStorage; + } + + /** + * Get standard object count + * + * @return int + */ + public function getStandardObjectCount() + { + return $this->standardObjectCount; + } + + /** + * Get infrequent access storage + * + * @return int + */ + public function getInfrequentAccessStorage() + { + return $this->infrequentAccessStorage; + } + + /** + * Get infrequent access real storage + * + * @return int + */ + public function getInfrequentAccessRealStorage() + { + return $this->infrequentAccessRealStorage; + } + + /** + * Get infrequent access object count + * + * @return int + */ + public function getInfrequentAccessObjectCount() + { + return $this->infrequentAccessObjectCount; + } + + /** + * Get archive storage + * + * @return int + */ + public function getArchiveStorage() + { + return $this->archiveStorage; + } + + /** + * Get archive real storage + * + * @return int + */ + public function getArchiveRealStorage() + { + return $this->archiveRealStorage; + } + /** + * Get archive object count + * + * @return int + */ + public function getArchiveObjectCount() + { + return $this->archiveObjectCount; + } + + /** + * Get cold archive storage + * + * @return int + */ + public function getColdArchiveStorage() + { + return $this->coldArchiveStorage; + } + + /** + * Get cold archive real storage + * + * @return int + */ + public function getColdArchiveRealStorage() + { + return $this->coldArchiveRealStorage; + } + + /** + * Get cold archive object count + * + * @return int + */ + public function getColdArchiveObjectCount() + { + return $this->coldArchiveObjectCount; + } + + /** + * Parse stat from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (isset($xml->Storage) ) { + $this->storage = intval($xml->Storage); + } + if (isset($xml->ObjectCount) ) { + $this->objectCount = intval($xml->ObjectCount); + } + if (isset($xml->MultipartUploadCount) ) { + $this->multipartUploadCount = intval($xml->MultipartUploadCount); + } + if (isset($xml->LiveChannelCount) ) { + $this->liveChannelCount = intval($xml->LiveChannelCount); + } + if (isset($xml->LastModifiedTime) ) { + $this->lastModifiedTime = intval($xml->LastModifiedTime); + } + if (isset($xml->StandardStorage) ) { + $this->standardStorage = intval($xml->StandardStorage); + } + if (isset($xml->StandardObjectCount) ) { + $this->standardObjectCount = intval($xml->StandardObjectCount); + } + if (isset($xml->InfrequentAccessStorage) ) { + $this->infrequentAccessStorage = intval($xml->InfrequentAccessStorage); + } + if (isset($xml->InfrequentAccessRealStorage) ) { + $this->infrequentAccessRealStorage = intval($xml->InfrequentAccessRealStorage); + } + if (isset($xml->InfrequentAccessObjectCount) ) { + $this->infrequentAccessObjectCount = intval($xml->InfrequentAccessObjectCount); + } + if (isset($xml->ArchiveStorage) ) { + $this->archiveStorage = intval($xml->ArchiveStorage); + } + if (isset($xml->ArchiveRealStorage) ) { + $this->archiveRealStorage = intval($xml->ArchiveRealStorage); + } + if (isset($xml->ArchiveObjectCount) ) { + $this->archiveObjectCount = intval($xml->ArchiveObjectCount); + } + if (isset($xml->ColdArchiveStorage) ) { + $this->coldArchiveStorage = intval($xml->ColdArchiveStorage); + } + if (isset($xml->ColdArchiveRealStorage) ) { + $this->coldArchiveRealStorage = intval($xml->ColdArchiveRealStorage); + } + if (isset($xml->ColdArchiveObjectCount) ) { + $this->coldArchiveObjectCount = intval($xml->ColdArchiveObjectCount); + } + } + + /** + * current storage + * + * @var int + */ + private $storage; + /** + * object count + * + * @var int + */ + private $objectCount; + + /** + * multipart upload count + * + * @var int + */ + private $multipartUploadCount; + + /** + * live channel count + * @var int + */ + private $liveChannelCount; + + /** + * last modified time + * @var int + */ + private $lastModifiedTime; + + /** + * standard storage + * @var int + */ + private $standardStorage; + + /** + * standard object count + * @var int + */ + private $standardObjectCount; + + /** + * infrequent access storage + * @var int + */ + private $infrequentAccessStorage; + + /** + * infrequent access real storage + * @var int + */ + private $infrequentAccessRealStorage; + + /** + * infrequent access object Count + * @var int + */ + private $infrequentAccessObjectCount; + + /** + * archive storage + * @var int + */ + private $archiveStorage; + + /** + * archive real storage + * @var int + */ + private $archiveRealStorage; + + /** + * archive object count + * @var int + */ + private $archiveObjectCount; + + /** + * cold archive storage + * @var int + */ + private $coldArchiveStorage; + + /** + * cold archive real storage + * @var int + */ + private $coldArchiveRealStorage; + + /** + * cold archive object count + * @var int + */ + private $coldArchiveObjectCount; + +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CnameConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CnameConfig.php new file mode 100644 index 0000000..f3597d2 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CnameConfig.php @@ -0,0 +1,99 @@ +cnameList = array(); + } + + /** + * @return array + * @example + * array(2) { + * [0]=> + * array(3) { + * ["Domain"]=> + * string(11) "www.foo.com" + * ["Status"]=> + * string(7) "enabled" + * ["LastModified"]=> + * string(8) "20150101" + * } + * [1]=> + * array(3) { + * ["Domain"]=> + * string(7) "bar.com" + * ["Status"]=> + * string(8) "disabled" + * ["LastModified"]=> + * string(8) "20160101" + * } + * } + */ + public function getCnames() + { + return $this->cnameList; + } + + + public function addCname($cname) + { + if (count($this->cnameList) >= self::OSS_MAX_RULES) { + throw new OssException( + "num of cname in the config exceeds self::OSS_MAX_RULES: " . strval(self::OSS_MAX_RULES)); + } + $this->cnameList[] = array('Domain' => $cname); + } + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (!isset($xml->Cname)) return; + foreach ($xml->Cname as $entry) { + $cname = array(); + foreach ($entry as $key => $value) { + $cname[strval($key)] = strval($value); + } + $this->cnameList[] = $cname; + } + } + + public function serializeToXml() + { + $strXml = << + + +EOF; + $xml = new \SimpleXMLElement($strXml); + foreach ($this->cnameList as $cname) { + $node = $xml->addChild('Cname'); + foreach ($cname as $key => $value) { + $node->addChild($key, $value); + } + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + const OSS_MAX_RULES = 10; + + private $cnameList = array(); +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CnameTokenInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CnameTokenInfo.php new file mode 100644 index 0000000..295cfbd --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CnameTokenInfo.php @@ -0,0 +1,105 @@ +bucket; + } + + /** + * Get cname + * + * @return string + */ + public function getCname() + { + return $this->cname; + } + + /** + * Get token. + * + * @return string + */ + public function getToken() + { + return $this->token; + } + + /** + * Get expireTime. + * + * @return string + */ + public function getExpireTime() + { + return $this->expireTime; + } + + /** + * Parse cname token from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (isset($xml->Bucket) ) { + $this->bucket = strval($xml->Bucket); + } + if (isset($xml->Cname) ) { + $this->cname = strval($xml->Cname); + } + if (isset($xml->Token) ) { + $this->token = strval($xml->Token); + } + if (isset($xml->ExpireTime) ) { + $this->expireTime = strval($xml->ExpireTime); + } + } + + /** + * bucket name + * + * @var string + */ + private $bucket; + /** + * cname + * + * @var string + */ + private $cname; + + /** + * token + * + * @var string + */ + private $token; + + /** + * expire time + * + * @var string + */ + private $expireTime; + +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php new file mode 100644 index 0000000..e0f1892 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsConfig.php @@ -0,0 +1,140 @@ +rules = array(); + } + + /** + * Get CorsRule list + * + * @return CorsRule[] + */ + public function getRules() + { + return $this->rules; + } + + + /** + * Add a new CorsRule + * + * @param CorsRule $rule + * @throws OssException + */ + public function addRule($rule) + { + if (count($this->rules) >= self::OSS_MAX_RULES) { + throw new OssException("num of rules in the config exceeds self::OSS_MAX_RULES: " . strval(self::OSS_MAX_RULES)); + } + $this->rules[] = $rule; + } + /** + * @param boolean $value + */ + public function setResponseVary($value) + { + $this->responseVary = $value; + } + + /** + * @return boolean + */ + public function getResponseVary(){ + if (isset($this->responseVary)) { + return $this->responseVary; + } + return false; + } + + /** + * Parse CorsConfig from the xml. + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if(isset($xml->ResponseVary)){ + $this->responseVary = + (strval($xml->ResponseVary) === 'TRUE' || strval($xml->ResponseVary) === 'true') ? true : false; + } + if (!isset($xml->CORSRule)) return; + foreach ($xml->CORSRule as $rule) { + $corsRule = new CorsRule(); + foreach ($rule as $key => $value) { + if ($key === self::OSS_CORS_ALLOWED_HEADER) { + $corsRule->addAllowedHeader(strval($value)); + } elseif ($key === self::OSS_CORS_ALLOWED_METHOD) { + $corsRule->addAllowedMethod(strval($value)); + } elseif ($key === self::OSS_CORS_ALLOWED_ORIGIN) { + $corsRule->addAllowedOrigin(strval($value)); + } elseif ($key === self::OSS_CORS_EXPOSE_HEADER) { + $corsRule->addExposeHeader(strval($value)); + } elseif ($key === self::OSS_CORS_MAX_AGE_SECONDS) { + $corsRule->setMaxAgeSeconds(strval($value)); + } + } + $this->addRule($corsRule); + } + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + foreach ($this->rules as $rule) { + $xmlRule = $xml->addChild('CORSRule'); + $rule->appendToXml($xmlRule); + } + if(isset($this->responseVary)){ + if ($this->responseVary) { + $xml->addChild('ResponseVary', 'true'); + } else { + $xml->addChild('ResponseVary', 'false'); + } + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + const OSS_CORS_ALLOWED_ORIGIN = 'AllowedOrigin'; + const OSS_CORS_ALLOWED_METHOD = 'AllowedMethod'; + const OSS_CORS_ALLOWED_HEADER = 'AllowedHeader'; + const OSS_CORS_EXPOSE_HEADER = 'ExposeHeader'; + const OSS_CORS_MAX_AGE_SECONDS = 'MaxAgeSeconds'; + const OSS_MAX_RULES = 10; + + /** + * CorsRule list + * + * @var CorsRule[] + */ + private $rules = array(); + private $responseVary; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php new file mode 100644 index 0000000..08353a0 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/CorsRule.php @@ -0,0 +1,150 @@ +allowedOrigins[] = $allowedOrigin; + } + } + + /** + * Add an allowedMethod rule + * + * @param string $allowedMethod + */ + public function addAllowedMethod($allowedMethod) + { + if (!empty($allowedMethod)) { + $this->allowedMethods[] = $allowedMethod; + } + } + + /** + * Add an allowedHeader rule + * + * @param string $allowedHeader + */ + public function addAllowedHeader($allowedHeader) + { + if (!empty($allowedHeader)) { + $this->allowedHeaders[] = $allowedHeader; + } + } + + /** + * Add an exposeHeader rule + * + * @param string $exposeHeader + */ + public function addExposeHeader($exposeHeader) + { + if (!empty($exposeHeader)) { + $this->exposeHeaders[] = $exposeHeader; + } + } + + /** + * @return int + */ + public function getMaxAgeSeconds() + { + return $this->maxAgeSeconds; + } + + /** + * @param int $maxAgeSeconds + */ + public function setMaxAgeSeconds($maxAgeSeconds) + { + $this->maxAgeSeconds = $maxAgeSeconds; + } + + /** + * Get the AllowedHeaders list + * + * @return string[] + */ + public function getAllowedHeaders() + { + return $this->allowedHeaders; + } + + /** + * Get the AllowedOrigins list + * + * @return string[] + */ + public function getAllowedOrigins() + { + return $this->allowedOrigins; + } + + /** + * Get the AllowedMethods list + * + * @return string[] + */ + public function getAllowedMethods() + { + return $this->allowedMethods; + } + + /** + * Get the ExposeHeaders list + * + * @return string[] + */ + public function getExposeHeaders() + { + return $this->exposeHeaders; + } + + /** + * Serialize all the rules into the xml represented by parameter $xmlRule + * + * @param \SimpleXMLElement $xmlRule + * @throws OssException + */ + public function appendToXml(&$xmlRule) + { + if (!isset($this->maxAgeSeconds)) { + throw new OssException("maxAgeSeconds is not set in the Rule"); + } + foreach ($this->allowedOrigins as $allowedOrigin) { + $xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_ORIGIN, $allowedOrigin); + } + foreach ($this->allowedMethods as $allowedMethod) { + $xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_METHOD, $allowedMethod); + } + foreach ($this->allowedHeaders as $allowedHeader) { + $xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_HEADER, $allowedHeader); + } + foreach ($this->exposeHeaders as $exposeHeader) { + $xmlRule->addChild(CorsConfig::OSS_CORS_EXPOSE_HEADER, $exposeHeader); + } + $xmlRule->addChild(CorsConfig::OSS_CORS_MAX_AGE_SECONDS, strval($this->maxAgeSeconds)); + } + + private $allowedHeaders = array(); + private $allowedOrigins = array(); + private $allowedMethods = array(); + private $exposeHeaders = array(); + private $maxAgeSeconds = null; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteMarkerInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteMarkerInfo.php new file mode 100644 index 0000000..c129e99 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteMarkerInfo.php @@ -0,0 +1,65 @@ +key = $key; + $this->versionId = $versionId; + $this->lastModified = $lastModified; + $this->isLatest = $isLatest; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getVersionId() + { + return $this->versionId; + } + + /** + * @return string + */ + public function getLastModified() + { + return $this->lastModified; + } + + /** + * @return string + */ + public function getIsLatest() + { + return $this->isLatest; + } + + private $key = ""; + private $versionId = ""; + private $lastModified = ""; + private $isLatest = ""; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteObjectInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteObjectInfo.php new file mode 100644 index 0000000..806eafb --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeleteObjectInfo.php @@ -0,0 +1,41 @@ +key = $key; + $this->versionId = $versionId; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getVersionId() + { + return $this->versionId; + } + + private $key = ""; + private $versionId = ""; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeletedObjectInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeletedObjectInfo.php new file mode 100644 index 0000000..6bba39a --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/DeletedObjectInfo.php @@ -0,0 +1,63 @@ +key = $key; + $this->versionId = $versionId; + $this->deleteMarker = $deleteMarker; + $this->deleteMarkerVersionId = $deleteMarkerVersionId; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getVersionId() + { + return $this->versionId; + } + + /** + * @return string + */ + public function getDeleteMarker() + { + return $this->deleteMarker; + } + + /** + * @return string + */ + public function getDeleteMarkerVersionId() + { + return $this->deleteMarkerVersionId; + } + + private $key = ""; + private $versionId = ""; + private $deleteMarker = ""; + private $deleteMarkerVersionId = ""; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ExtendWormConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ExtendWormConfig.php new file mode 100644 index 0000000..5e62287 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ExtendWormConfig.php @@ -0,0 +1,64 @@ +day = $day; + } + + /** + * Parse ExtendWormConfig from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + throw new OssException("Not implemented."); + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + if (isset($this->day)) { + $xml->addChild('RetentionPeriodInDays', $this->day); + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return int + */ + public function getDay() + { + return $this->day; + } + + private $day = 0; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelHistory.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelHistory.php new file mode 100644 index 0000000..e6d518a --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelHistory.php @@ -0,0 +1,37 @@ +liveRecordList; + } + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + + if (isset($xml->LiveRecord)) { + foreach ($xml->LiveRecord as $record) { + $liveRecord = new LiveChannelHistory(); + $liveRecord->parseFromXmlNode($record); + $this->liveRecordList[] = $liveRecord; + } + } + } + + public function serializeToXml() + { + throw new OssException("Not implemented."); + } + + private $liveRecordList = array(); +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelInfo.php new file mode 100644 index 0000000..0b5edfc --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelInfo.php @@ -0,0 +1,68 @@ +description; + } + + public function getStatus() + { + return $this->status; + } + + public function getType() + { + return $this->type; + } + + public function getFragDuration() + { + return $this->fragDuration; + } + + public function getFragCount() + { + return $this->fragCount; + } + + public function getPlayListName() + { + return $this->playlistName; + } + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + + $this->description = strval($xml->Description); + $this->status = strval($xml->Status); + + if (isset($xml->Target)) { + foreach ($xml->Target as $target) { + $this->type = strval($target->Type); + $this->fragDuration = strval($target->FragDuration); + $this->fragCount = strval($target->FragCount); + $this->playlistName = strval($target->PlaylistName); + } + } + } + + public function serializeToXml() + { + throw new OssException("Not implemented."); + } + + private $description; + private $status; + private $type; + private $fragDuration; + private $fragCount; + private $playlistName; +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelStatus.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelStatus.php new file mode 100644 index 0000000..2ee7a68 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/GetLiveChannelStatus.php @@ -0,0 +1,107 @@ +status; + } + + public function getConnectedTime() + { + return $this->connectedTime; + } + + public function getRemoteAddr() + { + return $this->remoteAddr; + } + + public function getVideoWidth() + { + return $this->videoWidth; + } + public function getVideoHeight() + { + return $this->videoHeight; + } + public function getVideoFrameRate() + { + return $this->videoFrameRate; + } + public function getVideoBandwidth() + { + return $this->videoBandwidth; + } + public function getVideoCodec() + { + return $this->videoCodec; + } + + public function getAudioBandwidth() + { + return $this->audioBandwidth; + } + public function getAudioSampleRate() + { + return $this->audioSampleRate; + } + public function getAudioCodec() + { + return $this->audioCodec; + } + + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + $this->status = strval($xml->Status); + $this->connectedTime = strval($xml->ConnectedTime); + $this->remoteAddr = strval($xml->RemoteAddr); + + if (isset($xml->Video)) { + foreach ($xml->Video as $video) { + $this->videoWidth = intval($video->Width); + $this->videoHeight = intval($video->Height); + $this->videoFrameRate = intval($video->FrameRate); + $this->videoBandwidth = intval($video->Bandwidth); + $this->videoCodec = strval($video->Codec); + } + } + + if (isset($xml->Video)) { + foreach ($xml->Audio as $audio) { + $this->audioBandwidth = intval($audio->Bandwidth); + $this->audioSampleRate = intval($audio->SampleRate); + $this->audioCodec = strval($audio->Codec); + } + } + + } + + public function serializeToXml() + { + throw new OssException("Not implemented."); + } + + private $status; + private $connectedTime; + private $remoteAddr; + + private $videoWidth; + private $videoHeight; + private $videoFrameRate; + private $videoBandwidth; + private $videoCodec; + + private $audioBandwidth; + private $audioSampleRate; + private $audioCodec; + + +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/InitiateWormConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/InitiateWormConfig.php new file mode 100644 index 0000000..572ceed --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/InitiateWormConfig.php @@ -0,0 +1,64 @@ +day = $day; + } + + /** + * Parse InitiateWormConfig from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + throw new OssException("Not implemented."); + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + if (isset($this->day)) { + $xml->addChild('RetentionPeriodInDays', $this->day); + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return int + */ + public function getDay() + { + return $this->day; + } + + private $day = 0; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php new file mode 100644 index 0000000..a0e2126 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleAction.php @@ -0,0 +1,88 @@ +action = $action; + $this->timeSpec = $timeSpec; + $this->timeValue = $timeValue; + } + + /** + * @return LifecycleAction + */ + public function getAction() + { + return $this->action; + } + + /** + * @param string $action + */ + public function setAction($action) + { + $this->action = $action; + } + + /** + * @return string + */ + public function getTimeSpec() + { + return $this->timeSpec; + } + + /** + * @param string $timeSpec + */ + public function setTimeSpec($timeSpec) + { + $this->timeSpec = $timeSpec; + } + + /** + * @return string + */ + public function getTimeValue() + { + return $this->timeValue; + } + + /** + * @param string $timeValue + */ + public function setTimeValue($timeValue) + { + $this->timeValue = $timeValue; + } + + /** + * Use appendToXml to insert actions into xml. + * + * @param \SimpleXMLElement $xmlRule + */ + public function appendToXml(&$xmlRule) + { + $xmlAction = $xmlRule->addChild($this->action); + $xmlAction->addChild($this->timeSpec, $this->timeValue); + } + + private $action; + private $timeSpec; + private $timeValue; + +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php new file mode 100644 index 0000000..f2d2dc3 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleConfig.php @@ -0,0 +1,107 @@ +rules = array(); + $xml = simplexml_load_string($strXml); + if (!isset($xml->Rule)) return; + $this->rules = array(); + foreach ($xml->Rule as $rule) { + $id = strval($rule->ID); + $prefix = strval($rule->Prefix); + $status = strval($rule->Status); + $actions = array(); + foreach ($rule as $key => $value) { + if ($key === 'ID' || $key === 'Prefix' || $key === 'Status') continue; + $action = $key; + $timeSpec = null; + $timeValue = null; + foreach ($value as $timeSpecKey => $timeValueValue) { + $timeSpec = $timeSpecKey; + $timeValue = strval($timeValueValue); + } + $actions[] = new LifecycleAction($action, $timeSpec, $timeValue); + } + $this->rules[] = new LifecycleRule($id, $prefix, $status, $actions); + } + return; + } + + + /** + * Serialize the object to xml + * + * @return string + */ + public function serializeToXml() + { + + $xml = new \SimpleXMLElement(''); + foreach ($this->rules as $rule) { + $xmlRule = $xml->addChild('Rule'); + $rule->appendToXml($xmlRule); + } + return $xml->asXML(); + } + + /** + * + * Add a LifecycleRule + * + * @param LifecycleRule $lifecycleRule + * @throws OssException + */ + public function addRule($lifecycleRule) + { + if (!isset($lifecycleRule)) { + throw new OssException("lifecycleRule is null"); + } + $this->rules[] = $lifecycleRule; + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * Get all lifecycle rules. + * + * @return LifecycleRule[] + */ + public function getRules() + { + return $this->rules; + } + + /** + * @var LifecycleRule[] + */ + private $rules; +} + + diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php new file mode 100644 index 0000000..73c6cc3 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LifecycleRule.php @@ -0,0 +1,126 @@ +id; + } + + /** + * @param string $id Rule Id + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * Get a file prefix + * + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * Set a file prefix + * + * @param string $prefix The file prefix + */ + public function setPrefix($prefix) + { + $this->prefix = $prefix; + } + + /** + * Get Lifecycle status + * + * @return string + */ + public function getStatus() + { + return $this->status; + } + + /** + * Set Lifecycle status + * + * @param string $status + */ + public function setStatus($status) + { + $this->status = $status; + } + + /** + * + * @return LifecycleAction[] + */ + public function getActions() + { + return $this->actions; + } + + /** + * @param LifecycleAction[] $actions + */ + public function setActions($actions) + { + $this->actions = $actions; + } + + + /** + * LifecycleRule constructor. + * + * @param string $id rule Id + * @param string $prefix File prefix + * @param string $status Rule status, which has the following valid values: [self::LIFECYCLE_STATUS_ENABLED, self::LIFECYCLE_STATUS_DISABLED] + * @param LifecycleAction[] $actions + */ + public function __construct($id, $prefix, $status, $actions) + { + $this->id = $id; + $this->prefix = $prefix; + $this->status = $status; + $this->actions = $actions; + } + + /** + * @param \SimpleXMLElement $xmlRule + */ + public function appendToXml(&$xmlRule) + { + $xmlRule->addChild('ID', $this->id); + $xmlRule->addChild('Prefix', $this->prefix); + $xmlRule->addChild('Status', $this->status); + foreach ($this->actions as $action) { + $action->appendToXml($xmlRule); + } + } + + private $id; + private $prefix; + private $status; + private $actions = array(); + + const LIFECYCLE_STATUS_ENABLED = 'Enabled'; + const LIFECYCLE_STATUS_DISABLED = 'Disabled'; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ListMultipartUploadInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ListMultipartUploadInfo.php new file mode 100644 index 0000000..105d005 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ListMultipartUploadInfo.php @@ -0,0 +1,134 @@ +bucket = $bucket; + $this->keyMarker = $keyMarker; + $this->uploadIdMarker = $uploadIdMarker; + $this->nextKeyMarker = $nextKeyMarker; + $this->nextUploadIdMarker = $nextUploadIdMarker; + $this->delimiter = $delimiter; + $this->prefix = $prefix; + $this->maxUploads = $maxUploads; + $this->isTruncated = $isTruncated; + $this->uploads = $uploads; + } + + /** + * 得到bucket名称 + * + * @return string + */ + public function getBucket() + { + return $this->bucket; + } + + /** + * @return string + */ + public function getKeyMarker() + { + return $this->keyMarker; + } + + /** + * + * @return string + */ + public function getUploadIdMarker() + { + return $this->uploadIdMarker; + } + + /** + * @return string + */ + public function getNextKeyMarker() + { + return $this->nextKeyMarker; + } + + /** + * @return string + */ + public function getNextUploadIdMarker() + { + return $this->nextUploadIdMarker; + } + + /** + * @return string + */ + public function getDelimiter() + { + return $this->delimiter; + } + + /** + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * @return int + */ + public function getMaxUploads() + { + return $this->maxUploads; + } + + /** + * @return string + */ + public function getIsTruncated() + { + return $this->isTruncated; + } + + /** + * @return UploadInfo[] + */ + public function getUploads() + { + return $this->uploads; + } + + private $bucket = ""; + private $keyMarker = ""; + private $uploadIdMarker = ""; + private $nextKeyMarker = ""; + private $nextUploadIdMarker = ""; + private $delimiter = ""; + private $prefix = ""; + private $maxUploads = 0; + private $isTruncated = "false"; + private $uploads = array(); +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ListPartsInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ListPartsInfo.php new file mode 100644 index 0000000..f1d10ee --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ListPartsInfo.php @@ -0,0 +1,97 @@ +bucket = $bucket; + $this->key = $key; + $this->uploadId = $uploadId; + $this->nextPartNumberMarker = $nextPartNumberMarker; + $this->maxParts = $maxParts; + $this->isTruncated = $isTruncated; + $this->listPart = $listPart; + } + + /** + * @return string + */ + public function getBucket() + { + return $this->bucket; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getUploadId() + { + return $this->uploadId; + } + + /** + * @return int + */ + public function getNextPartNumberMarker() + { + return $this->nextPartNumberMarker; + } + + /** + * @return int + */ + public function getMaxParts() + { + return $this->maxParts; + } + + /** + * @return string + */ + public function getIsTruncated() + { + return $this->isTruncated; + } + + /** + * @return array + */ + public function getListPart() + { + return $this->listPart; + } + + private $bucket = ""; + private $key = ""; + private $uploadId = ""; + private $nextPartNumberMarker = 0; + private $maxParts = 0; + private $isTruncated = ""; + private $listPart = array(); +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelConfig.php new file mode 100644 index 0000000..dadedc9 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelConfig.php @@ -0,0 +1,121 @@ +description = $option['description']; + } + if (isset($option['status'])) { + $this->status = $option['status']; + } + if (isset($option['type'])) { + $this->type = $option['type']; + } + if (isset($option['fragDuration'])) { + $this->fragDuration = $option['fragDuration']; + } + if (isset($option['fragCount'])) { + $this->fragCount = $option['fragCount']; + } + if (isset($option['playListName'])) { + $this->playListName = $option['playListName']; + } + } + + public function getDescription() + { + return $this->description; + } + + public function getStatus() + { + return $this->status; + } + + public function getType() + { + return $this->type; + } + + public function getFragDuration() + { + return $this->fragDuration; + } + + public function getFragCount() + { + return $this->fragCount; + } + + public function getPlayListName() + { + return $this->playListName; + } + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + $this->description = strval($xml->Description); + $this->status = strval($xml->Status); + $target = $xml->Target; + $this->type = strval($target->Type); + $this->fragDuration = intval($target->FragDuration); + $this->fragCount = intval($target->FragCount); + $this->playListName = strval($target->PlayListName); + } + + public function serializeToXml() + { + $strXml = << + + +EOF; + $xml = new \SimpleXMLElement($strXml); + if (isset($this->description)) { + $xml->addChild('Description', $this->description); + } + + if (isset($this->status)) { + $xml->addChild('Status', $this->status); + } + + $node = $xml->addChild('Target'); + $node->addChild('Type', $this->type); + + if (isset($this->fragDuration)) { + $node->addChild('FragDuration', $this->fragDuration); + } + + if (isset($this->fragCount)) { + $node->addChild('FragCount', $this->fragCount); + } + + if (isset($this->playListName)) { + $node->addChild('PlayListName', $this->playListName); + } + + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + private $description; + private $status = "enabled"; + private $type; + private $fragDuration = 5; + private $fragCount = 3; + private $playListName = "playlist.m3u8"; +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelHistory.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelHistory.php new file mode 100644 index 0000000..1c1fd4d --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelHistory.php @@ -0,0 +1,59 @@ +startTime; + } + + public function getEndTime() + { + return $this->endTime; + } + + public function getRemoteAddr() + { + return $this->remoteAddr; + } + + public function parseFromXmlNode($xml) + { + if (isset($xml->StartTime)) { + $this->startTime = strval($xml->StartTime); + } + + if (isset($xml->EndTime)) { + $this->endTime = strval($xml->EndTime); + } + + if (isset($xml->RemoteAddr)) { + $this->remoteAddr = strval($xml->RemoteAddr); + } + } + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + $this->parseFromXmlNode($xml); + } + + public function serializeToXml() + { + throw new OssException("Not implemented."); + } + + private $startTime; + private $endTime; + private $remoteAddr; +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelInfo.php new file mode 100644 index 0000000..c63ec54 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelInfo.php @@ -0,0 +1,107 @@ +name = $name; + $this->description = $description; + $this->publishUrls = array(); + $this->playUrls = array(); + } + + public function getName() + { + return $this->name; + } + + public function setName($name) + { + $this->name = $name; + } + + public function getPublishUrls() + { + return $this->publishUrls; + } + + public function getPlayUrls() + { + return $this->playUrls; + } + + public function getStatus() + { + return $this->status; + } + + public function getLastModified() + { + return $this->lastModified; + } + + public function getDescription() + { + return $this->description; + } + + public function setDescription($description) + { + $this->description = $description; + } + + public function parseFromXmlNode($xml) + { + if (isset($xml->Name)) { + $this->name = strval($xml->Name); + } + + if (isset($xml->Description)) { + $this->description = strval($xml->Description); + } + + if (isset($xml->Status)) { + $this->status = strval($xml->Status); + } + + if (isset($xml->LastModified)) { + $this->lastModified = strval($xml->LastModified); + } + + if (isset($xml->PublishUrls)) { + foreach ($xml->PublishUrls as $url) { + $this->publishUrls[] = strval($url->Url); + } + } + + if (isset($xml->PlayUrls)) { + foreach ($xml->PlayUrls as $url) { + $this->playUrls[] = strval($url->Url); + } + } + } + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + $this->parseFromXmlNode($xml); + } + + public function serializeToXml() + { + throw new OssException("Not implemented."); + } + + private $name; + private $description; + private $publishUrls; + private $playUrls; + private $status; + private $lastModified; +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelListInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelListInfo.php new file mode 100644 index 0000000..f4ee02f --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LiveChannelListInfo.php @@ -0,0 +1,107 @@ +bucket; + } + + public function setBucketName($name) + { + $this->bucket = $name; + } + + /** + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * @return string + */ + public function getMarker() + { + return $this->marker; + } + + /** + * @return int + */ + public function getMaxKeys() + { + return $this->maxKeys; + } + + /** + * @return mixed + */ + public function getIsTruncated() + { + return $this->isTruncated; + } + + /** + * @return LiveChannelInfo[] + */ + public function getChannelList() + { + return $this->channelList; + } + + /** + * @return string + */ + public function getNextMarker() + { + return $this->nextMarker; + } + + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + + $this->prefix = strval($xml->Prefix); + $this->marker = strval($xml->Marker); + $this->maxKeys = intval($xml->MaxKeys); + $this->isTruncated = (strval($xml->IsTruncated) == 'true'); + $this->nextMarker = strval($xml->NextMarker); + + if (isset($xml->LiveChannel)) { + foreach ($xml->LiveChannel as $chan) { + $channel = new LiveChannelInfo(); + $channel->parseFromXmlNode($chan); + $this->channelList[] = $channel; + } + } + } + + public function serializeToXml() + { + throw new OssException("Not implemented."); + } + + private $bucket = ''; + private $prefix = ''; + private $marker = ''; + private $nextMarker = ''; + private $maxKeys = 100; + private $isTruncated = 'false'; + private $channelList = array(); +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php new file mode 100644 index 0000000..ed9fb1d --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/LoggingConfig.php @@ -0,0 +1,86 @@ +targetBucket = $targetBucket; + $this->targetPrefix = $targetPrefix; + } + + /** + * @param $strXml + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (!isset($xml->LoggingEnabled)) return; + foreach ($xml->LoggingEnabled as $status) { + foreach ($status as $key => $value) { + if ($key === 'TargetBucket') { + $this->targetBucket = strval($value); + } elseif ($key === 'TargetPrefix') { + $this->targetPrefix = strval($value); + } + } + break; + } + } + + /** + * Serialize to xml string + * + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + if (isset($this->targetBucket) && isset($this->targetPrefix)) { + $loggingEnabled = $xml->addChild('LoggingEnabled'); + $loggingEnabled->addChild('TargetBucket', $this->targetBucket); + $loggingEnabled->addChild('TargetPrefix', $this->targetPrefix); + } + return $xml->asXML(); + } + + /** + * @return string + */ + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return string + */ + public function getTargetBucket() + { + return $this->targetBucket; + } + + /** + * @return string + */ + public function getTargetPrefix() + { + return $this->targetPrefix; + } + + private $targetBucket = ""; + private $targetPrefix = ""; + +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php new file mode 100644 index 0000000..9e538bf --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectInfo.php @@ -0,0 +1,129 @@ +key = $key; + $this->lastModified = $lastModified; + $this->eTag = $eTag; + $this->type = $type; + $this->size = $size; + $this->storageClass = $storageClass; + $this->owner = $owner; + $this->restoreInfo = $restoreInfo; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getLastModified() + { + return $this->lastModified; + } + + /** + * @return string + */ + public function getETag() + { + return $this->eTag; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * php7 && 64bit can use it + * @return int + */ + public function getSize() + { + return (int)$this->size; + } + + + /** + * php5.x or 32bit must use it + * @return string + */ + public function getSizeStr() + { + return $this->size; + } + + /** + * @return string + */ + public function getStorageClass() + { + return $this->storageClass; + } + + /** + * @return string + */ + public function getRestoreInfo() + { + return $this->restoreInfo; + } + + + /** + * @return Owner|null + */ + public function getOwner() + { + return $this->owner; + } + + private $key = ""; + private $lastModified = ""; + private $eTag = ""; + private $type = ""; + private $size = "0"; + private $storageClass = ""; + /** + * @var Owner + */ + private $owner; + private $restoreInfo; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php new file mode 100644 index 0000000..81c5d27 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfo.php @@ -0,0 +1,126 @@ +bucketName = $bucketName; + $this->prefix = $prefix; + $this->marker = $marker; + $this->nextMarker = $nextMarker; + $this->maxKeys = $maxKeys; + $this->delimiter = $delimiter; + $this->isTruncated = $isTruncated; + $this->objectList = $objectList; + $this->prefixList = $prefixList; + } + + /** + * @return string + */ + public function getBucketName() + { + return $this->bucketName; + } + + /** + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * @return string + */ + public function getMarker() + { + return $this->marker; + } + + /** + * @return int + */ + public function getMaxKeys() + { + return $this->maxKeys; + } + + /** + * @return string + */ + public function getDelimiter() + { + return $this->delimiter; + } + + /** + * @return mixed + */ + public function getIsTruncated() + { + return $this->isTruncated; + } + + /** + * Get the ObjectInfo list. + * + * @return ObjectInfo[] + */ + public function getObjectList() + { + return $this->objectList; + } + + /** + * Get the PrefixInfo list + * + * @return PrefixInfo[] + */ + public function getPrefixList() + { + return $this->prefixList; + } + + /** + * @return string + */ + public function getNextMarker() + { + return $this->nextMarker; + } + + private $bucketName = ""; + private $prefix = ""; + private $marker = ""; + private $nextMarker = ""; + private $maxKeys = 0; + private $delimiter = ""; + private $isTruncated = null; + private $objectList = array(); + private $prefixList = array(); +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfoV2.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfoV2.php new file mode 100644 index 0000000..c1fef22 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectListInfoV2.php @@ -0,0 +1,147 @@ +bucketName = $bucketName; + $this->prefix = $prefix; + $this->maxKeys = $maxKeys; + $this->delimiter = $delimiter; + $this->isTruncated = $isTruncated; + $this->objectList = $objectList; + $this->prefixList = $prefixList; + $this->continuationToken = $continuationToken; + $this->nextContinuationToken = $nextContinuationToken; + $this->startAfter = $startAfter; + $this->keyCount = $keyCount; + } + + /** + * @return string + */ + public function getBucketName() + { + return $this->bucketName; + } + + /** + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * @return int + */ + public function getMaxKeys() + { + return $this->maxKeys; + } + + /** + * @return string + */ + public function getDelimiter() + { + return $this->delimiter; + } + + /** + * @return mixed + */ + public function getIsTruncated() + { + return $this->isTruncated; + } + + /** + * Get the ObjectInfo list. + * + * @return ObjectInfo[] + */ + public function getObjectList() + { + return $this->objectList; + } + + /** + * Get the PrefixInfo list + * + * @return PrefixInfo[] + */ + public function getPrefixList() + { + return $this->prefixList; + } + + /** + * @return string + */ + public function getContinuationToken() + { + return $this->continuationToken; + } + + /** + * @return string + */ + public function getNextContinuationToken() + { + return $this->nextContinuationToken; + } + + /** + * @return string + */ + public function getStartAfter() + { + return $this->startAfter; + } + + /** + * @return int + */ + public function getKeyCount() + { + return $this->keyCount; + } + + private $bucketName = ""; + private $prefix = ""; + private $maxKeys = 0; + private $delimiter = ""; + private $isTruncated = null; + private $objectList = array(); + private $prefixList = array(); + private $nextContinuationToken = ""; + private $continuationToken = ""; + private $startAfter = ""; + private $keyCount = 0; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionInfo.php new file mode 100644 index 0000000..663bd0b --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionInfo.php @@ -0,0 +1,125 @@ +key = $key; + $this->versionId = $versionId; + $this->lastModified = $lastModified; + $this->eTag = $eTag; + $this->type = $type; + $this->size = $size; + $this->storageClass = $storageClass; + $this->isLatest = $isLatest; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getVersionId() + { + return $this->versionId; + } + + /** + * @return string + */ + public function getLastModified() + { + return $this->lastModified; + } + + /** + * @return string + */ + public function getETag() + { + return $this->eTag; + } + + /** + * @return string + */ + public function getType() + { + return $this->type; + } + + /** + * php7 && 64bit can use it + * @return int + */ + public function getSize() + { + return (int)$this->size; + } + + + /** + * php5.x or 32bit must use it + * @return string + */ + public function getSizeStr() + { + return $this->size; + } + + /** + * @return string + */ + public function getStorageClass() + { + return $this->storageClass; + } + + /** + * @return string + */ + public function getIsLatest() + { + return $this->isLatest; + } + + private $key = ""; + private $versionId = ""; + private $lastModified = ""; + private $eTag = ""; + private $type = ""; + private $size = "0"; + private $storageClass = ""; + private $isLatest = ""; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionListInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionListInfo.php new file mode 100644 index 0000000..f976b7e --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ObjectVersionListInfo.php @@ -0,0 +1,162 @@ +bucketName = $bucketName; + $this->prefix = $prefix; + $this->keyMarker = $keyMarker; + $this->nextKeyMarker = $nextKeyMarker; + $this->versionIdMarker = $versionIdMarker; + $this->nextVersionIdMarker = $nextVersionIdMarker; + $this->maxKeys = $maxKeys; + $this->delimiter = $delimiter; + $this->isTruncated = $isTruncated; + $this->objectVersionList = $objectversionList; + $this->deleteMarkerList = $deleteMarkerList; + $this->prefixList = $prefixList; + } + + /** + * @return string + */ + public function getBucketName() + { + return $this->bucketName; + } + + /** + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + /** + * @return string + */ + public function getKeyMarker() + { + return $this->keyMarker; + } + + /** + * @return string + */ + public function getNextKeyMarker() + { + return $this->nextKeyMarker; + } + + /** + * @return string + */ + public function getVersionIdMarker() + { + return $this->versionIdMarker; + } + + /** + * @return string + */ + public function getNextVersionIdMarker() + { + return $this->nextVersionIdMarker; + } + + /** + * @return int + */ + public function getMaxKeys() + { + return $this->maxKeys; + } + + /** + * @return string + */ + public function getDelimiter() + { + return $this->delimiter; + } + + /** + * @return mixed + */ + public function getIsTruncated() + { + return $this->isTruncated; + } + + /** + * Get the ObjectVersionInfo list. + * + * @return ObjectVersionInfo[] + */ + public function getObjectVersionList() + { + return $this->objectVersionList; + } + + /** + * Get the DeleteMarkerInfo list. + * + * @return DeleteMarkerInfo[] + */ + public function getDeleteMarkerList() + { + return $this->deleteMarkerList; + } + + /** + * Get the PrefixInfo list + * + * @return PrefixInfo[] + */ + public function getPrefixList() + { + return $this->prefixList; + } + + private $bucketName = ""; + private $prefix = ""; + private $keyMarker = ""; + private $nextKeyMarker = ""; + private $versionIdMarker = ""; + private $nextVersionIdMarker = ""; + private $maxKeys = 0; + private $delimiter = ""; + private $isTruncated = null; + private $objectVersionList = array(); + private $deleteMarkerList = array(); + private $prefixList = array(); +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Owner.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Owner.php new file mode 100644 index 0000000..5de8bcf --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Owner.php @@ -0,0 +1,46 @@ +id = $id; + $this->displayName = $displayName; + } + + /** + * @return string + */ + public function getId() + { + return $this->id; + } + + /** + * @return string + */ + public function getDisplayName() + { + return $this->displayName; + } + + private $id; + private $displayName; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PartInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PartInfo.php new file mode 100644 index 0000000..07df576 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PartInfo.php @@ -0,0 +1,74 @@ +partNumber = $partNumber; + $this->lastModified = $lastModified; + $this->eTag = $eTag; + $this->size = $size; + } + + /** + * @return int + */ + public function getPartNumber() + { + return $this->partNumber; + } + + /** + * @return string + */ + public function getLastModified() + { + return $this->lastModified; + } + + /** + * @return string + */ + public function getETag() + { + return $this->eTag; + } + + /** + * php7 && 64bit can use it + * @return int + */ + public function getSize() + { + return (int)$this->size; + } + + + /** + * php5.x or 32bit must use it + * @return string + */ + public function getSizeStr() + { + return $this->size; + } + + private $partNumber = 0; + private $lastModified = ""; + private $eTag = ""; + private $size = "0"; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php new file mode 100644 index 0000000..27920b9 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/PrefixInfo.php @@ -0,0 +1,36 @@ +prefix = $prefix; + } + + /** + * @return string + */ + public function getPrefix() + { + return $this->prefix; + } + + private $prefix; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php new file mode 100644 index 0000000..0830143 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RefererConfig.php @@ -0,0 +1,93 @@ +AllowEmptyReferer)) return; + if (!isset($xml->RefererList)) return; + $this->allowEmptyReferer = + (strval($xml->AllowEmptyReferer) === 'TRUE' || strval($xml->AllowEmptyReferer) === 'true') ? true : false; + + foreach ($xml->RefererList->Referer as $key => $refer) { + $this->refererList[] = strval($refer); + } + } + + + /** + * serialize the RefererConfig object into xml string + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + if ($this->allowEmptyReferer) { + $xml->addChild('AllowEmptyReferer', 'true'); + } else { + $xml->addChild('AllowEmptyReferer', 'false'); + } + $refererList = $xml->addChild('RefererList'); + foreach ($this->refererList as $referer) { + $refererList->addChild('Referer', $referer); + } + return $xml->asXML(); + } + + /** + * @return string + */ + function __toString() + { + return $this->serializeToXml(); + } + + /** + * @param boolean $allowEmptyReferer + */ + public function setAllowEmptyReferer($allowEmptyReferer) + { + $this->allowEmptyReferer = $allowEmptyReferer; + } + + /** + * @param string $referer + */ + public function addReferer($referer) + { + $this->refererList[] = $referer; + } + + /** + * @return boolean + */ + public function isAllowEmptyReferer() + { + return $this->allowEmptyReferer; + } + + /** + * @return array + */ + public function getRefererList() + { + return $this->refererList; + } + + private $allowEmptyReferer = true; + private $refererList = array(); +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RequestPaymentConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RequestPaymentConfig.php new file mode 100644 index 0000000..6b32060 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RequestPaymentConfig.php @@ -0,0 +1,68 @@ +payer = $payer; + } + + /** + * Parse ServerSideEncryptionConfig from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (isset($xml->Payer)) { + $this->payer = strval($xml->Payer); + } + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + if (isset($this->payer)) { + $xml->addChild('Payer', $this->payer); + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return string + */ + public function getPayer() + { + return $this->payer; + } + + private $payer = ""; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RestoreConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RestoreConfig.php new file mode 100644 index 0000000..156852a --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/RestoreConfig.php @@ -0,0 +1,77 @@ +day = $day; + $this->tier = $tier; + } + + /** + * Parse RestoreConfig from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + throw new OssException("Not implemented."); + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + $xml->addChild('Days', strval($this->day)); + if (isset($this->tier)) { + $xml_param = $xml->addChild('JobParameters'); + $xml_param->addChild('Tier', $this->tier); + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return int + */ + public function getDay() + { + return $this->day; + } + + /** + * @return string + */ + public function getTier() + { + return $this->tier; + } + + private $day = 1; + private $tier = 'Standard'; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ServerSideEncryptionConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ServerSideEncryptionConfig.php new file mode 100644 index 0000000..e3a190b --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/ServerSideEncryptionConfig.php @@ -0,0 +1,91 @@ +sseAlgorithm = $sseAlgorithm; + $this->kmsMasterKeyID = $kmsMasterKeyID; + } + + /** + * Parse ServerSideEncryptionConfig from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (!isset($xml->ApplyServerSideEncryptionByDefault)) return; + foreach ($xml->ApplyServerSideEncryptionByDefault as $default) { + foreach ($default as $key => $value) { + if ($key === 'SSEAlgorithm') { + $this->sseAlgorithm = strval($value); + } elseif ($key === 'KMSMasterKeyID') { + $this->kmsMasterKeyID = strval($value); + } + } + break; + } + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + $default = $xml->addChild('ApplyServerSideEncryptionByDefault'); + if (isset($this->sseAlgorithm)) { + $default->addChild('SSEAlgorithm', $this->sseAlgorithm); + } + if (isset($this->kmsMasterKeyID)) { + $default->addChild('KMSMasterKeyID', $this->kmsMasterKeyID); + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return string + */ + public function getSSEAlgorithm() + { + return $this->sseAlgorithm; + } + + /** + * @return string + */ + public function getKMSMasterKeyID() + { + return $this->kmsMasterKeyID; + } + + private $sseAlgorithm = ""; + private $kmsMasterKeyID = ""; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php new file mode 100644 index 0000000..39a9e72 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/StorageCapacityConfig.php @@ -0,0 +1,76 @@ +storageCapacity = $storageCapacity; + } + + /** + * Not implemented + */ + public function parseFromXml($strXml) + { + throw new OssException("Not implemented."); + } + + /** + * Serialize StorageCapacityConfig into xml + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + $xml->addChild('StorageCapacity', strval($this->storageCapacity)); + return $xml->asXML(); + } + + /** + * To string + * + * @return string + */ + function __toString() + { + return $this->serializeToXml(); + } + + /** + * Set storage capacity + * + * @param int $storageCapacity + */ + public function setStorageCapacity($storageCapacity) + { + $this->storageCapacity = $storageCapacity; + } + + /** + * Get storage capacity + * + * @return int + */ + public function getStorageCapacity() + { + return $this->storageCapacity; + } + + private $storageCapacity = 0; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Tag.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Tag.php new file mode 100644 index 0000000..509bd6e --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/Tag.php @@ -0,0 +1,41 @@ +key = $key; + $this->value = $value; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getValue() + { + return $this->value; + } + + private $key = ""; + private $value = ""; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/TaggingConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/TaggingConfig.php new file mode 100644 index 0000000..09fa323 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/TaggingConfig.php @@ -0,0 +1,89 @@ +tags = array(); + } + + /** + * Get Tag list + * + * @return Tag[] + */ + public function getTags() + { + return $this->tags; + } + + + /** + * Add a new Tag + * + * @param Tag $tag + * @throws OssException + */ + public function addTag($tag) + { + $this->tags[] = $tag; + } + + /** + * Parse TaggingConfig from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (!isset($xml->TagSet) || !isset($xml->TagSet->Tag)) return; + foreach ($xml->TagSet->Tag as $tag) { + $this->addTag(new Tag($tag->Key, $tag->Value)); + } + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + $xmlTagSet = $xml->addChild('TagSet'); + foreach ($this->tags as $tag) { + $xmlTag = $xmlTagSet->addChild('Tag'); + $xmlTag->addChild('Key', strval($tag->getKey())); + $xmlTag->addChild('Value', strval($tag->getValue())); + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * Tag list + * + * @var Tag[] + */ + private $tags = array(); +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/TransferAccelerationConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/TransferAccelerationConfig.php new file mode 100644 index 0000000..187fb24 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/TransferAccelerationConfig.php @@ -0,0 +1,73 @@ +Enabled)) { + $this->enabled = (strval($xml->Enabled) === 'TRUE' || strval($xml->Enabled) === 'true') ? true : false; + } + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + if (isset($this->enabled)) { + if($this->enabled === true){ + $xml->addChild('Enabled','true'); + } else { + $xml->addChild('Enabled','false'); + } + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + + /** + * @return bool + */ + public function getEnabled() + { + return $this->enabled; + } + + /** + * @param boolean enabled + */ + public function setEnabled($enabled) + { + $this->enabled = $enabled; + } + + /** + * @var $enabled boolean + */ + private $enabled = false; +} + + diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php new file mode 100644 index 0000000..49aa414 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/UploadInfo.php @@ -0,0 +1,55 @@ +key = $key; + $this->uploadId = $uploadId; + $this->initiated = $initiated; + } + + /** + * @return string + */ + public function getKey() + { + return $this->key; + } + + /** + * @return string + */ + public function getUploadId() + { + return $this->uploadId; + } + + /** + * @return string + */ + public function getInitiated() + { + return $this->initiated; + } + + private $key = ""; + private $uploadId = ""; + private $initiated = ""; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/VersioningConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/VersioningConfig.php new file mode 100644 index 0000000..992a80f --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/VersioningConfig.php @@ -0,0 +1,67 @@ +status = $status; + } + + /** + * Parse VersioningConfig from the xml. + * + * @param string $strXml + * @throws OssException + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (isset($xml->Status)) { + $this->status = strval($xml->Status); + } + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + if (isset($this->status)) { + $xml->addChild('Status', $this->status); + } + return $xml->asXML(); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return string + */ + public function getStatus() + { + return $this->status; + } + + private $status = ""; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php new file mode 100644 index 0000000..e298eb4 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WebsiteConfig.php @@ -0,0 +1,76 @@ +indexDocument = $indexDocument; + $this->errorDocument = $errorDocument; + } + + /** + * @param string $strXml + * @return null + */ + public function parseFromXml($strXml) + { + $xml = simplexml_load_string($strXml); + if (isset($xml->IndexDocument) && isset($xml->IndexDocument->Suffix)) { + $this->indexDocument = strval($xml->IndexDocument->Suffix); + } + if (isset($xml->ErrorDocument) && isset($xml->ErrorDocument->Key)) { + $this->errorDocument = strval($xml->ErrorDocument->Key); + } + } + + /** + * Serialize the WebsiteConfig object into xml string. + * + * @return string + * @throws OssException + */ + public function serializeToXml() + { + $xml = new \SimpleXMLElement(''); + $index_document_part = $xml->addChild('IndexDocument'); + $error_document_part = $xml->addChild('ErrorDocument'); + $index_document_part->addChild('Suffix', $this->indexDocument); + $error_document_part->addChild('Key', $this->errorDocument); + return $xml->asXML(); + } + + /** + * @return string + */ + public function getIndexDocument() + { + return $this->indexDocument; + } + + /** + * @return string + */ + public function getErrorDocument() + { + return $this->errorDocument; + } + + private $indexDocument = ""; + private $errorDocument = ""; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WormConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WormConfig.php new file mode 100644 index 0000000..6a48956 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/WormConfig.php @@ -0,0 +1,90 @@ +WormId)) { + $this->wormId = strval($xml->WormId); + } + if (isset($xml->State)) { + $this->state = strval($xml->State); + } + if (isset($xml->RetentionPeriodInDays)) { + $this->day = intval($xml->RetentionPeriodInDays); + } + if (isset($xml->CreationDate)) { + $this->creationDate = strval($xml->CreationDate); + } + } + + /** + * Serialize the object into xml string. + * + * @return string + */ + public function serializeToXml() + { + throw new OssException("Not implemented."); + } + + public function __toString() + { + return $this->serializeToXml(); + } + + /** + * @return string + */ + public function getWormId() + { + return $this->wormId; + } + + /** + * @return string + */ + public function getState() + { + return $this->state; + } + + /** + * @return int + */ + public function getDay() + { + return $this->day; + } + + /** + * @return string + */ + public function getCreationDate() + { + return $this->creationDate; + } + + private $wormId = ''; + private $state = ''; + private $creationDate = ''; + private $day = 0; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php new file mode 100644 index 0000000..8c0a0db --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Model/XmlConfig.php @@ -0,0 +1,27 @@ + $endpoint, + 'cname' => $isCName, + 'request_proxy' => $requestProxy, + 'provider' => $provider + ); + $this->__initNewClient($config); + } + + /** + * @param array $config + * @throws OssException + */ + private function __initNewClient($config = array()) + { + $isCName = isset($config['cname']) ? $config['cname'] : false; + $endpoint = isset($config['endpoint']) ? $config['endpoint'] : ''; + $requestProxy = isset($config['request_proxy']) ? $config['request_proxy'] : null; + $provider = isset($config['provider']) ? $config['provider'] : ''; + if (empty($endpoint)) { + throw new OssException("endpoint is empty"); + } + $this->hostname = $this->checkEndpoint($endpoint, $isCName); + if (isset($config['forcePathStyle'])) { + if ($config['forcePathStyle'] === true) { + $this->hostType = self::OSS_HOST_TYPE_PATH_STYLE; + } + } + $this->requestProxy = $requestProxy; + if (!$provider instanceof CredentialsProvider) { + throw new OssException("provider must be an instance of CredentialsProvider"); + } + $this->provider = $provider; + + $this->region = isset($config['region']) ? $config['region'] : ''; + $this->cloudBoxId = isset($config['cloudBoxId']) ? $config['cloudBoxId'] : ''; + + // $enableStrictObjName + $this->enableStrictObjName = true; + if (isset($config['strictObjectName'])) { + if ($config['strictObjectName'] === false) { + $this->enableStrictObjName = false; + } + } + + // sign version + $signatureVersion = self::OSS_SIGNATURE_VERSION_V1; + if (isset($config['signatureVersion']) && $config['signatureVersion'] === self::OSS_SIGNATURE_VERSION_V4) { + $signatureVersion = self::OSS_SIGNATURE_VERSION_V4; + } + if ($signatureVersion === self::OSS_SIGNATURE_VERSION_V4) { + $this->enableStrictObjName = false; + $this->signer = new SignerV4(); + } else { + $this->signer = new SignerV1(); + } + + //checkObjectEncoding + $this->checkObjectEncoding = false; + if (isset($config['checkObjectEncoding'])) { + if ($config['checkObjectEncoding'] === true) { + $this->checkObjectEncoding = true; + } + } + + //filePathCompatible + $this->filePathCompatible = false; + if (version_compare(phpversion(), '7.0.0', '<')) { + if (OssUtil::isWin()) { + $this->filePathCompatible = true; + } + } + if (isset($config['filePathCompatible'])) { + if ($config['filePathCompatible'] === true) { + $this->filePathCompatible = true; + } else if ($config['filePathCompatible'] === false) { + $this->filePathCompatible = false; + } + } + + self::checkEnv(); + } + + /** + * Lists the Bucket [GetService]. Not applicable if the endpoint is CName (because CName must be binded to a specific bucket). + * + * @param array $options + * @return BucketListInfo|null + * @throws OssException|RequestCore_Exception + */ + public function listBuckets($options = NULL) + { + if ($this->hostType === self::OSS_HOST_TYPE_CNAME) { + throw new OssException("operation is not permitted with CName host"); + } + $this->precheckOptions($options); + $options[self::OSS_BUCKET] = ''; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $response = $this->auth($options); + $result = new ListBucketsResult($response); + return $result->getData(); + } + + /** + * Creates bucket,The ACL of the bucket created by default is OssClient::OSS_ACL_TYPE_PRIVATE + * + * @param string $bucket + * @param string $acl + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function createBucket($bucket, $acl = self::OSS_ACL_TYPE_PRIVATE, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_HEADERS][self::OSS_ACL] = $acl; + if (isset($options[self::OSS_STORAGE])) { + $this->precheckStorage($options[self::OSS_STORAGE]); + $options[self::OSS_CONTENT] = OssUtil::createBucketXmlBody($options[self::OSS_STORAGE]); + unset($options[self::OSS_STORAGE]); + } + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Deletes bucket + * The deletion will not succeed if the bucket is not empty (either has objects or parts) + * To delete a bucket, all its objects and parts must be deleted first. + * + * @param string $bucket + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucket($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Checks if a bucket exists + * + * @param string $bucket + * @return bool|null + * @throws OssException|RequestCore_Exception + */ + public function doesBucketExist($bucket) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'acl'; + $response = $this->auth($options); + $result = new ExistResult($response); + return $result->getData(); + } + + /** + * Get the data center location information for the bucket + * + * @param string $bucket + * @param array $options + * @return string|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketLocation($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'location'; + $response = $this->auth($options); + $result = new GetLocationResult($response); + return $result->getData(); + } + + /** + * Get the Meta information for the Bucket + * + * @param string $bucket + * @param array $options Refer to the SDK documentation + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketMeta($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_HEAD; + $response = $this->auth($options); + $result = new HeaderResult($response); + return $result->getData(); + } + + /** + * Gets the bucket ACL + * + * @param string $bucket + * @param array $options + * @return string|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketAcl($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'acl'; + $response = $this->auth($options); + $result = new AclResult($response); + return $result->getData(); + } + + /** + * Sets the bucket ACL + * + * @param string $bucket bucket name + * @param string $acl access permissions, valid values are ['private', 'public-read', 'public-read-write'] + * @param array $options by default is empty + * @return null + * @throws OssException|RequestCore_Exception + */ + public function putBucketAcl($bucket, $acl, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_HEADERS][self::OSS_ACL] = $acl; + $options[self::OSS_SUB_RESOURCE] = 'acl'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets object ACL + * + * @param string $bucket + * @param string $object + * @param array $options + * @return string|null + * @throws OssException|RequestCore_Exception + */ + public function getObjectAcl($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options, true); + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = 'acl'; + $response = $this->auth($options); + $result = new AclResult($response); + return $result->getData(); + } + + /** + * Sets the object ACL + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $acl access permissions, valid values are ['default', 'private', 'public-read', 'public-read-write'] + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function putObjectAcl($bucket, $object, $acl, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options, true); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_HEADERS][self::OSS_OBJECT_ACL] = $acl; + $options[self::OSS_SUB_RESOURCE] = 'acl'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets the bucket logging config + * + * @param string $bucket bucket name + * @param array $options by default is empty + * @return LoggingConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketLogging($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'logging'; + $response = $this->auth($options); + $result = new GetLoggingResult($response); + return $result->getData(); + } + + /** + * Sets the bycket logging config. Only owner can call this API. + * + * @param string $bucket bucket name + * @param string $targetBucket The logging file's bucket + * @param string $targetPrefix The logging file's prefix + * @param array $options By default is empty. + * @return null + * @throws OssException|RequestCore_Exception + */ + public function putBucketLogging($bucket, $targetBucket, $targetPrefix, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $this->precheckBucket($targetBucket, 'targetbucket is not allowed empty'); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'logging'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + + $loggingConfig = new LoggingConfig($targetBucket, $targetPrefix); + $options[self::OSS_CONTENT] = $loggingConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Deletes the bucket logging config + * + * @param string $bucket bucket name + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketLogging($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_SUB_RESOURCE] = 'logging'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Sets the website config in bucket---that is could make the bucket as a static website once the CName is binded. + * + * @param string $bucket bucket name + * @param WebsiteConfig $websiteConfig + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function putBucketWebsite($bucket, $websiteConfig, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'website'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $websiteConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets the website config in the bucket + * + * @param string $bucket bucket name + * @param array $options + * @return WebsiteConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketWebsite($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'website'; + $response = $this->auth($options); + $result = new GetWebsiteResult($response); + return $result->getData(); + } + + /** + * Deletes the website config in the bucket + * + * @param string $bucket bucket name + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketWebsite($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_SUB_RESOURCE] = 'website'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Sets the cross-origin-resource-sharing (CORS) rule. It would overwrite the originl one. + * + * @param string $bucket bucket name + * @param CorsConfig $corsConfig CORS config. Check out the details from OSS API document + * @param array $options array + * @return null + * @throws OssException|RequestCore_Exception + */ + public function putBucketCors($bucket, $corsConfig, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'cors'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $corsConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets the bucket CORS config + * + * @param string $bucket bucket name + * @param array $options + * @return CorsConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketCors($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'cors'; + $response = $this->auth($options); + $result = new GetCorsResult($response); + return $result->getData(); + } + + /** + * Deletes the bucket's CORS config and disable the CORS on the bucket. + * + * @param string $bucket bucket name + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketCors($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_SUB_RESOURCE] = 'cors'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Bind a CName for the bucket + * + * @param string $bucket bucket name + * @param string $cname + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function addBucketCname($bucket, $cname, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $cnameConfig = new CnameConfig(); + $cnameConfig->addCname($cname); + $options[self::OSS_CONTENT] = $cnameConfig->serializeToXml(); + $options[self::OSS_COMP] = 'add'; + $options[self::OSS_CNAME] = ''; + + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets the binded CName list of the bucket + * + * @param string $bucket bucket name + * @param array $options + * @return CnameConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketCname($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_CNAME] = ''; + $response = $this->auth($options); + $result = new GetCnameResult($response); + return $result->getData(); + } + + /** + * Remove a CName binding from the bucket + * + * @param string $bucket bucket name + * @param CnameConfig $cname + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketCname($bucket, $cname, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $cnameConfig = new CnameConfig(); + $cnameConfig->addCname($cname); + $options[self::OSS_CONTENT] = $cnameConfig->serializeToXml(); + $options[self::OSS_COMP] = 'delete'; + $options[self::OSS_CNAME] = ''; + + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * create a cname token for a bucket + * + * @param string $bucket bucket name + * @param array $options + * @return CnameTokenInfo|null + * @throws OssException|RequestCore_Exception + */ + public function createBucketCnameToken($bucket, $cname, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $cnameConfig = new CnameConfig(); + $cnameConfig->addCname($cname); + $options[self::OSS_CONTENT] = $cnameConfig->serializeToXml(); + $options[self::OSS_COMP] = 'token'; + $options[self::OSS_CNAME] = ''; + $response = $this->auth($options); + $result = new CreateBucketCnameTokenResult($response); + return $result->getData(); + } + + /** + * get a cname token for a bucket + * + * @param string $bucket bucket name + * @param array $options + * @return CnameTokenInfo|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketCnameToken($bucket, $cname, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_COMP] = 'token'; + $options[self::OSS_CNAME] = $cname; + $response = $this->auth($options); + $result = new GetBucketCnameTokenResult($response); + return $result->getData(); + } + + /** + * Creates a Live Channel under a bucket + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param LiveChannelConfig $channelConfig + * @param array $options + * @return LiveChannelInfo|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketLiveChannel($bucket, $channelName, $channelConfig, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $channelName; + $options[self::OSS_SUB_RESOURCE] = 'live'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $channelConfig->serializeToXml(); + + $response = $this->auth($options); + $result = new PutLiveChannelResult($response); + $info = $result->getData(); + $info->setName($channelName); + $info->setDescription($channelConfig->getDescription()); + + return $info; + } + + /** + * Sets the LiveChannel status + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param string channelStatus $channelStatus enabled or disabled + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function putLiveChannelStatus($bucket, $channelName, $channelStatus, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $channelName; + $options[self::OSS_SUB_RESOURCE] = 'live'; + $options[self::OSS_LIVE_CHANNEL_STATUS] = $channelStatus; + + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets the LiveChannel information by the channel name + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param array $options + * @return GetLiveChannelInfo|null + * @throws OssException|RequestCore_Exception + */ + public function getLiveChannelInfo($bucket, $channelName, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_OBJECT] = $channelName; + $options[self::OSS_SUB_RESOURCE] = 'live'; + + $response = $this->auth($options); + $result = new GetLiveChannelInfoResult($response); + return $result->getData(); + } + + /** + * Gets the status of LiveChannel + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param array $options + * @return GetLiveChannelStatus|null + * @throws OssException|RequestCore_Exception + */ + public function getLiveChannelStatus($bucket, $channelName, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_OBJECT] = $channelName; + $options[self::OSS_SUB_RESOURCE] = 'live'; + $options[self::OSS_COMP] = 'stat'; + + $response = $this->auth($options); + $result = new GetLiveChannelStatusResult($response); + return $result->getData(); + } + + /** + * Gets the LiveChannel pushing streaming record + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param array $options + * @return GetLiveChannelHistory|null + * @throws OssException|RequestCore_Exception + */ + public function getLiveChannelHistory($bucket, $channelName, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_OBJECT] = $channelName; + $options[self::OSS_SUB_RESOURCE] = 'live'; + $options[self::OSS_COMP] = 'history'; + + $response = $this->auth($options); + $result = new GetLiveChannelHistoryResult($response); + return $result->getData(); + } + + /** + *Gets the live channel list under a bucket. + * + * @param string $bucket bucket name + * @param array $options + * @return LiveChannelListInfo|null + * @throws OssException|RequestCore_Exception + */ + public function listBucketLiveChannels($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'live'; + $options[self::OSS_QUERY_STRING] = array( + 'prefix' => isset($options['prefix']) ? $options['prefix'] : '', + 'marker' => isset($options['marker']) ? $options['marker'] : '', + 'max-keys' => isset($options['max-keys']) ? $options['max-keys'] : '', + ); + $response = $this->auth($options); + $result = new ListLiveChannelResult($response); + $list = $result->getData(); + $list->setBucketName($bucket); + + return $list; + } + + /** + * Creates a play list file for the LiveChannel + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param string $playlistName The playlist name, must end with ".m3u8". + * @param array $setTime startTime and EndTime in unix time. No more than 1 day. + * @return null + * @throws OssException|RequestCore_Exception + */ + public function postVodPlaylist($bucket, $channelName, $playlistName, $setTime) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_OBJECT] = $channelName . '/' . $playlistName; + $options[self::OSS_SUB_RESOURCE] = 'vod'; + $options[self::OSS_LIVE_CHANNEL_END_TIME] = $setTime['EndTime']; + $options[self::OSS_LIVE_CHANNEL_START_TIME] = $setTime['StartTime']; + + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Deletes the Bucket LiveChannel + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketLiveChannel($bucket, $channelName, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_OBJECT] = $channelName; + $options[self::OSS_SUB_RESOURCE] = 'live'; + + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Generates the signed pushing streaming url + * + * @param string $bucket bucket name + * @param string channelName $channelName + * @param int timeout timeout value in seconds + * @param array $options + * @return string The signed pushing streaming url + * @throws OssException + */ + public function signRtmpUrl($bucket, $channelName, $timeout = 60, $options = NULL) + { + $this->precheckCommon($bucket, $channelName, $options, false); + $expires = time() + $timeout; + $proto = 'rtmp://'; + $hostname = $this->generateHostname($bucket); + $cano_params = ''; + $query_items = array(); + $params = isset($options['params']) ? $options['params'] : array(); + uksort($params, 'strnatcasecmp'); + foreach ($params as $key => $value) { + $cano_params = $cano_params . $key . ':' . $value . "\n"; + $query_items[] = rawurlencode($key) . '=' . rawurlencode($value); + } + $resource = '/' . $bucket . '/' . $channelName; + + $string_to_sign = $expires . "\n" . $cano_params . $resource; + $cred = $this->provider->getCredentials(); + $this->checkCredentials($cred); + + $signature = base64_encode(hash_hmac('sha1', $string_to_sign, $cred->getAccessKeySecret(), true)); + + $query_items[] = 'OSSAccessKeyId=' . rawurlencode($cred->getAccessKeyId()); + $query_items[] = 'Expires=' . rawurlencode($expires); + $query_items[] = 'Signature=' . rawurlencode($signature); + + return $proto . $hostname . '/live/' . $channelName . '?' . implode('&', $query_items); + } + + /** + * Generates the signed pushing streaming url + * + * @param string $bucket bucket name + * @param string $channelName channel name + * @param int $expiration expiration time of the Url, unix epoch, since 1970.1.1 00.00.00 UTC + * @param array $options + * @return string The signed pushing streaming url + * @throws OssException + */ + public function generatePresignedRtmpUrl($bucket, $channelName, $expiration, $options = NULL) + { + $this->precheckCommon($bucket, $channelName, $options, false); + $proto = 'rtmp://'; + $hostname = $this->generateHostname($bucket); + $cano_params = ''; + $query_items = array(); + $params = isset($options['params']) ? $options['params'] : array(); + uksort($params, 'strnatcasecmp'); + foreach ($params as $key => $value) { + $cano_params = $cano_params . $key . ':' . $value . "\n"; + $query_items[] = rawurlencode($key) . '=' . rawurlencode($value); + } + $resource = '/' . $bucket . '/' . $channelName; + + $string_to_sign = $expiration . "\n" . $cano_params . $resource; + $cred = $this->provider->getCredentials(); + $this->checkCredentials($cred); + + $signature = base64_encode(hash_hmac('sha1', $string_to_sign, $cred->getAccessKeySecret(), true)); + + $query_items[] = 'OSSAccessKeyId=' . rawurlencode($cred->getAccessKeyId()); + $query_items[] = 'Expires=' . rawurlencode($expiration); + $query_items[] = 'Signature=' . rawurlencode($signature); + + return $proto . $hostname . '/live/' . $channelName . '?' . implode('&', $query_items); + } + + /** + * Precheck the CORS request. Before sending a CORS request, a preflight request (OPTIONS) is sent with the specific origin. + * HTTP METHOD and headers information are sent to OSS as well for evaluating if the CORS request is allowed. + * + * Note: OSS could enable the CORS on the bucket by calling putBucketCors. Once CORS is enabled, the OSS could evaluate accordingto the preflight request. + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $origin the origin of the request + * @param string $request_method The actual HTTP method which will be used in CORS request + * @param string $request_headers The actual HTTP headers which will be used in CORS request + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function optionsObject($bucket, $object, $origin, $request_method, $request_headers, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_OPTIONS; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_HEADERS][self::OSS_OPTIONS_ORIGIN] = $origin; + $options[self::OSS_HEADERS][self::OSS_OPTIONS_REQUEST_HEADERS] = $request_headers; + $options[self::OSS_HEADERS][self::OSS_OPTIONS_REQUEST_METHOD] = $request_method; + $response = $this->auth($options); + $result = new HeaderResult($response); + return $result->getData(); + } + + /** + * Sets the bucket's lifecycle config + * + * @param string $bucket bucket name + * @param LifecycleConfig $lifecycleConfig LifecycleConfig instance + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketLifecycle($bucket, $lifecycleConfig, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'lifecycle'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $lifecycleConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets bucket's lifecycle config + * + * @param string $bucket bucket name + * @param array $options + * @return LifecycleConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketLifecycle($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'lifecycle'; + $response = $this->auth($options); + $result = new GetLifecycleResult($response); + return $result->getData(); + } + + /** + * Deletes the bucket's lifecycle config + * + * @param string $bucket bucket name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketLifecycle($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_SUB_RESOURCE] = 'lifecycle'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Sets a bucket's referer, which has a whitelist of referrer and specifies if empty referer is allowed. + * Checks out API document for more details about "Bucket Referer" + * + * @param string $bucket bucket name + * @param RefererConfig $refererConfig + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketReferer($bucket, $refererConfig, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'referer'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $refererConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets the bucket's Referer + * Checks out API document for more details about "Bucket Referer" + * + * @param string $bucket bucket name + * @param array $options + * @return RefererConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketReferer($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'referer'; + $response = $this->auth($options); + $result = new GetRefererResult($response); + return $result->getData(); + } + + /** + * Set the size of the bucket,the unit is GB + * When the capacity of the bucket is bigger than the set, it's forbidden to continue writing + * + * @param string $bucket bucket name + * @param int $storageCapacity + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketStorageCapacity($bucket, $storageCapacity, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'qos'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $storageCapacityConfig = new StorageCapacityConfig($storageCapacity); + $options[self::OSS_CONTENT] = $storageCapacityConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Get the capacity of the bucket, the unit is GB + * + * @param string $bucket bucket name + * @param array $options + * @return int|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketStorageCapacity($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'qos'; + $response = $this->auth($options); + $result = new GetStorageCapacityResult($response); + return $result->getData(); + } + + /** + * Get the information of the bucket + * + * @param string $bucket bucket name + * @param array $options + * @return BucketInfo|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketInfo($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'bucketInfo'; + $response = $this->auth($options); + $result = new GetBucketInfoResult($response); + return $result->getData(); + } + + /** + * Get the stat of the bucket + * + * @param string $bucket bucket name + * @param array $options + * @return BucketStat|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketStat($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'stat'; + $response = $this->auth($options); + $result = new GetBucketStatResult($response); + return $result->getData(); + } + + /** + * Sets the bucket's policy + * + * @param string $bucket bucket name + * @param string $policy policy json format content + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketPolicy($bucket, $policy, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'policy'; + $options[self::OSS_CONTENT_TYPE] = 'application/json'; + $options[self::OSS_CONTENT] = $policy; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets bucket's policy + * + * @param string $bucket bucket name + * @param array $options + * @return string|null policy json content + * @throws OssException|RequestCore_Exception + */ + public function getBucketPolicy($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'policy'; + $response = $this->auth($options); + $result = new BodyResult($response); + return $result->getData(); + } + + /** + * Deletes the bucket's policy + * + * @param string $bucket bucket name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketPolicy($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_SUB_RESOURCE] = 'policy'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Sets the bucket's encryption + * + * @param string $bucket bucket name + * @param ServerSideEncryptionConfig $sseConfig + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketEncryption($bucket, $sseConfig, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'encryption'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $sseConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets bucket's encryption + * + * @param string $bucket bucket name + * @param array $options + * @return ServerSideEncryptionConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketEncryption($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'encryption'; + $response = $this->auth($options); + $result = new GetBucketEncryptionResult($response); + return $result->getData(); + } + + /** + * Deletes the bucket's encryption + * + * @param string $bucket bucket name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketEncryption($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_SUB_RESOURCE] = 'encryption'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Set the request playment of the bucket, Can be BucketOwner and Requester + * + * @param string $bucket bucket name + * @param string $payer + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketRequestPayment($bucket, $payer, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'requestPayment'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $config = new RequestPaymentConfig($payer); + $options[self::OSS_CONTENT] = $config->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Get the request playment of the bucket + * + * @param string $bucket bucket name + * @param array $options + * @return string|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketRequestPayment($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'requestPayment'; + $response = $this->auth($options); + $result = new GetBucketRequestPaymentResult($response); + return $result->getData(); + } + + /** + * Sets the bucket's tags + * + * @param string $bucket bucket name + * @param TaggingConfig $taggingConfig + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function putBucketTags($bucket, $taggingConfig, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $taggingConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets bucket's tags + * + * @param string $bucket bucket name + * @param array $options + * @return TaggingConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketTags($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING; + $response = $this->auth($options); + $result = new GetBucketTagsResult($response); + return $result->getData(); + } + + /** + * Deletes the bucket's tags + * If want to delete specified tags for a bucket, please set the $tags + * + * @param string $bucket bucket name + * @param tag[] $tags (optional) + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function deleteBucketTags($bucket, $tags = NULL, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + if (empty($tags)) { + $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING; + } else { + $value = ''; + foreach ($tags as $tag) { + $value .= $tag->getKey() . ','; + } + $value = rtrim($value, ','); + $options[self::OSS_TAGGING] = $value; + } + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Set the versioning of the bucket, Can be BucketOwner and Requester + * + * @param string $bucket bucket name + * @param string $status + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putBucketVersioning($bucket, $status, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'versioning'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $config = new VersioningConfig($status); + $options[self::OSS_CONTENT] = $config->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Get the versioning of the bucket + * + * @param string $bucket bucket name + * @param array $options + * @return string|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketVersioning($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'versioning'; + $response = $this->auth($options); + $result = new GetBucketVersioningResult($response); + return $result->getData(); + } + + /** + * Initialize a bucket's worm + * + * @param string $bucket bucket name + * @param int $day + * @param array $options + * @return string|null returns upload id + * @throws OssException|RequestCore_Exception + */ + public function initiateBucketWorm($bucket, $day, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_SUB_RESOURCE] = 'worm'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $config = new InitiateWormConfig($day); + $options[self::OSS_CONTENT] = $config->serializeToXml(); + $response = $this->auth($options); + $result = new InitiateBucketWormResult($response); + return $result->getData(); + } + + /** + * Aborts the bucket's worm + * + * @param string $bucket bucket name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function abortBucketWorm($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_SUB_RESOURCE] = 'worm'; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Complete a bucket's worm + * + * @param string $bucket bucket name + * @param string $wormId + * @param array $options + * @return string|null returns upload id + * @throws OssException|RequestCore_Exception + */ + public function completeBucketWorm($bucket, $wormId, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_WORM_ID] = $wormId; + $options[self::OSS_CONTENT] = ''; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Extend a bucket's worm + * + * @param string $bucket bucket name + * @param string $wormId + * @param int $day + * @param array $options + * @return string|null returns upload id + * @throws OssException|RequestCore_Exception + */ + public function extendBucketWorm($bucket, $wormId, $day, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_WORM_ID] = $wormId; + $options[self::OSS_SUB_RESOURCE] = 'wormExtend'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $config = new ExtendWormConfig($day); + $options[self::OSS_CONTENT] = $config->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Get a bucket's worm + * + * @param string $bucket bucket name + * @param array $options + * @return string|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketWorm($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'worm'; + $response = $this->auth($options); + $result = new GetBucketWormResult($response); + return $result->getData(); + } + + + /** + * Put Bucket TransferAcceleration + * @param $bucket + * @param $enabled boolean + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + + public function putBucketTransferAcceleration($bucket, $enabled, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_SUB_RESOURCE] = 'transferAcceleration'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $config = new TransferAccelerationConfig(); + $config->setEnabled($enabled); + $options[self::OSS_CONTENT] = $config->serializeToXml(); + $response = $this->auth($options); + $result = new HeaderResult($response); + return $result->getData(); + } + + /** + * Put Bucket TransferAcceleration + * @param $bucket + * @param array $options + * @return boolean|null + * @throws OssException|RequestCore_Exception + */ + public function getBucketTransferAcceleration($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'transferAcceleration'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $response = $this->auth($options); + $result = new GetBucketTransferAccelerationResult($response); + return $result->getData(); + } + + /** + * Lists the bucket's object list (in ObjectListInfo) + * + * @param string $bucket + * @param array $options are defined below: + * $options = array( + * 'max-keys' => specifies max object count to return. By default is 100 and max value could be 1000. + * 'prefix' => specifies the key prefix the returned objects must have. Note that the returned keys still contain the prefix. + * 'delimiter' => The delimiter of object name for grouping object. When it's specified, listObjects will differeniate the object and folder. And it will return subfolder's objects. + * 'marker' => The key of returned object must be greater than the 'marker'. + *) + * Prefix and marker are for filtering and paging. Their length must be less than 256 bytes + * @return ObjectListInfo|null + * @throws OssException|RequestCore_Exception + */ + public function listObjects($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $query = isset($options[self::OSS_QUERY_STRING]) ? $options[self::OSS_QUERY_STRING] : array(); + $options[self::OSS_QUERY_STRING] = array_merge( + $query, + array(self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL, + self::OSS_DELIMITER => isset($options[self::OSS_DELIMITER]) ? $options[self::OSS_DELIMITER] : '/', + self::OSS_PREFIX => isset($options[self::OSS_PREFIX]) ? $options[self::OSS_PREFIX] : '', + self::OSS_MAX_KEYS => isset($options[self::OSS_MAX_KEYS]) ? $options[self::OSS_MAX_KEYS] : self::OSS_MAX_KEYS_VALUE, + self::OSS_MARKER => isset($options[self::OSS_MARKER]) ? $options[self::OSS_MARKER] : '') + ); + + $response = $this->auth($options); + $result = new ListObjectsResult($response); + return $result->getData(); + } + + + /** + * Lists the bucket's object list v2 (in ObjectListInfoV2) + * + * @param string $bucket + * @param array $options are defined below: + * $options = array( + * 'max-keys' => specifies max object count to return. By default is 100 and max value could be 1000. + * 'prefix' => specifies the key prefix the returned objects must have. Note that the returned keys still contain the prefix. + * 'delimiter' => The delimiter of object name for grouping object. When it's specified, listObjects will differeniate the object and folder. And it will return subfolder's objects. + * 'start-after' => The key of returned object must be greater than the 'start-after'. + * 'continuation-token' => The token from which the list operation must start. + *) + * Prefix, start-after and continuation-token are for filtering and paging. Their length must be less than 256 bytes + * @return ObjectListInfoV2|null + * @throws OssException|RequestCore_Exception + */ + public function listObjectsV2($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $query = isset($options[self::OSS_QUERY_STRING]) ? $options[self::OSS_QUERY_STRING] : array(); + $temp = array( + self::OSS_LIST_TYPE => 2, + self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL, + self::OSS_DELIMITER => isset($options[self::OSS_DELIMITER]) ? $options[self::OSS_DELIMITER] : '/', + self::OSS_PREFIX => isset($options[self::OSS_PREFIX]) ? $options[self::OSS_PREFIX] : '', + self::OSS_MAX_KEYS => isset($options[self::OSS_MAX_KEYS]) ? $options[self::OSS_MAX_KEYS] : self::OSS_MAX_KEYS_VALUE, + self::OSS_START_AFTER => isset($options[self::OSS_START_AFTER]) ? $options[self::OSS_START_AFTER] : '', + ); + if (isset($options[self::OSS_CONTINUATION_TOKEN])) { + $temp[self::OSS_CONTINUATION_TOKEN] = $options[self::OSS_CONTINUATION_TOKEN]; + } + $options[self::OSS_QUERY_STRING] = array_merge( + $query, $temp + ); + $response = $this->auth($options); + $result = new ListObjectsV2Result($response); + return $result->getData(); + } + + /** + * Lists the bucket's object with version information (in ObjectListInfo) + * + * @param string $bucket + * @param array $options are defined below: + * $options = array( + * 'max-keys' => specifies max object count to return. By default is 100 and max value could be 1000. + * 'prefix' => specifies the key prefix the returned objects must have. Note that the returned keys still contain the prefix. + * 'delimiter' => The delimiter of object name for grouping object. When it's specified, listObjectVersions will differeniate the object and folder. And it will return subfolder's objects. + * 'key-marker' => The key of returned object must be greater than the 'key-marker'. + * 'version-id-marker' => The version id of returned object must be greater than the 'version-id-marker'. + *) + * Prefix and marker are for filtering and paging. Their length must be less than 256 bytes + * @return ObjectVersionListInfo|null + * @throws OssException|RequestCore_Exception + */ + public function listObjectVersions($bucket, $options = NULL) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_SUB_RESOURCE] = 'versions'; + $query = isset($options[self::OSS_QUERY_STRING]) ? $options[self::OSS_QUERY_STRING] : array(); + $options[self::OSS_QUERY_STRING] = array_merge( + $query, + array(self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL, + self::OSS_DELIMITER => isset($options[self::OSS_DELIMITER]) ? $options[self::OSS_DELIMITER] : '/', + self::OSS_PREFIX => isset($options[self::OSS_PREFIX]) ? $options[self::OSS_PREFIX] : '', + self::OSS_MAX_KEYS => isset($options[self::OSS_MAX_KEYS]) ? $options[self::OSS_MAX_KEYS] : self::OSS_MAX_KEYS_VALUE, + self::OSS_KEY_MARKER => isset($options[self::OSS_KEY_MARKER]) ? $options[self::OSS_KEY_MARKER] : '', + self::OSS_VERSION_ID_MARKER => isset($options[self::OSS_VERSION_ID_MARKER]) ? $options[self::OSS_VERSION_ID_MARKER] : '') + ); + + $response = $this->auth($options); + $result = new ListObjectVersionsResult($response); + return $result->getData(); + } + + /** + * Creates a virtual 'folder' in OSS. The name should not end with '/' because the method will append the name with a '/' anyway. + * + * Internal use only. + * + * @param string $bucket bucket name + * @param string $object object name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function createObjectDir($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $object . '/'; + $options[self::OSS_CONTENT_LENGTH] = array(self::OSS_CONTENT_LENGTH => 0); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Uploads the $content object to OSS. + * + * @param string $bucket bucket name + * @param string $object objcet name + * @param string $content The content object + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putObject($bucket, $object, $content, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + + $options[self::OSS_CONTENT] = $content; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $object; + + if (!isset($options[self::OSS_LENGTH])) { + $options[self::OSS_CONTENT_LENGTH] = strlen($options[self::OSS_CONTENT]); + } else { + $options[self::OSS_CONTENT_LENGTH] = $options[self::OSS_LENGTH]; + } + + $is_check_md5 = $this->isCheckMD5($options); + if ($is_check_md5) { + $content_md5 = base64_encode(md5($content, true)); + $options[self::OSS_CONTENT_MD5] = $content_md5; + } + + if (!isset($options[self::OSS_CONTENT_TYPE])) { + $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object); + } + $response = $this->auth($options); + + if (isset($options[self::OSS_CALLBACK]) && !empty($options[self::OSS_CALLBACK])) { + $result = new CallbackResult($response); + } else { + $result = new PutSetDeleteResult($response); + } + + return $result->getData(); + } + + + /** + * creates symlink + * @param string $bucket bucket name + * @param string $symlink symlink name + * @param string $targetObject targetObject name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putSymlink($bucket, $symlink, $targetObject, $options = NULL) + { + $this->precheckCommon($bucket, $symlink, $options); + + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $symlink; + $options[self::OSS_SUB_RESOURCE] = self::OSS_SYMLINK; + $options[self::OSS_HEADERS][self::OSS_SYMLINK_TARGET] = rawurlencode($targetObject); + + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets symlink + * @param string $bucket bucket name + * @param string $symlink symlink name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function getSymlink($bucket, $symlink, $options = NULL) + { + $this->precheckCommon($bucket, $symlink, $options); + + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_OBJECT] = $symlink; + $options[self::OSS_SUB_RESOURCE] = self::OSS_SYMLINK; + + $response = $this->auth($options); + $result = new SymlinkResult($response); + return $result->getData(); + } + + /** + * Uploads a local file + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $file local file path + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function uploadFile($bucket, $object, $file, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + OssUtil::throwOssExceptionWithMessageIfEmpty($file, "file path is invalid"); + $file = $this->encodeFilePath($file); + if (!file_exists($file)) { + throw new OssException($file . " file does not exist"); + } + $options[self::OSS_FILE_UPLOAD] = $file; + $file_size = sprintf('%u', filesize($options[self::OSS_FILE_UPLOAD])); + $is_check_md5 = $this->isCheckMD5($options); + if ($is_check_md5) { + $content_md5 = base64_encode(md5_file($options[self::OSS_FILE_UPLOAD], true)); + $options[self::OSS_CONTENT_MD5] = $content_md5; + } + if (!isset($options[self::OSS_CONTENT_TYPE])) { + $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object, $file); + } + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_CONTENT_LENGTH] = $file_size; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Uploads object from file handle + * + * @param string $bucket bucket name + * @param string $object object name + * @param resource $handle file handle + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function uploadStream($bucket, $object, $handle, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + if (!is_resource($handle)) { + throw new OssException("The handle must be an opened stream"); + } + $options[self::OSS_FILE_UPLOAD] = $handle; + if ($this->isCheckMD5($options)) { + rewind($handle); + $ctx = hash_init('md5'); + hash_update_stream($ctx, $handle); + $content_md5 = base64_encode(hash_final($ctx, true)); + rewind($handle); + $options[self::OSS_CONTENT_MD5] = $content_md5; + } + if (!isset($options[self::OSS_CONTENT_TYPE])) { + $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object); + } + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + if (!isset($options[self::OSS_CONTENT_LENGTH])) { + $stat = fstat($handle); + $options[self::OSS_CONTENT_LENGTH] = $stat[self::OSS_SIZE]; + } + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Append the object with the content at the specified position. + * The specified position is typically the lengh of the current file. + * @param string $bucket bucket name + * @param string $object objcet name + * @param string $content content to append + * @param array $options + * @return int|null next append position + * @throws OssException|RequestCore_Exception + */ + public function appendObject($bucket, $object, $content, $position, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + + $options[self::OSS_CONTENT] = $content; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = 'append'; + $options[self::OSS_POSITION] = strval($position); + if (!isset($options[self::OSS_LENGTH])) { + $options[self::OSS_CONTENT_LENGTH] = strlen($options[self::OSS_CONTENT]); + } else { + $options[self::OSS_CONTENT_LENGTH] = $options[self::OSS_LENGTH]; + } + + $is_check_md5 = $this->isCheckMD5($options); + if ($is_check_md5) { + $content_md5 = base64_encode(md5($content, true)); + $options[self::OSS_CONTENT_MD5] = $content_md5; + } + + if (!isset($options[self::OSS_CONTENT_TYPE])) { + $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object); + } + $response = $this->auth($options); + $result = new AppendResult($response); + return $result->getData(); + } + + /** + * Append the object with a local file + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $file The local file path to append with + * @param array $options + * @return int|null next append position + * @throws OssException|RequestCore_Exception + */ + public function appendFile($bucket, $object, $file, $position, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + + OssUtil::throwOssExceptionWithMessageIfEmpty($file, "file path is invalid"); + $file = $this->encodeFilePath($file); + if (!file_exists($file)) { + throw new OssException($file . " file does not exist"); + } + $options[self::OSS_FILE_UPLOAD] = $file; + $file_size = sprintf('%u', filesize($options[self::OSS_FILE_UPLOAD])); + $is_check_md5 = $this->isCheckMD5($options); + if ($is_check_md5) { + $content_md5 = base64_encode(md5_file($options[self::OSS_FILE_UPLOAD], true)); + $options[self::OSS_CONTENT_MD5] = $content_md5; + } + if (!isset($options[self::OSS_CONTENT_TYPE])) { + $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object, $file); + } + + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_CONTENT_LENGTH] = $file_size; + $options[self::OSS_SUB_RESOURCE] = 'append'; + $options[self::OSS_POSITION] = strval($position); + + $response = $this->auth($options); + $result = new AppendResult($response); + return $result->getData(); + } + + /** + * Copy from an existing OSS object to another OSS object. If the target object exists already, it will be overwritten. + * + * @param string $fromBucket Source bucket name + * @param string $fromObject Source object name + * @param string $toBucket Target bucket name + * @param string $toObject Target object name + * @param array $options + * @return null + * @throws OssException|RequestCore_Exception + */ + public function copyObject($fromBucket, $fromObject, $toBucket, $toObject, $options = NULL) + { + $this->precheckCommon($fromBucket, $fromObject, $options); + $this->precheckCommon($toBucket, $toObject, $options); + $options[self::OSS_BUCKET] = $toBucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $toObject; + $param = '/' . $fromBucket . '/' . rawurlencode($fromObject); + if (isset($options[self::OSS_VERSION_ID])) { + $param = $param . '?versionId=' . $options[self::OSS_VERSION_ID]; + unset($options[self::OSS_VERSION_ID]); + } + $options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE] = $param; + $response = $this->auth($options); + $result = new CopyObjectResult($response); + return $result->getData(); + } + + /** + * Gets Object metadata + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $options Checks out the SDK document for the detail + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function getObjectMeta($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_HEAD; + $options[self::OSS_OBJECT] = $object; + $response = $this->auth($options); + $result = new HeaderResult($response); + return $result->getData(); + } + + /** + * Gets the simplified metadata of a object. + * Simplified metadata includes ETag, Size, LastModified. + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $options Checks out the SDK document for the detail + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function getSimplifiedObjectMeta($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_HEAD; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = 'objectMeta'; + $response = $this->auth($options); + $result = new HeaderResult($response); + return $result->getData(); + } + + /** + * Deletes a object + * + * @param string $bucket bucket name + * @param string $object object name + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function deleteObject($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_OBJECT] = $object; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Deletes multiple objects in a bucket + * + * @param string $bucket bucket name + * @param array $objects object list + * @param array $options + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function deleteObjects($bucket, $objects, $options = null) + { + $this->precheckCommon($bucket, NULL, $options, false); + if (!is_array($objects) || !$objects) { + throw new OssException('objects must be array'); + } + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_SUB_RESOURCE] = 'delete'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $quiet = 'false'; + if (isset($options['quiet'])) { + if (is_bool($options['quiet'])) { //Boolean + $quiet = $options['quiet'] ? 'true' : 'false'; + } elseif (is_string($options['quiet'])) { // string + $quiet = ($options['quiet'] === 'true') ? 'true' : 'false'; + } + } + $xmlBody = OssUtil::createDeleteObjectsXmlBody($objects, $quiet); + $options[self::OSS_CONTENT] = $xmlBody; + $response = $this->auth($options); + $result = new DeleteObjectsResult($response); + return $result->getData(); + } + + /** + * Deletes multiple objects with version id in a bucket + * + * @param string $bucket bucket name + * @param array $objects DeleteObjectInfo list + * @param array $options + * @return DeletedObjectInfo|null + * @throws OssException|RequestCore_Exception + */ + public function deleteObjectVersions($bucket, $objects, $options = null) + { + $this->precheckCommon($bucket, NULL, $options, false); + if (!is_array($objects) || !$objects) { + throw new OssException('objects must be array'); + } + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_SUB_RESOURCE] = 'delete'; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $quiet = 'false'; + if (isset($options['quiet'])) { + if (is_bool($options['quiet'])) { //Boolean + $quiet = $options['quiet'] ? 'true' : 'false'; + } elseif (is_string($options['quiet'])) { // string + $quiet = ($options['quiet'] === 'true') ? 'true' : 'false'; + } + } + $xmlBody = OssUtil::createDeleteObjectVersionsXmlBody($objects, $quiet); + $options[self::OSS_CONTENT] = $xmlBody; + $response = $this->auth($options); + $result = new DeleteObjectVersionsResult($response); + return $result->getData(); + } + + /** + * Gets Object content + * + * @param string $bucket bucket name + * @param string $object object name + * @param array $options It must contain ALIOSS::OSS_FILE_DOWNLOAD. And ALIOSS::OSS_RANGE is optional and empty means to download the whole file. + * @return string|null + * @throws OssException|RequestCore_Exception + */ + public function getObject($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_OBJECT] = $object; + if (isset($options[self::OSS_LAST_MODIFIED])) { + $options[self::OSS_HEADERS][self::OSS_IF_MODIFIED_SINCE] = $options[self::OSS_LAST_MODIFIED]; + unset($options[self::OSS_LAST_MODIFIED]); + } + if (isset($options[self::OSS_ETAG])) { + $options[self::OSS_HEADERS][self::OSS_IF_NONE_MATCH] = $options[self::OSS_ETAG]; + unset($options[self::OSS_ETAG]); + } + if (isset($options[self::OSS_RANGE])) { + $range = $options[self::OSS_RANGE]; + $options[self::OSS_HEADERS][self::OSS_RANGE] = "bytes=$range"; + unset($options[self::OSS_RANGE]); + } + $response = $this->auth($options); + $result = new BodyResult($response); + return $result->getData(); + } + + /** + * Checks if the object exists + * It's implemented by getObjectMeta(). + * + * @param string $bucket bucket name + * @param string $object object name + * @param array $options + * @return bool|null True:object exists; False:object does not exist + * @throws OssException|RequestCore_Exception| + */ + public function doesObjectExist($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_HEAD; + $options[self::OSS_OBJECT] = $object; + $response = $this->auth($options); + $result = new ExistResult($response); + return $result->getData(); + } + + /** + * Object reading for Archive type + * Use Restore to enable the server to perform the thawing task + * + * @param string $bucket bucket name + * @param string $object object name + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function restoreObject($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = self::OSS_RESTORE; + if (isset($options[self::OSS_RESTORE_CONFIG])) { + $config = $options[self::OSS_RESTORE_CONFIG]; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $config->serializeToXml(); + } + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Sets the object tagging + * + * @param string $bucket bucket name + * @param string $object object name + * @param TaggingConfig $taggingConfig + * @return array|null + * @throws OssException|RequestCore_Exception + */ + public function putObjectTagging($bucket, $object, $taggingConfig, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options, true); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + $options[self::OSS_CONTENT] = $taggingConfig->serializeToXml(); + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Gets the object tagging + * + * @param string $bucket + * @param string $object + * @return TaggingConfig|null + * @throws OssException|RequestCore_Exception + */ + public function getObjectTagging($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options, true); + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING; + $response = $this->auth($options); + $result = new GetBucketTagsResult($response); + return $result->getData(); + } + + /** + * Deletes the object tagging + * + * @param string $bucket + * @param string $object + * @return null + * @throws OssException|RequestCore_Exception + */ + public function deleteObjectTagging($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options, true); + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = self::OSS_TAGGING; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Processes the object + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $process process script + * @return string|null process result, json format + * @throws OssException|RequestCore_Exception| + */ + public function processObject($bucket, $object, $process, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = 'x-oss-process'; + $options[self::OSS_CONTENT_TYPE] = 'application/octet-stream'; + $options[self::OSS_CONTENT] = 'x-oss-process=' . $process; + $response = $this->auth($options); + $result = new BodyResult($response); + return $result->getData(); + } + + + /** + * Async Process the object + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $asyncProcess async process script + * @param null $options + * @return string|null process result, json format + * @throws OssException + * @throws RequestCore_Exception + */ + public function asyncProcessObject($bucket, $object, $asyncProcess, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = 'x-oss-async-process'; + $options[self::OSS_CONTENT_TYPE] = 'application/octet-stream'; + $options[self::OSS_CONTENT] = 'x-oss-async-process=' . $asyncProcess; + $response = $this->auth($options); + $result = new BodyResult($response); + return $result->getData(); + } + + /** + * Gets the part size according to the preferred part size. + * If the specified part size is too small or too big, it will return a min part or max part size instead. + * Otherwise returns the specified part size. + * @param int $partSize + * @return int + */ + private function computePartSize($partSize) + { + $partSize = (integer)$partSize; + if ($partSize <= self::OSS_MIN_PART_SIZE) { + $partSize = self::OSS_MIN_PART_SIZE; + } elseif ($partSize > self::OSS_MAX_PART_SIZE) { + $partSize = self::OSS_MAX_PART_SIZE; + } + return $partSize; + } + + /** + * Computes the parts count, size and start position according to the file size and the part size. + * It must be only called by upload_Part(). + * + * @param integer $file_size File size + * @param integer $partSize part size. Default is 5MB + * @return array An array contains key-value pairs--the key is `seekTo`and value is `length`. + */ + public function generateMultiuploadParts($file_size, $partSize = 5242880) + { + $i = 0; + $size_count = $file_size; + $values = array(); + $partSize = $this->computePartSize($partSize); + while ($size_count > 0) { + $size_count -= $partSize; + $values[] = array( + self::OSS_SEEK_TO => ($partSize * $i), + self::OSS_LENGTH => (($size_count > 0) ? $partSize : ($size_count + $partSize)), + ); + $i++; + } + return $values; + } + + /** + * Initialize a multi-part upload + * + * @param string $bucket bucket name + * @param string $object object name + * @param array $options Key-Value array + * @return string|null returns upload id + * @throws OssException|RequestCore_Exception + */ + public function initiateMultipartUpload($bucket, $object, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_SUB_RESOURCE] = 'uploads'; + $options[self::OSS_CONTENT] = ''; + + if (!isset($options[self::OSS_CONTENT_TYPE])) { + $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object); + } + if (!isset($options[self::OSS_HEADERS])) { + $options[self::OSS_HEADERS] = array(); + } + $response = $this->auth($options); + $result = new InitiateMultipartUploadResult($response); + return $result->getData(); + } + + /** + * Upload a part in a multiparts upload. + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $uploadId + * @param array $options Key-Value array + * @return string|null eTag + * @throws OssException|RequestCore_Exception + */ + public function uploadPart($bucket, $object, $uploadId, $options = null) + { + $this->precheckCommon($bucket, $object, $options); + $this->precheckParam($options, self::OSS_FILE_UPLOAD, __FUNCTION__); + $this->precheckParam($options, self::OSS_PART_NUM, __FUNCTION__); + + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_UPLOAD_ID] = $uploadId; + + if (isset($options[self::OSS_LENGTH])) { + $options[self::OSS_CONTENT_LENGTH] = $options[self::OSS_LENGTH]; + } + $response = $this->auth($options); + $result = new UploadPartResult($response); + return $result->getData(); + } + + /** + * Gets the uploaded parts. + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $uploadId uploadId + * @param array $options Key-Value array + * @return ListPartsInfo|null + * @throws OssException|RequestCore_Exception + */ + public function listParts($bucket, $object, $uploadId, $options = null) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_UPLOAD_ID] = $uploadId; + $options[self::OSS_QUERY_STRING] = array(); + foreach (array('max-parts', 'part-number-marker') as $param) { + if (isset($options[$param])) { + $options[self::OSS_QUERY_STRING][$param] = $options[$param]; + unset($options[$param]); + } + } + $response = $this->auth($options); + $result = new ListPartsResult($response); + return $result->getData(); + } + + /** + * Abort a multiparts upload + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $uploadId uploadId + * @param array $options Key-Value name + * @return null + * @throws OssException|RequestCore_Exception + */ + public function abortMultipartUpload($bucket, $object, $uploadId, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_METHOD] = self::OSS_HTTP_DELETE; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_UPLOAD_ID] = $uploadId; + $response = $this->auth($options); + $result = new PutSetDeleteResult($response); + return $result->getData(); + } + + /** + * Completes a multiparts upload, after all parts are uploaded. + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $uploadId uploadId + * @param array $listParts array( array("PartNumber"=> int, "ETag"=>string)) + * @param array $options Key-Value array + * @return null + * @throws OssException|RequestCore_Exception + */ + public function completeMultipartUpload($bucket, $object, $uploadId, $listParts, $options = NULL) + { + $this->precheckCommon($bucket, $object, $options); + $options[self::OSS_METHOD] = self::OSS_HTTP_POST; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_OBJECT] = $object; + $options[self::OSS_UPLOAD_ID] = $uploadId; + $options[self::OSS_CONTENT_TYPE] = 'application/xml'; + if (is_array($listParts)) { + $options[self::OSS_CONTENT] = OssUtil::createCompleteMultipartUploadXmlBody($listParts); + } else { + $options[self::OSS_CONTENT] = ""; + } + + $response = $this->auth($options); + if (isset($options[self::OSS_CALLBACK]) && !empty($options[self::OSS_CALLBACK])) { + $result = new CallbackResult($response); + } else { + $result = new PutSetDeleteResult($response); + } + return $result->getData(); + } + + /** + * Lists all ongoing multipart upload events, which means all initialized but not completed or aborted multipart uploads. + * + * @param string $bucket bucket + * @param array $options key-value array--expected keys are 'delimiter', 'key-marker', 'max-uploads', 'prefix', 'upload-id-marker' + * @return ListMultipartUploadInfo|null + * @throws OssException|RequestCore_Exception + */ + public function listMultipartUploads($bucket, $options = null) + { + $this->precheckCommon($bucket, NULL, $options, false); + $options[self::OSS_METHOD] = self::OSS_HTTP_GET; + $options[self::OSS_BUCKET] = $bucket; + $options[self::OSS_SUB_RESOURCE] = 'uploads'; + + foreach (array('delimiter', 'key-marker', 'max-uploads', 'prefix', 'upload-id-marker') as $param) { + if (isset($options[$param])) { + $options[self::OSS_QUERY_STRING][$param] = $options[$param]; + unset($options[$param]); + } + } + $query = isset($options[self::OSS_QUERY_STRING]) ? $options[self::OSS_QUERY_STRING] : array(); + $options[self::OSS_QUERY_STRING] = array_merge( + $query, + array(self::OSS_ENCODING_TYPE => self::OSS_ENCODING_TYPE_URL) + ); + + $response = $this->auth($options); + $result = new ListMultipartUploadResult($response); + return $result->getData(); + } + + /** + * Copy an existing file as a part + * + * @param string $fromBucket source bucket name + * @param string $fromObject source object name + * @param string $toBucket target bucket name + * @param string $toObject target object name + * @param int $partNumber Part number + * @param string $uploadId Upload Id + * @param array $options Key-Value array---it should have 'start' or 'end' key to specify the range of the source object to copy. If it's not specifed, the whole object is copied. + * @return null + * @throws OssException|RequestCore_Exception + */ + public function uploadPartCopy($fromBucket, $fromObject, $toBucket, $toObject, $partNumber, $uploadId, $options = NULL) + { + $this->precheckCommon($fromBucket, $fromObject, $options); + $this->precheckCommon($toBucket, $toObject, $options); + + //If $options['isFullCopy'] is not set, copy from the beginning + $start_range = "0"; + if (isset($options['start'])) { + $start_range = $options['start']; + } + $end_range = ""; + if (isset($options['end'])) { + $end_range = $options['end']; + } + $options[self::OSS_METHOD] = self::OSS_HTTP_PUT; + $options[self::OSS_BUCKET] = $toBucket; + $options[self::OSS_OBJECT] = $toObject; + $options[self::OSS_PART_NUM] = $partNumber; + $options[self::OSS_UPLOAD_ID] = $uploadId; + + if (!isset($options[self::OSS_HEADERS])) { + $options[self::OSS_HEADERS] = array(); + } + + $param = '/' . $fromBucket . '/' . rawurlencode($fromObject); + if (isset($options[self::OSS_VERSION_ID])) { + $param = $param . '?versionId=' . $options[self::OSS_VERSION_ID]; + unset($options[self::OSS_VERSION_ID]); + } + + $options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE] = $param; + $options[self::OSS_HEADERS][self::OSS_OBJECT_COPY_SOURCE_RANGE] = "bytes=" . $start_range . "-" . $end_range; + $response = $this->auth($options); + $result = new UploadPartResult($response); + return $result->getData(); + } + + /** + * A higher level API for uploading a file with multipart upload. It consists of initialization, parts upload and completion. + * + * @param string $bucket bucket name + * @param string $object object name + * @param string $file The local file to upload + * @param array $options Key-Value array + * @return null + * @throws OssException|RequestCore_Exception + */ + public function multiuploadFile($bucket, $object, $file, $options = null) + { + $this->precheckCommon($bucket, $object, $options); + if (isset($options[self::OSS_LENGTH])) { + $options[self::OSS_CONTENT_LENGTH] = $options[self::OSS_LENGTH]; + unset($options[self::OSS_LENGTH]); + } + if (empty($file)) { + throw new OssException("parameter invalid, file is empty"); + } + $uploadFile = $this->encodeFilePath($file); + if (!isset($options[self::OSS_CONTENT_TYPE])) { + $options[self::OSS_CONTENT_TYPE] = $this->getMimeType($object, $uploadFile); + } + + $upload_position = isset($options[self::OSS_SEEK_TO]) ? (integer)$options[self::OSS_SEEK_TO] : 0; + + if (isset($options[self::OSS_CONTENT_LENGTH])) { + $upload_file_size = (integer)$options[self::OSS_CONTENT_LENGTH]; + } else { + $upload_file_size = sprintf('%u', filesize($uploadFile)); + + if ($upload_file_size !== false) { + $upload_file_size -= $upload_position; + } + } + + if ($upload_position === false || !isset($upload_file_size) || $upload_file_size === false || $upload_file_size < 0) { + throw new OssException('The size of `fileUpload` cannot be determined in ' . __FUNCTION__ . '().'); + } + // Computes the part size and assign it to options. + if (isset($options[self::OSS_PART_SIZE])) { + $options[self::OSS_PART_SIZE] = $this->computePartSize($options[self::OSS_PART_SIZE]); + } else { + $options[self::OSS_PART_SIZE] = self::OSS_MID_PART_SIZE; + } + + $is_check_md5 = $this->isCheckMD5($options); + // if the file size is less than part size, use simple file upload. + if ($upload_file_size < $options[self::OSS_PART_SIZE] && !isset($options[self::OSS_UPLOAD_ID])) { + return $this->uploadFile($bucket, $object, $uploadFile, $options); + } + + // Using multipart upload, initialize if no OSS_UPLOAD_ID is specified in options. + if (isset($options[self::OSS_UPLOAD_ID])) { + $uploadId = $options[self::OSS_UPLOAD_ID]; + } else { + // initialize + $uploadId = $this->initiateMultipartUpload($bucket, $object, $options); + } + + // generates the parts information and upload them one by one + $pieces = $this->generateMultiuploadParts($upload_file_size, (integer)$options[self::OSS_PART_SIZE]); + $response_upload_part = array(); + foreach ($pieces as $i => $piece) { + $from_pos = $upload_position + (integer)$piece[self::OSS_SEEK_TO]; + $to_pos = (integer)$piece[self::OSS_LENGTH] + $from_pos - 1; + $up_options = array( + self::OSS_FILE_UPLOAD => $uploadFile, + self::OSS_PART_NUM => ($i + 1), + self::OSS_SEEK_TO => $from_pos, + self::OSS_LENGTH => $to_pos - $from_pos + 1, + self::OSS_CHECK_MD5 => $is_check_md5, + ); + if ($is_check_md5) { + $content_md5 = OssUtil::getMd5SumForFile($uploadFile, $from_pos, $to_pos); + $up_options[self::OSS_CONTENT_MD5] = $content_md5; + } + $response_upload_part[] = $this->uploadPart($bucket, $object, $uploadId, $up_options); + } + + $uploadParts = array(); + foreach ($response_upload_part as $i => $etag) { + $uploadParts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $etag, + ); + } + + //build complete options + $cmp_options = null; + if (isset($options[self::OSS_HEADERS]) && isset($options[self::OSS_HEADERS][self::OSS_REQUEST_PAYER])) { + $cmp_options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => $options[self::OSS_HEADERS][self::OSS_REQUEST_PAYER], + )); + } + return $this->completeMultipartUpload($bucket, $object, $uploadId, $uploadParts, $cmp_options); + } + + /** + * Uploads the local directory to the specified bucket into specified folder (prefix) + * + * @param string $bucket bucket name + * @param string $prefix The object key prefix. Typically it's folder name. The name should not end with '/' as the API appends it automatically. + * @param string $localDirectory The local directory to upload + * @param string $exclude To excluded directories + * @param bool $recursive Recursive flag. True: Recursively upload all datas under the local directory; False: only upload first layer's files. + * @param bool $checkMd5 + * @return array Returns two list: array("succeededList" => array("object"), "failedList" => array("object"=>"errorMessage")) + * @throws OssException + */ + public function uploadDir($bucket, $prefix, $localDirectory, $exclude = '.|..|.svn|.git', $recursive = false, $checkMd5 = true) + { + $retArray = array("succeededList" => array(), "failedList" => array()); + if (empty($bucket)) throw new OssException("parameter error, bucket is empty"); + if (!is_string($prefix)) throw new OssException("parameter error, prefix is not string"); + if (empty($localDirectory)) throw new OssException("parameter error, localDirectory is empty"); + $directory = $localDirectory; + $directory = $this->encodeFilePath($directory); + //If it's not the local directory, throw OSSException. + if (!is_dir($directory)) { + throw new OssException('parameter error: ' . $directory . ' is not a directory, please check it'); + } + //read directory + $file_list_array = OssUtil::readDir($directory, $exclude, $recursive); + if (!$file_list_array) { + throw new OssException($directory . ' is empty...'); + } + foreach ($file_list_array as $k => $item) { + if (is_dir($item['path'])) { + continue; + } + $options = array( + self::OSS_PART_SIZE => self::OSS_MIN_PART_SIZE, + self::OSS_CHECK_MD5 => $checkMd5, + ); + //mbstring to utf-8 + $fileName = $this->decodeFilePath($item['file']); + $realObject = (!empty($prefix) ? $prefix . '/' : '') . $fileName; + + try { + $this->multiuploadFile($bucket, $realObject, $item['path'], $options); + $retArray["succeededList"][] = $realObject; + } catch (OssException $e) { + $retArray["failedList"][$realObject] = $e->getMessage(); + } + } + return $retArray; + } + + /** + * Sign URL with specified expiration time in seconds (timeout) and HTTP method. + * The signed URL could be used to access the object directly. + * + * @param string $bucket + * @param string $object + * @param int $timeout expiration time in seconds. + * @param string $method + * @param array $options Key-Value array + * @return string + * @throws OssException + */ + public function signUrl($bucket, $object, $timeout = 60, $method = self::OSS_HTTP_GET, $options = NULL) + { + $expiration = time() + $timeout; + return $this->generatePresignedUrl($bucket, $object, $expiration, $method, $options); + } + + /** + * Sign URL with specified expiration time in seconds and HTTP method. + * The signed URL could be used to access the object directly. + * + * @param string $bucket + * @param string $object + * @param int $expiration expiration time of the Url, unix epoch, since 1970.1.1 00.00.00 UTC + * @param string $method + * @param array $options Key-Value array + * @return string + * @throws OssException + */ + public function generatePresignedUrl($bucket, $object, $expiration, $method = self::OSS_HTTP_GET, $options = NULL) + { + $this->precheckObjectExt($object, $this->enableStrictObjName); + $this->precheckCommon($bucket, $object, $options); + $cred = $this->provider->getCredentials(); + //method + if (self::OSS_HTTP_GET !== $method && self::OSS_HTTP_PUT !== $method) { + throw new OssException("method is invalid"); + } + // Should https or http be used? + $scheme = $this->useSSL ? 'https://' : 'http://'; + // gets the host name. If the host name is public domain or private domain, form a third level domain by prefixing the bucket name on the domain name. + $hostname = $this->generateHostname($bucket); + $path = $this->generatePath($bucket, $object); + $headers = $this->generateHeaders($options, ''); + $query_string = $this->generateQueryString($options); + $query_string = empty($query_string) ? '' : '?' . $query_string; + $requestUrl = $scheme . $hostname . $path . $query_string; + //Creates the request + $request = new RequestCore($requestUrl); + $request->set_method($method); + if (isset($options[self::OSS_CALLBACK])) { + $headers[self::OSS_CALLBACK] = base64_encode($options[self::OSS_CALLBACK]); + } + if (isset($options[self::OSS_CALLBACK_VAR])) { + $headers[self::OSS_CALLBACK_VAR] = base64_encode($options[self::OSS_CALLBACK_VAR]); + } + foreach ($headers as $header_key => $header_value) { + $header_value = trim($header_value); + if (empty($header_value)) { + continue; + } + $request->add_header($header_key, $header_value); + } + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => $this->getRegion(), + 'product' => $this->getProduct(), + 'expiration' => $expiration, + ); + $this->signer->presign($request, $cred, $signingOpt); + return $request->request_url; + } + + /** + * validates options. Create a empty array if it's NULL. + * + * @param array $options + * @throws OssException + */ + private function precheckOptions(&$options) + { + OssUtil::validateOptions($options); + if (!$options) { + $options = array(); + } + } + + /** + * Validates bucket parameter + * + * @param string $bucket + * @param string $errMsg + * @throws OssException + */ + private function precheckBucket($bucket, $errMsg = 'bucket is not allowed empty') + { + OssUtil::throwOssExceptionWithMessageIfEmpty($bucket, $errMsg); + if (!OssUtil::validateBucket($bucket)) { + throw new OssException('"' . $bucket . '"' . 'bucket name is invalid'); + } + } + + /** + * validates object parameter + * + * @param string $object + * @throws OssException + */ + private function precheckObject($object) + { + OssUtil::throwOssExceptionWithMessageIfEmpty($object, "object name is empty"); + if (!OssUtil::validateObject($object)) { + throw new OssException('"' . $object . '"' . ' object name is invalid'); + } + } + + /** + * validates object name start with ? or not + * @param $object string + * @param $strict boolean + * @throws OssException + */ + private function precheckObjectExt($object, $strict) + { + $this->precheckObject($object); + if ($strict) { + if (is_string($object) && $object[0] === "?") { + throw new OssException('"' . $object . '"' . ' object name cannot start with `?`'); + } + } + } + + /** + * Check option restore + * + * @param $storage string + * @throws OssException + */ + private function precheckStorage($storage) + { + if (is_string($storage)) { + switch ($storage) { + case self::OSS_STORAGE_ARCHIVE: + return; + case self::OSS_STORAGE_IA: + return; + case self::OSS_STORAGE_STANDARD: + return; + case self::OSS_STORAGE_COLDARCHIVE: + return; + default: + break; + } + } + throw new OssException('storage name is invalid'); + } + + /** + * Validates bucket,options parameters and optionally validate object parameter. + * + * @param string $bucket + * @param string $object + * @param array $options + * @param bool $isCheckObject + */ + private function precheckCommon($bucket, $object, &$options, $isCheckObject = true) + { + if ($isCheckObject) { + $this->precheckObject($object); + } + $this->precheckOptions($options); + $this->precheckBucket($bucket); + } + + /** + * checks parameters + * + * @param array $options + * @param string $param + * @param string $funcName + * @throws OssException + */ + private function precheckParam($options, $param, $funcName) + { + if (!isset($options[$param])) { + throw new OssException('The `' . $param . '` options is required in ' . $funcName . '().'); + } + } + + /** + * Checks md5 + * + * @param array $options + * @return bool|null + */ + private function isCheckMD5($options) + { + return $this->getValue($options, self::OSS_CHECK_MD5, false, true, true); + } + + /** + * Gets value of the specified key from the options + * + * @param array $options + * @param string $key + * @param string $default + * @param bool $isCheckEmpty + * @param bool $isCheckBool + * @return bool|null + */ + private function getValue($options, $key, $default = NULL, $isCheckEmpty = false, $isCheckBool = false) + { + $value = $default; + if (isset($options[$key])) { + if ($isCheckEmpty) { + if (!empty($options[$key])) { + $value = $options[$key]; + } + } else { + $value = $options[$key]; + } + unset($options[$key]); + } + if ($isCheckBool) { + if ($value !== true && $value !== false) { + $value = false; + } + } + return $value; + } + + /** + * Gets mimetype + * + * @param string $object + * @return string + */ + private function getMimeType($object, $file = null) + { + if (!is_null($file)) { + $type = MimeTypes::getMimetype($file); + if (!is_null($type)) { + return $type; + } + } + + $type = MimeTypes::getMimetype($object); + if (!is_null($type)) { + return $type; + } + + return self::DEFAULT_CONTENT_TYPE; + } + + /** + * Validates and executes the request according to OSS API protocol. + * + * @param array $options + * @return ResponseCore|string + * @throws OssException + * @throws RequestCore_Exception + */ + private function auth($options) + { + OssUtil::validateOptions($options); + //Object Encoding + $this->authPrecheckObjectEncoding($options); + //Validates ACL + $this->authPrecheckAcl($options); + $cred = $this->provider->getCredentials(); + $this->checkCredentials($cred); + + $bucket = isset($options[self::OSS_BUCKET]) ? $options[self::OSS_BUCKET] : ''; + $object = isset($options[self::OSS_OBJECT]) ? $options[self::OSS_OBJECT] : ''; + + // Should https or http be used? + $scheme = $this->useSSL ? 'https://' : 'http://'; + // gets the host name. If the host name is public domain or private domain, form a third level domain by prefixing the bucket name on the domain name. + $hostname = $this->generateHostname($bucket); + $path = $this->generatePath($bucket, $object); + $headers = $this->generateHeaders($options, $hostname); + $query_string = $this->generateQueryString($options); + $query_string = empty($query_string) ? '' : '?' . $query_string; + $requestUrl = $scheme . $hostname . $path . $query_string; + + //Creates the request + $request = new RequestCore($requestUrl, $this->requestProxy); + $request->set_useragent($this->generateUserAgent()); + // Streaming uploads + if (isset($options[self::OSS_FILE_UPLOAD])) { + if (is_resource($options[self::OSS_FILE_UPLOAD])) { + $length = null; + + if (isset($options[self::OSS_CONTENT_LENGTH])) { + $length = $options[self::OSS_CONTENT_LENGTH]; + } elseif (isset($options[self::OSS_SEEK_TO])) { + $stats = fstat($options[self::OSS_FILE_UPLOAD]); + if ($stats && $stats[self::OSS_SIZE] >= 0) { + $length = $stats[self::OSS_SIZE] - (integer)$options[self::OSS_SEEK_TO]; + } + } + $request->set_read_stream($options[self::OSS_FILE_UPLOAD], $length); + } else { + $request->set_read_file($options[self::OSS_FILE_UPLOAD]); + $length = $request->read_stream_size; + if (isset($options[self::OSS_CONTENT_LENGTH])) { + $length = $options[self::OSS_CONTENT_LENGTH]; + } elseif (isset($options[self::OSS_SEEK_TO]) && isset($length)) { + $length -= (integer)$options[self::OSS_SEEK_TO]; + } + $request->set_read_stream_size($length); + } + } + if (isset($options[self::OSS_SEEK_TO])) { + $request->set_seek_position((integer)$options[self::OSS_SEEK_TO]); + } + if (isset($options[self::OSS_FILE_DOWNLOAD])) { + if (is_resource($options[self::OSS_FILE_DOWNLOAD])) { + $request->set_write_stream($options[self::OSS_FILE_DOWNLOAD]); + } else { + $request->set_write_file($options[self::OSS_FILE_DOWNLOAD]); + } + } + if (isset($options[self::OSS_METHOD])) { + $request->set_method($options[self::OSS_METHOD]); + } + if (isset($options[self::OSS_CONTENT])) { + $request->set_body($options[self::OSS_CONTENT]); + if (isset($headers[self::OSS_CONTENT_TYPE]) && $headers[self::OSS_CONTENT_TYPE] === 'application/x-www-form-urlencoded') { + $headers[self::OSS_CONTENT_TYPE] = 'application/octet-stream'; + } + + $headers[self::OSS_CONTENT_LENGTH] = strlen($options[self::OSS_CONTENT]); + $headers[self::OSS_CONTENT_MD5] = base64_encode(md5($options[self::OSS_CONTENT], true)); + } + + if (isset($options[self::OSS_CALLBACK])) { + $headers[self::OSS_CALLBACK] = base64_encode($options[self::OSS_CALLBACK]); + } + if (isset($options[self::OSS_CALLBACK_VAR])) { + $headers[self::OSS_CALLBACK_VAR] = base64_encode($options[self::OSS_CALLBACK_VAR]); + } + + if (!isset($headers[self::OSS_ACCEPT_ENCODING])) { + $headers[self::OSS_ACCEPT_ENCODING] = ''; + } + + if (!isset($headers[self::OSS_CONTENT_TYPE])) { + $headers[self::OSS_CONTENT_TYPE] = self::DEFAULT_CONTENT_TYPE; + } + + foreach ($headers as $header_key => $header_value) { + $header_value = trim($header_value); + if (empty($header_value)) { + continue; + } + $request->add_header($header_key, $header_value); + } + + // sign request + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => $this->getRegion(), + 'product' => $this->getProduct(), + ); + if (isset($options[self::OSS_ADDITIONAL_HEADERS])) { + $signingOpt['additionalHeaders'] = $options[self::OSS_ADDITIONAL_HEADERS]; + } + + $this->signer->sign($request, $cred, $signingOpt); + $string_to_sign = isset($signingOpt['string_to_sign']) ? $signingOpt['string_to_sign'] : ''; + + if ($this->timeout !== 0) { + $request->timeout = $this->timeout; + } + if ($this->connectTimeout !== 0) { + $request->connect_timeout = $this->connectTimeout; + } + + try { + $request->send_request(); + } catch (RequestCore_Exception $e) { + throw(new OssException('RequestCoreException: ' . $e->getMessage())); + } + $response_header = $request->get_response_header(); + $response_header['oss-request-url'] = $requestUrl; + $response_header['oss-redirects'] = $this->redirects; + $response_header['oss-stringtosign'] = $string_to_sign; + $response_header['oss-requestheaders'] = $request->request_headers; + + $data = new ResponseCore($response_header, $request->get_response_body(), $request->get_response_code()); + //retry if OSS Internal Error + if ((integer)$request->get_response_code() === 500) { + if ($this->redirects <= $this->maxRetries) { + //Sets the sleep time betwen each retry. + $delay = (integer)(pow(4, $this->redirects) * 100000); + usleep($delay); + $this->redirects++; + $data = $this->auth($options); + } + } + + $this->redirects = 0; + return $data; + } + + /** + * Sets the max retry count + * + * @param int $maxRetries + * @return void + */ + public function setMaxTries($maxRetries = 3) + { + $this->maxRetries = $maxRetries; + } + + /** + * Gets the max retry count + * + * @return int + */ + public function getMaxRetries() + { + return $this->maxRetries; + } + + /** + * Enaable/disable STS in the URL. This is to determine the $sts value passed from constructor take effect or not. + * + * @param boolean $enable + */ + public function setSignStsInUrl($enable) + { + } + + /** + * @return boolean + */ + public function isUseSSL() + { + return $this->useSSL; + } + + /** + * @param boolean $useSSL + */ + public function setUseSSL($useSSL) + { + $this->useSSL = $useSSL; + } + + /** + * Checks the object's encoding. Convert it to UTF8 if it's in GBK or GB2312 + * + * @param mixed $options parameter + */ + private function authPrecheckObjectEncoding(&$options) + { + if ($this->checkObjectEncoding !== true) { + return; + } + + if (!isset($options[self::OSS_OBJECT])) { + return; + } + + try { + $tmp_object = $options[self::OSS_OBJECT]; + $encoding = array('UTF-8', 'GB2312', 'GBK'); + $encode = mb_detect_encoding($tmp_object, $encoding); + if ($encode === 'UTF-8' || $encode === false) { + return; + } + $tmp_object = iconv($encode, "UTF-8", $tmp_object); + if ($tmp_object === false) { + return; + } + $options[self::OSS_OBJECT] = $tmp_object; + } catch (\Exception $e) { + //IGNORE + } + } + + /** + * Checks if the ACL is one of the 3 predefined one. Throw OSSException if not. + * + * @param $options + * @throws OssException + */ + private function authPrecheckAcl($options) + { + if (isset($options[self::OSS_HEADERS][self::OSS_ACL]) && !empty($options[self::OSS_HEADERS][self::OSS_ACL])) { + if (!in_array(strtolower($options[self::OSS_HEADERS][self::OSS_ACL]), self::$OSS_ACL_TYPES)) { + throw new OssException($options[self::OSS_HEADERS][self::OSS_ACL] . ':' . 'acl is invalid(private,public-read,public-read-write)'); + } + } + } + + /** + * Gets the host name for the current request. + * It could be either a third level domain (prefixed by bucket name) or second level domain if it's CName or IP + * + * @param $bucket + * @return string The host name without the protocol scheem (e.g. https://) + */ + private function generateHostname($bucket) + { + if ($this->hostType === self::OSS_HOST_TYPE_IP || $this->hostType === self::OSS_HOST_TYPE_PATH_STYLE) { + $hostname = $this->hostname; + } elseif ($this->hostType === self::OSS_HOST_TYPE_CNAME) { + $hostname = $this->hostname; + } else { + // Private domain or public domain + $hostname = ($bucket == '') ? $this->hostname : ($bucket . '.') . $this->hostname; + } + return $hostname; + } + + /** + * Gets the Uri path in the current request + * + * @param $bucket + * @param $object + * @return string return the resource uri. + */ + private function generatePath($bucket, $object) + { + $paths = array(); + // +bucket + if ('' !== $bucket) { + if ($this->hostType === self::OSS_HOST_TYPE_IP || $this->hostType === self::OSS_HOST_TYPE_PATH_STYLE) { + $paths[] = $bucket; + if ('' === $object) { + $paths[] = ''; + } + } + } + // + object + if ('' !== $object && '/' !== $object) { + $paths[] = str_replace(array('%2F'), array('/'), rawurlencode($object)); + } + return '/' . implode('/', $paths); + } + + /** + * generates query string + * + * @param mixed $options + * @return string + */ + private function generateQueryString($options) + { + //query parameters + $query = array(); + $queryList = array( + self::OSS_PART_NUM, + 'response-content-type', + 'response-content-language', + 'response-cache-control', + 'response-content-encoding', + 'response-expires', + 'response-content-disposition', + self::OSS_UPLOAD_ID, + self::OSS_COMP, + self::OSS_LIVE_CHANNEL_STATUS, + self::OSS_LIVE_CHANNEL_START_TIME, + self::OSS_LIVE_CHANNEL_END_TIME, + self::OSS_PROCESS, + self::OSS_POSITION, + self::OSS_SYMLINK, + self::OSS_RESTORE, + self::OSS_TAGGING, + self::OSS_WORM_ID, + self::OSS_TRAFFIC_LIMIT, + self::OSS_VERSION_ID, + self::OSS_CONTINUATION_TOKEN, + self::OSS_CNAME, + ); + foreach ($queryList as $item) { + if (isset($options[$item])) { + $query[$item] = $options[$item]; + } + } + if (isset($options[self::OSS_QUERY_STRING])) { + $query = array_merge($query, $options[self::OSS_QUERY_STRING]); + } + if (isset($options[self::OSS_SUB_RESOURCE])) { + $query[$options[self::OSS_SUB_RESOURCE]] = ''; + } + + return OssUtil::toQueryString($query); + } + + /** + * Initialize headers + * + * @param mixed $options + * @param string $hostname hostname + * @return array + */ + private function generateHeaders($options, $hostname) + { + $headers = array(); + + if (!empty($hostname)) { + $headers[self::OSS_HOST] = $hostname; + } + + if (isset($options[self::OSS_CONTENT_TYPE])) { + $headers[self::OSS_CONTENT_TYPE] = $options[self::OSS_CONTENT_TYPE]; + } + + if (isset($options[self::OSS_DATE])) { + $headers[self::OSS_DATE] = $options[self::OSS_DATE]; + } + + if (isset($options[self::OSS_CONTENT_MD5])) { + $headers[self::OSS_CONTENT_MD5] = $options[self::OSS_CONTENT_MD5]; + } + + //Merge HTTP headers + if (isset($options[self::OSS_HEADERS])) { + $headers = array_merge($headers, $options[self::OSS_HEADERS]); + } + return $headers; + } + + /** + * Generates UserAgent + * + * @return string + */ + private function generateUserAgent() + { + return self::OSS_NAME . "/" . self::OSS_VERSION . " (" . php_uname('s') . "/" . php_uname('r') . "/" . php_uname('m') . ";" . PHP_VERSION . ")"; + } + + /** + * Checks endpoint type and returns the endpoint without the protocol schema. + * Figures out the domain's type (ip, cname or private/public domain). + * + * @param string $endpoint + * @param boolean $isCName + * @return string The domain name without the protocol schema. + * @throws OssException + */ + private function checkEndpoint($endpoint, $isCName) + { + $ret_endpoint = null; + if (strpos($endpoint, 'http://') === 0) { + $ret_endpoint = substr($endpoint, strlen('http://')); + } elseif (strpos($endpoint, 'https://') === 0) { + $ret_endpoint = substr($endpoint, strlen('https://')); + $this->useSSL = true; + } else { + $ret_endpoint = $endpoint; + } + + $ret_endpoint = OssUtil::getHostPortFromEndpoint($ret_endpoint); + + if ($isCName) { + $this->hostType = self::OSS_HOST_TYPE_CNAME; + } elseif (OssUtil::isIPFormat($ret_endpoint)) { + $this->hostType = self::OSS_HOST_TYPE_IP; + } else { + $this->hostType = self::OSS_HOST_TYPE_NORMAL; + } + return $ret_endpoint; + } + + /** + * @param Credentials $credential + * @throws OssException + */ + private function checkCredentials($credential) + { + if (empty($credential)) { + throw new OssException("credentials is empty."); + } + if (strlen($credential->getAccessKeyId()) == 0) { + throw new OssException("access key id is empty"); + } + if (strlen($credential->getAccessKeySecret()) == 0) { + throw new OssException("access key secret is empty"); + } + } + + /** + * For get Sign Product + * @return string + */ + private function getProduct() + { + if (!empty($this->cloudBoxId)) { + return self::OSS_CLOUDBOX_PRODUCT; + } + return self::OSS_DEFAULT_PRODUCT; + } + + /** + * For get Sign Region + * @return mixed + */ + private function getRegion() + { + if (!empty($this->cloudBoxId)) { + return $this->cloudBoxId; + } + return $this->region; + } + + /** + * Encodes the file path from UTF-8 to GBK. + * + * @param $filepath + * @return string + */ + private function encodeFilePath($filepath) + { + if ($this->filePathCompatible !== true) { + return $filepath; + } + + if (empty($filepath)) { + return $filepath; + } + + try { + $encoding = array('UTF-8', 'GB2312', 'GBK'); + $encode = mb_detect_encoding($filepath, $encoding); + if ($encode !== 'UTF-8') { + return $filepath; + } + $tmp = iconv($encode, 'GBK', $filepath); + if ($tmp !== false) { + $filepath = $tmp; + } + } catch (\Exception $e) { + //IGNORE + } + return $filepath; + } + + /** + * Decodes the file path from GBK to UTF-8. + * + * @param $filepath + * @return string + */ + private function decodeFilePath($filepath) + { + if ($this->filePathCompatible !== true) { + return $filepath; + } + if (empty($filepath)) { + return $filepath; + } + + try { + $encoding = array('UTF-8', 'GB2312', 'GBK'); + $encode = mb_detect_encoding($filepath, $encoding); + if ($encode === 'UTF-8' || $encode === false) { + return $filepath; + } + $tmp = iconv($encode, 'UTF-8', $filepath); + if ($tmp !== false) { + $filepath = $tmp; + } + } catch (\Exception $e) { + //IGNORE + } + return $filepath; + } + + /** + * Check if all dependent extensions are installed correctly. + * For now only "curl" is needed. + * @throws OssException + */ + public static function checkEnv() + { + if (function_exists('get_loaded_extensions')) { + //Test curl extension + $enabled_extension = array("curl"); + $extensions = get_loaded_extensions(); + if ($extensions) { + foreach ($enabled_extension as $item) { + if (!in_array($item, $extensions)) { + throw new OssException("Extension {" . $item . "} is not installed or not enabled, please check your php env."); + } + } + } else { + throw new OssException("function get_loaded_extensions not found."); + } + } else { + throw new OssException('Function get_loaded_extensions has been disabled, please check php config.'); + } + } + + /** + * Sets the http's timeout (in seconds) + * + * @param int $timeout + */ + public function setTimeout($timeout) + { + $this->timeout = $timeout; + } + + /** + * Sets the http's connection timeout (in seconds) + * + * @param int $connectTimeout + */ + public function setConnectTimeout($connectTimeout) + { + $this->connectTimeout = $connectTimeout; + } + + // Constants for Life cycle + const OSS_LIFECYCLE_EXPIRATION = "Expiration"; + const OSS_LIFECYCLE_TIMING_DAYS = "Days"; + const OSS_LIFECYCLE_TIMING_DATE = "Date"; + //OSS Internal constants + const OSS_BUCKET = 'bucket'; + const OSS_OBJECT = 'object'; + const OSS_HEADERS = OssUtil::OSS_HEADERS; + const OSS_ADDITIONAL_HEADERS = 'additionalHeaders'; + const OSS_METHOD = 'method'; + const OSS_QUERY = 'query'; + const OSS_BASENAME = 'basename'; + const OSS_MAX_KEYS = 'max-keys'; + const OSS_UPLOAD_ID = 'uploadId'; + const OSS_PART_NUM = 'partNumber'; + const OSS_COMP = 'comp'; + const OSS_LIVE_CHANNEL_STATUS = 'status'; + const OSS_LIVE_CHANNEL_START_TIME = 'startTime'; + const OSS_LIVE_CHANNEL_END_TIME = 'endTime'; + const OSS_POSITION = 'position'; + const OSS_MAX_KEYS_VALUE = 100; + const OSS_MAX_OBJECT_GROUP_VALUE = OssUtil::OSS_MAX_OBJECT_GROUP_VALUE; + const OSS_MAX_PART_SIZE = OssUtil::OSS_MAX_PART_SIZE; + const OSS_MID_PART_SIZE = OssUtil::OSS_MID_PART_SIZE; + const OSS_MIN_PART_SIZE = OssUtil::OSS_MIN_PART_SIZE; + const OSS_FILE_SLICE_SIZE = 8192; + const OSS_PREFIX = 'prefix'; + const OSS_DELIMITER = 'delimiter'; + const OSS_MARKER = 'marker'; + const OSS_FETCH_OWNER = 'fetch-owner'; + const OSS_START_AFTER = 'start-after'; + const OSS_CONTINUATION_TOKEN = 'continuation-token'; + const OSS_ACCEPT_ENCODING = 'Accept-Encoding'; + const OSS_CONTENT_MD5 = 'Content-Md5'; + const OSS_SELF_CONTENT_MD5 = 'x-oss-meta-md5'; + const OSS_CONTENT_TYPE = 'Content-Type'; + const OSS_CONTENT_LENGTH = 'Content-Length'; + const OSS_IF_MODIFIED_SINCE = 'If-Modified-Since'; + const OSS_IF_UNMODIFIED_SINCE = 'If-Unmodified-Since'; + const OSS_IF_MATCH = 'If-Match'; + const OSS_IF_NONE_MATCH = 'If-None-Match'; + const OSS_CACHE_CONTROL = 'Cache-Control'; + const OSS_EXPIRES = 'Expires'; + + const OSS_CONTENT_COING = 'Content-Coding'; + const OSS_CONTENT_DISPOSTION = 'Content-Disposition'; + const OSS_RANGE = 'range'; + const OSS_ETAG = 'etag'; + const OSS_LAST_MODIFIED = 'lastmodified'; + const OS_CONTENT_RANGE = 'Content-Range'; + const OSS_CONTENT = OssUtil::OSS_CONTENT; + const OSS_BODY = 'body'; + const OSS_LENGTH = OssUtil::OSS_LENGTH; + const OSS_HOST = 'Host'; + const OSS_DATE = 'Date'; + const OSS_AUTHORIZATION = 'Authorization'; + const OSS_FILE_DOWNLOAD = 'fileDownload'; + const OSS_FILE_UPLOAD = 'fileUpload'; + const OSS_PART_SIZE = 'partSize'; + const OSS_SEEK_TO = 'seekTo'; + const OSS_SIZE = 'size'; + const OSS_QUERY_STRING = 'query_string'; + const OSS_SUB_RESOURCE = 'sub_resource'; + const OSS_DEFAULT_PREFIX = 'x-oss-'; + const OSS_CHECK_MD5 = 'checkmd5'; + const OSS_CHECK_OBJECT = 'checkobject'; + const DEFAULT_CONTENT_TYPE = 'application/octet-stream'; + const OSS_SYMLINK_TARGET = 'x-oss-symlink-target'; + const OSS_SYMLINK = 'symlink'; + const OSS_HTTP_CODE = 'http_code'; + const OSS_REQUEST_ID = 'x-oss-request-id'; + const OSS_INFO = 'info'; + const OSS_STORAGE = 'storage'; + const OSS_RESTORE = 'restore'; + const OSS_STORAGE_STANDARD = 'Standard'; + const OSS_STORAGE_IA = 'IA'; + const OSS_STORAGE_ARCHIVE = 'Archive'; + const OSS_STORAGE_COLDARCHIVE = 'ColdArchive'; + const OSS_TAGGING = 'tagging'; + const OSS_WORM_ID = 'wormId'; + const OSS_RESTORE_CONFIG = 'restore-config'; + const OSS_KEY_MARKER = 'key-marker'; + const OSS_VERSION_ID_MARKER = 'version-id-marker'; + const OSS_VERSION_ID = 'versionId'; + const OSS_HEADER_VERSION_ID = 'x-oss-version-id'; + const OSS_CNAME = 'cname'; + + //private URLs + const OSS_URL_ACCESS_KEY_ID = 'OSSAccessKeyId'; + const OSS_URL_EXPIRES = 'Expires'; + const OSS_URL_SIGNATURE = 'Signature'; + //HTTP METHOD + const OSS_HTTP_GET = 'GET'; + const OSS_HTTP_PUT = 'PUT'; + const OSS_HTTP_HEAD = 'HEAD'; + const OSS_HTTP_POST = 'POST'; + const OSS_HTTP_DELETE = 'DELETE'; + const OSS_HTTP_OPTIONS = 'OPTIONS'; + //Others + const OSS_ACL = 'x-oss-acl'; + const OSS_OBJECT_ACL = 'x-oss-object-acl'; + const OSS_OBJECT_GROUP = 'x-oss-file-group'; + const OSS_MULTI_PART = 'uploads'; + const OSS_MULTI_DELETE = 'delete'; + const OSS_OBJECT_COPY_SOURCE = 'x-oss-copy-source'; + const OSS_OBJECT_COPY_SOURCE_RANGE = "x-oss-copy-source-range"; + const OSS_PROCESS = "x-oss-process"; + const OSS_CALLBACK = "x-oss-callback"; + const OSS_CALLBACK_VAR = "x-oss-callback-var"; + const OSS_REQUEST_PAYER = "x-oss-request-payer"; + const OSS_TRAFFIC_LIMIT = "x-oss-traffic-limit"; + //Constants for STS SecurityToken + const OSS_SECURITY_TOKEN = "x-oss-security-token"; + const OSS_ACL_TYPE_PRIVATE = 'private'; + const OSS_ACL_TYPE_PUBLIC_READ = 'public-read'; + const OSS_ACL_TYPE_PUBLIC_READ_WRITE = 'public-read-write'; + const OSS_ENCODING_TYPE = "encoding-type"; + const OSS_ENCODING_TYPE_URL = "url"; + + const OSS_LIST_TYPE = "list-type"; + + // Domain Types + const OSS_HOST_TYPE_NORMAL = "normal";//http://bucket.oss-cn-hangzhou.aliyuncs.com/object + const OSS_HOST_TYPE_IP = "ip"; //http://1.1.1.1/bucket/object + const OSS_HOST_TYPE_SPECIAL = 'special'; //http://bucket.guizhou.gov/object + const OSS_HOST_TYPE_CNAME = "cname"; //http://mydomain.com/object + const OSS_HOST_TYPE_PATH_STYLE = "path-style"; //http://oss-cn-hangzhou.aliyuncs.com/bucket/object + //OSS ACL array + static $OSS_ACL_TYPES = array( + self::OSS_ACL_TYPE_PRIVATE, + self::OSS_ACL_TYPE_PUBLIC_READ, + self::OSS_ACL_TYPE_PUBLIC_READ_WRITE + ); + // OssClient version information + const OSS_NAME = "aliyun-sdk-php"; + const OSS_VERSION = "2.7.2"; + const OSS_BUILD = "20241028"; + const OSS_AUTHOR = ""; + const OSS_OPTIONS_ORIGIN = 'Origin'; + const OSS_OPTIONS_REQUEST_METHOD = 'Access-Control-Request-Method'; + const OSS_OPTIONS_REQUEST_HEADERS = 'Access-Control-Request-Headers'; + + // signatrue version information + const OSS_SIGNATURE_VERSION_V1 = "v1"; + const OSS_SIGNATURE_VERSION_V4 = "v4"; + const OSS_DEFAULT_PRODUCT = "oss"; + const OSS_CLOUDBOX_PRODUCT = "oss-cloudbox"; + + //use ssl flag + private $useSSL = false; + private $maxRetries = 3; + private $redirects = 0; + + // user's domain type. It could be one of the four: OSS_HOST_TYPE_NORMAL, OSS_HOST_TYPE_IP, OSS_HOST_TYPE_SPECIAL, OSS_HOST_TYPE_CNAME + private $hostType = self::OSS_HOST_TYPE_NORMAL; + private $requestProxy = null; + /** + * @var CredentialsProvider + */ + private $provider; + private $hostname; + private $enableStrictObjName; + private $timeout = 0; + private $connectTimeout = 0; + private $cloudBoxId = null; + private $region = null; + /** + * @var SignerV1|SignerV4 + */ + private $signer; + + private $checkObjectEncoding = false; + + private $filePathCompatible; +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php new file mode 100644 index 0000000..7061ff0 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AclResult.php @@ -0,0 +1,31 @@ +rawResponse->body; + if (empty($content)) { + throw new OssException("body is null"); + } + $xml = simplexml_load_string($content); + if (isset($xml->AccessControlList->Grant)) { + return strval($xml->AccessControlList->Grant); + } else { + throw new OssException("xml format exception"); + } + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AppendResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AppendResult.php new file mode 100644 index 0000000..d898d58 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/AppendResult.php @@ -0,0 +1,27 @@ +rawResponse->header; + if (isset($header["x-oss-next-append-position"])) { + return intval($header["x-oss-next-append-position"]); + } + throw new OssException("cannot get next-append-position"); + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/BodyResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/BodyResult.php new file mode 100644 index 0000000..44ba15e --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/BodyResult.php @@ -0,0 +1,19 @@ +rawResponse->body) ? "" : $this->rawResponse->body; + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CallbackResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CallbackResult.php new file mode 100644 index 0000000..514e985 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CallbackResult.php @@ -0,0 +1,21 @@ +rawResponse->status; + if ((int)(intval($status) / 100) == 2 && (int)(intval($status)) !== 203) { + return true; + } + return false; + } + +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CopyObjectResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CopyObjectResult.php new file mode 100644 index 0000000..6ed67c6 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CopyObjectResult.php @@ -0,0 +1,30 @@ +rawResponse->body; + $xml = simplexml_load_string($body); + $result = array(); + + if (isset($xml->LastModified)) { + $result[] = $xml->LastModified; + } + if (isset($xml->ETag)) { + $result[] = $xml->ETag; + } + + return array_merge($result, $this->rawResponse->header); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CreateBucketCnameTokenResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CreateBucketCnameTokenResult.php new file mode 100644 index 0000000..a38ca0d --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/CreateBucketCnameTokenResult.php @@ -0,0 +1,19 @@ +rawResponse->body; + $info = new CnameTokenInfo(); + $info->parseFromXml($content); + return $info; + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectVersionsResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectVersionsResult.php new file mode 100644 index 0000000..69f52a7 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectVersionsResult.php @@ -0,0 +1,39 @@ +rawResponse->body); + $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; + return $this->parseDeletedList($xml, $encodingType); + } + + private function parseDeletedList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->Deleted)) { + foreach ($xml->Deleted as $content) { + $key = isset($content->Key) ? strval($content->Key) : ""; + $key = OssUtil::decodeKey($key, $encodingType); + $versionId = isset($content->VersionId) ? strval($content->VersionId) : ""; + $deleteMarker = isset($content->DeleteMarker) ? strval($content->DeleteMarker) : ""; + $deleteMarkerVersionId = isset($content->DeleteMarkerVersionId) ? strval($content->DeleteMarkerVersionId) : ""; + $retList[] = new DeletedObjectInfo($key, $versionId, $deleteMarker, $deleteMarkerVersionId); + } + } + return $retList; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectsResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectsResult.php new file mode 100644 index 0000000..dc373b8 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/DeleteObjectsResult.php @@ -0,0 +1,27 @@ +rawResponse->body; + $xml = simplexml_load_string($body); + $objects = array(); + + if (isset($xml->Deleted)) { + foreach($xml->Deleted as $deleteKey) + $objects[] = $deleteKey->Key; + } + return $objects; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php new file mode 100644 index 0000000..e9522d4 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ExistResult.php @@ -0,0 +1,34 @@ +rawResponse->status) === 200 ? true : false; + } + + /** + * Check if the response status is OK according to the http status code. + * [200-299]: OK; [404]: Not found. It means the object or bucket is not found--it's a valid response too. + * + * @return bool + */ + protected function isResponseOk() + { + $status = $this->rawResponse->status; + if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { + return true; + } + return false; + } + +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketCnameTokenResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketCnameTokenResult.php new file mode 100644 index 0000000..b524d3f --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketCnameTokenResult.php @@ -0,0 +1,19 @@ +rawResponse->body; + $info = new CnameTokenInfo(); + $info->parseFromXml($content); + return $info; + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketEncryptionResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketEncryptionResult.php new file mode 100644 index 0000000..3987cc9 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketEncryptionResult.php @@ -0,0 +1,26 @@ +rawResponse->body; + $config = new ServerSideEncryptionConfig(); + $config->parseFromXml($content); + return $config; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketInfoResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketInfoResult.php new file mode 100644 index 0000000..d467851 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketInfoResult.php @@ -0,0 +1,37 @@ +rawResponse->body; + if (empty($content)) { + throw new OssException("body is null"); + } + $xml = simplexml_load_string($content); + if (isset($xml->Bucket)) { + $info = new BucketInfo(); + $info->parseFromXmlNode($xml->Bucket); + return $info; + } else { + throw new OssException("xml format exception"); + } + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketRequestPaymentResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketRequestPaymentResult.php new file mode 100644 index 0000000..5107de3 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketRequestPaymentResult.php @@ -0,0 +1,26 @@ +rawResponse->body; + $config = new RequestPaymentConfig(); + $config->parseFromXml($content); + return $config->getPayer(); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketStatResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketStatResult.php new file mode 100644 index 0000000..aa310cf --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketStatResult.php @@ -0,0 +1,26 @@ +rawResponse->body; + $stat = new BucketStat(); + $stat->parseFromXml($content); + return $stat; + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTagsResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTagsResult.php new file mode 100644 index 0000000..59b4dd7 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTagsResult.php @@ -0,0 +1,26 @@ +rawResponse->body; + $config = new TaggingConfig(); + $config->parseFromXml($content); + return $config; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTransferAccelerationResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTransferAccelerationResult.php new file mode 100644 index 0000000..a300d62 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketTransferAccelerationResult.php @@ -0,0 +1,22 @@ +rawResponse->body; + $config = new TransferAccelerationConfig(); + $config->parseFromXml($content); + return $config->getEnabled(); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketVersioningResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketVersioningResult.php new file mode 100644 index 0000000..225190c --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketVersioningResult.php @@ -0,0 +1,26 @@ +rawResponse->body; + $config = new VersioningConfig(); + $config->parseFromXml($content); + return $config->getStatus(); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketWormResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketWormResult.php new file mode 100644 index 0000000..9587204 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetBucketWormResult.php @@ -0,0 +1,26 @@ +rawResponse->body; + $config = new WormConfig(); + $config->parseFromXml($content); + return $config; + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCnameResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCnameResult.php new file mode 100644 index 0000000..eed01f9 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCnameResult.php @@ -0,0 +1,19 @@ +rawResponse->body; + $config = new CnameConfig(); + $config->parseFromXml($content); + return $config; + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php new file mode 100644 index 0000000..8fb10ea --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetCorsResult.php @@ -0,0 +1,34 @@ +rawResponse->body; + $config = new CorsConfig(); + $config->parseFromXml($content); + return $config; + } + + /** + * Check if the response is OK, according to the http status. [200-299]:OK, the Cors config could be got; [404]: not found--no Cors config. + * + * @return bool + */ + protected function isResponseOk() + { + $status = $this->rawResponse->status; + if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { + return true; + } + return false; + } + +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php new file mode 100644 index 0000000..e0a9595 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLifecycleResult.php @@ -0,0 +1,41 @@ +rawResponse->body; + $config = new LifecycleConfig(); + $config->parseFromXml($content); + return $config; + } + + /** + * Check if the response is OK according to the http status. + * [200-299]: OK, and the LifecycleConfig could be got; [404] The Life cycle config is not found. + * + * @return bool + */ + protected function isResponseOk() + { + $status = $this->rawResponse->status; + if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { + return true; + } + return false; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelHistoryResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelHistoryResult.php new file mode 100644 index 0000000..5d5bc92 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelHistoryResult.php @@ -0,0 +1,19 @@ +rawResponse->body; + $channelList = new GetLiveChannelHistory(); + $channelList->parseFromXml($content); + return $channelList; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelInfoResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelInfoResult.php new file mode 100644 index 0000000..cefe460 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelInfoResult.php @@ -0,0 +1,19 @@ +rawResponse->body; + $channelList = new GetLiveChannelInfo(); + $channelList->parseFromXml($content); + return $channelList; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelStatusResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelStatusResult.php new file mode 100644 index 0000000..6b8a60f --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLiveChannelStatusResult.php @@ -0,0 +1,19 @@ +rawResponse->body; + $channelList = new GetLiveChannelStatus(); + $channelList->parseFromXml($content); + return $channelList; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLocationResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLocationResult.php new file mode 100644 index 0000000..a0c5129 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLocationResult.php @@ -0,0 +1,30 @@ +rawResponse->body; + if (empty($content)) { + throw new OssException("body is null"); + } + $xml = simplexml_load_string($content); + return $xml; + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLoggingResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLoggingResult.php new file mode 100644 index 0000000..eab8c64 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetLoggingResult.php @@ -0,0 +1,41 @@ +rawResponse->body; + $config = new LoggingConfig(); + $config->parseFromXml($content); + return $config; + } + + /** + * Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface, + * 404 is also considered a valid response + * + * @return bool + */ + protected function isResponseOk() + { + $status = $this->rawResponse->status; + if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetRefererResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetRefererResult.php new file mode 100644 index 0000000..a8a649e --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetRefererResult.php @@ -0,0 +1,41 @@ +rawResponse->body; + $config = new RefererConfig(); + $config->parseFromXml($content); + return $config; + } + + /** + * Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface, + * 404 is also considered a valid response + * + * @return bool + */ + protected function isResponseOk() + { + $status = $this->rawResponse->status; + if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php new file mode 100644 index 0000000..2f4127b --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetStorageCapacityResult.php @@ -0,0 +1,34 @@ +rawResponse->body; + if (empty($content)) { + throw new OssException("body is null"); + } + $xml = simplexml_load_string($content); + if (isset($xml->StorageCapacity)) { + return intval($xml->StorageCapacity); + } else { + throw new OssException("xml format exception"); + } + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php new file mode 100644 index 0000000..64d54fa --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/GetWebsiteResult.php @@ -0,0 +1,40 @@ +rawResponse->body; + $config = new WebsiteConfig(); + $config->parseFromXml($content); + return $config; + } + + /** + * Judged according to the return HTTP status code, [200-299] that is OK, get the bucket configuration interface, + * 404 is also considered a valid response + * + * @return bool + */ + protected function isResponseOk() + { + $status = $this->rawResponse->status; + if ((int)(intval($status) / 100) == 2 || (int)(intval($status)) === 404) { + return true; + } + return false; + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php new file mode 100644 index 0000000..1ca4d1a --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/HeaderResult.php @@ -0,0 +1,23 @@ +rawResponse->header) ? array() : $this->rawResponse->header; + } + +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateBucketWormResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateBucketWormResult.php new file mode 100644 index 0000000..1cd7a02 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateBucketWormResult.php @@ -0,0 +1,27 @@ +rawResponse->header; + if (isset($header["x-oss-worm-id"])) { + return strval($header["x-oss-worm-id"]); + } + throw new OssException("cannot get worm-id"); + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php new file mode 100644 index 0000000..53a15da --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/InitiateMultipartUploadResult.php @@ -0,0 +1,29 @@ +rawResponse->body; + $xml = simplexml_load_string($content); + if (isset($xml->UploadId)) { + return strval($xml->UploadId); + } + throw new OssException("cannot get UploadId"); + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListBucketsResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListBucketsResult.php new file mode 100644 index 0000000..1dd037b --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListBucketsResult.php @@ -0,0 +1,32 @@ +rawResponse->body; + $xml = new \SimpleXMLElement($content); + if (isset($xml->Buckets) && isset($xml->Buckets->Bucket)) { + foreach ($xml->Buckets->Bucket as $bucket) { + $bucketInfo = new BucketInfo(); + $bucketInfo->parseFromXmlNode($bucket); + $bucketList[] = $bucketInfo; + } + } + return new BucketListInfo($bucketList); + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListLiveChannelResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListLiveChannelResult.php new file mode 100644 index 0000000..1a6e2a4 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListLiveChannelResult.php @@ -0,0 +1,16 @@ +rawResponse->body; + $channelList = new LiveChannelListInfo(); + $channelList->parseFromXml($content); + return $channelList; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php new file mode 100644 index 0000000..3220c86 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListMultipartUploadResult.php @@ -0,0 +1,55 @@ +rawResponse->body; + $xml = simplexml_load_string($content); + + $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; + $bucket = isset($xml->Bucket) ? strval($xml->Bucket) : ""; + $keyMarker = isset($xml->KeyMarker) ? strval($xml->KeyMarker) : ""; + $keyMarker = OssUtil::decodeKey($keyMarker, $encodingType); + $uploadIdMarker = isset($xml->UploadIdMarker) ? strval($xml->UploadIdMarker) : ""; + $nextKeyMarker = isset($xml->NextKeyMarker) ? strval($xml->NextKeyMarker) : ""; + $nextKeyMarker = OssUtil::decodeKey($nextKeyMarker, $encodingType); + $nextUploadIdMarker = isset($xml->NextUploadIdMarker) ? strval($xml->NextUploadIdMarker) : ""; + $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : ""; + $delimiter = OssUtil::decodeKey($delimiter, $encodingType); + $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : ""; + $prefix = OssUtil::decodeKey($prefix, $encodingType); + $maxUploads = isset($xml->MaxUploads) ? intval($xml->MaxUploads) : 0; + $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; + $listUpload = array(); + + if (isset($xml->Upload)) { + foreach ($xml->Upload as $upload) { + $key = isset($upload->Key) ? strval($upload->Key) : ""; + $key = OssUtil::decodeKey($key, $encodingType); + $uploadId = isset($upload->UploadId) ? strval($upload->UploadId) : ""; + $initiated = isset($upload->Initiated) ? strval($upload->Initiated) : ""; + $listUpload[] = new UploadInfo($key, $uploadId, $initiated); + } + } + return new ListMultipartUploadInfo($bucket, $keyMarker, $uploadIdMarker, + $nextKeyMarker, $nextUploadIdMarker, + $delimiter, $prefix, $maxUploads, $isTruncated, $listUpload); + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectVersionsResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectVersionsResult.php new file mode 100644 index 0000000..4503c03 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectVersionsResult.php @@ -0,0 +1,98 @@ +rawResponse->body); + $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; + $objectVersionList = $this->parseObjecVersionList($xml, $encodingType); + $deleteMarkerList = $this->parseDeleteMarkerList($xml, $encodingType); + $prefixList = $this->parsePrefixList($xml, $encodingType); + $bucketName = isset($xml->Name) ? strval($xml->Name) : ""; + $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : ""; + $prefix = OssUtil::decodeKey($prefix, $encodingType); + $keyMarker = isset($xml->KeyMarker) ? strval($xml->KeyMarker) : ""; + $keyMarker = OssUtil::decodeKey($keyMarker, $encodingType); + $nextKeyMarker = isset($xml->NextKeyMarker) ? strval($xml->NextKeyMarker) : ""; + $nextKeyMarker = OssUtil::decodeKey($nextKeyMarker, $encodingType); + $versionIdMarker = isset($xml->VersionIdMarker) ? strval($xml->VersionIdMarker) : ""; + $nextVersionIdMarker = isset($xml->NextVersionIdMarker) ? strval($xml->NextVersionIdMarker) : ""; + $maxKeys = isset($xml->MaxKeys) ? intval($xml->MaxKeys) : 0; + $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : ""; + $delimiter = OssUtil::decodeKey($delimiter, $encodingType); + $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; + + return new ObjectVersionListInfo($bucketName, $prefix, $keyMarker, $nextKeyMarker, + $versionIdMarker, $nextVersionIdMarker, $maxKeys, $delimiter, $isTruncated, + $objectVersionList, $deleteMarkerList, $prefixList); + } + + private function parseObjecVersionList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->Version)) { + foreach ($xml->Version as $content) { + $key = isset($content->Key) ? strval($content->Key) : ""; + $key = OssUtil::decodeKey($key, $encodingType); + $versionId = isset($content->VersionId) ? strval($content->VersionId) : ""; + $lastModified = isset($content->LastModified) ? strval($content->LastModified) : ""; + $eTag = isset($content->ETag) ? strval($content->ETag) : ""; + $type = isset($content->Type) ? strval($content->Type) : ""; + $size = isset($content->Size) ? strval($content->Size) : "0"; + $storageClass = isset($content->StorageClass) ? strval($content->StorageClass) : ""; + $isLatest = isset($content->IsLatest) ? strval($content->IsLatest) : ""; + $retList[] = new ObjectVersionInfo($key, $versionId, $lastModified, $eTag, $type, $size, $storageClass, $isLatest); + } + } + return $retList; + } + + private function parseDeleteMarkerList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->DeleteMarker)) { + foreach ($xml->DeleteMarker as $content) { + $key = isset($content->Key) ? strval($content->Key) : ""; + $key = OssUtil::decodeKey($key, $encodingType); + $versionId = isset($content->VersionId) ? strval($content->VersionId) : ""; + $lastModified = isset($content->LastModified) ? strval($content->LastModified) : ""; + $isLatest = isset($content->IsLatest) ? strval($content->IsLatest) : ""; + $retList[] = new DeleteMarkerInfo($key, $versionId, $lastModified, $isLatest); + } + } + return $retList; + } + + private function parsePrefixList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->CommonPrefixes)) { + foreach ($xml->CommonPrefixes as $commonPrefix) { + $prefix = isset($commonPrefix->Prefix) ? strval($commonPrefix->Prefix) : ""; + $prefix = OssUtil::decodeKey($prefix, $encodingType); + $retList[] = new PrefixInfo($prefix); + } + } + return $retList; + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php new file mode 100644 index 0000000..1246174 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsResult.php @@ -0,0 +1,80 @@ +rawResponse->body); + $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; + $objectList = $this->parseObjectList($xml, $encodingType); + $prefixList = $this->parsePrefixList($xml, $encodingType); + $bucketName = isset($xml->Name) ? strval($xml->Name) : ""; + $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : ""; + $prefix = OssUtil::decodeKey($prefix, $encodingType); + $marker = isset($xml->Marker) ? strval($xml->Marker) : ""; + $marker = OssUtil::decodeKey($marker, $encodingType); + $maxKeys = isset($xml->MaxKeys) ? intval($xml->MaxKeys) : 0; + $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : ""; + $delimiter = OssUtil::decodeKey($delimiter, $encodingType); + $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; + $nextMarker = isset($xml->NextMarker) ? strval($xml->NextMarker) : ""; + $nextMarker = OssUtil::decodeKey($nextMarker, $encodingType); + return new ObjectListInfo($bucketName, $prefix, $marker, $nextMarker, $maxKeys, $delimiter, $isTruncated, $objectList, $prefixList); + } + + private function parseObjectList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->Contents)) { + foreach ($xml->Contents as $content) { + $key = isset($content->Key) ? strval($content->Key) : ""; + $key = OssUtil::decodeKey($key, $encodingType); + $lastModified = isset($content->LastModified) ? strval($content->LastModified) : ""; + $eTag = isset($content->ETag) ? strval($content->ETag) : ""; + $type = isset($content->Type) ? strval($content->Type) : ""; + $size = isset($content->Size) ? strval($content->Size) : "0"; + $storageClass = isset($content->StorageClass) ? strval($content->StorageClass) : ""; + if(isset($content->Owner)){ + $owner = new Owner(strval($content->Owner->ID),strval($content->Owner->DisplayName)); + }else{ + $owner = null; + } + $restoreInfo= isset($content->RestoreInfo) ? strval($content->RestoreInfo) : null; + $retList[] = new ObjectInfo($key, $lastModified, $eTag, $type, $size, $storageClass,$owner,$restoreInfo); + } + } + return $retList; + } + + private function parsePrefixList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->CommonPrefixes)) { + foreach ($xml->CommonPrefixes as $commonPrefix) { + $prefix = isset($commonPrefix->Prefix) ? strval($commonPrefix->Prefix) : ""; + $prefix = OssUtil::decodeKey($prefix, $encodingType); + $retList[] = new PrefixInfo($prefix); + } + } + return $retList; + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsV2Result.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsV2Result.php new file mode 100644 index 0000000..8293767 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListObjectsV2Result.php @@ -0,0 +1,81 @@ +rawResponse->body); + $encodingType = isset($xml->EncodingType) ? strval($xml->EncodingType) : ""; + $objectList = $this->parseObjectList($xml, $encodingType); + $prefixList = $this->parsePrefixList($xml, $encodingType); + $bucketName = isset($xml->Name) ? strval($xml->Name) : ""; + $prefix = isset($xml->Prefix) ? strval($xml->Prefix) : ""; + $prefix = OssUtil::decodeKey($prefix, $encodingType); + $maxKeys = isset($xml->MaxKeys) ? intval($xml->MaxKeys) : 0; + $delimiter = isset($xml->Delimiter) ? strval($xml->Delimiter) : ""; + $delimiter = OssUtil::decodeKey($delimiter, $encodingType); + $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; + $continuationToken = isset($xml->ContinuationToken) ? strval($xml->ContinuationToken) : ""; + $nextContinuationToken = isset($xml->NextContinuationToken) ? strval($xml->NextContinuationToken) : ""; + $startAfter = isset($xml->StartAfter) ? strval($xml->StartAfter) : ""; + $startAfter = OssUtil::decodeKey($startAfter, $encodingType); + $keyCount = isset($xml->KeyCount) ? intval($xml->KeyCount) : 0; + return new ObjectListInfoV2($bucketName, $prefix, $maxKeys, $delimiter, $isTruncated, $objectList, $prefixList, $continuationToken, $nextContinuationToken, $startAfter, $keyCount); + } + + private function parseObjectList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->Contents)) { + foreach ($xml->Contents as $content) { + $key = isset($content->Key) ? strval($content->Key) : ""; + $key = OssUtil::decodeKey($key, $encodingType); + $lastModified = isset($content->LastModified) ? strval($content->LastModified) : ""; + $eTag = isset($content->ETag) ? strval($content->ETag) : ""; + $type = isset($content->Type) ? strval($content->Type) : ""; + $size = isset($content->Size) ? strval($content->Size) : "0"; + $storageClass = isset($content->StorageClass) ? strval($content->StorageClass) : ""; + if(isset($content->Owner)){ + $owner = new Owner(strval($content->Owner->ID),strval($content->Owner->DisplayName)); + }else{ + $owner = null; + } + $restoreInfo= isset($content->RestoreInfo) ? strval($content->RestoreInfo) : null; + $retList[] = new ObjectInfo($key, $lastModified, $eTag, $type, $size, $storageClass,$owner,$restoreInfo); + } + } + return $retList; + } + + private function parsePrefixList($xml, $encodingType) + { + $retList = array(); + if (isset($xml->CommonPrefixes)) { + foreach ($xml->CommonPrefixes as $commonPrefix) { + $prefix = isset($commonPrefix->Prefix) ? strval($commonPrefix->Prefix) : ""; + $prefix = OssUtil::decodeKey($prefix, $encodingType); + $retList[] = new PrefixInfo($prefix); + } + } + return $retList; + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php new file mode 100644 index 0000000..6641b5b --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/ListPartsResult.php @@ -0,0 +1,42 @@ +rawResponse->body; + $xml = simplexml_load_string($content); + $bucket = isset($xml->Bucket) ? strval($xml->Bucket) : ""; + $key = isset($xml->Key) ? strval($xml->Key) : ""; + $uploadId = isset($xml->UploadId) ? strval($xml->UploadId) : ""; + $nextPartNumberMarker = isset($xml->NextPartNumberMarker) ? intval($xml->NextPartNumberMarker) : ""; + $maxParts = isset($xml->MaxParts) ? intval($xml->MaxParts) : ""; + $isTruncated = isset($xml->IsTruncated) ? strval($xml->IsTruncated) : ""; + $partList = array(); + if (isset($xml->Part)) { + foreach ($xml->Part as $part) { + $partNumber = isset($part->PartNumber) ? intval($part->PartNumber) : ""; + $lastModified = isset($part->LastModified) ? strval($part->LastModified) : ""; + $eTag = isset($part->ETag) ? strval($part->ETag) : ""; + $size = isset($part->Size) ? strval($part->Size) : ""; + $partList[] = new PartInfo($partNumber, $lastModified, $eTag, $size); + } + } + return new ListPartsInfo($bucket, $key, $uploadId, $nextPartNumberMarker, $maxParts, $isTruncated, $partList); + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/PutLiveChannelResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/PutLiveChannelResult.php new file mode 100644 index 0000000..dcac86b --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/PutLiveChannelResult.php @@ -0,0 +1,16 @@ +rawResponse->body; + $channel = new LiveChannelInfo(); + $channel->parseFromXml($content); + return $channel; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/PutSetDeleteResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/PutSetDeleteResult.php new file mode 100644 index 0000000..97af003 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/PutSetDeleteResult.php @@ -0,0 +1,20 @@ + $this->rawResponse->body); + return array_merge($this->rawResponse->header, $body); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/Result.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/Result.php new file mode 100644 index 0000000..597ac5a --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/Result.php @@ -0,0 +1,213 @@ +rawResponse = $response; + $this->parseResponse(); + } + + /** + * Get requestId + * + * @return string + */ + public function getRequestId() + { + if (isset($this->rawResponse) && + isset($this->rawResponse->header) && + isset($this->rawResponse->header['x-oss-request-id']) + ) { + return $this->rawResponse->header['x-oss-request-id']; + } else { + return ''; + } + } + + /** + * Get the returned data, different request returns the data format is different + * + * $return mixed + */ + public function getData() + { + return $this->parsedData; + } + + /** + * Subclass implementation, different requests return data has different analytical logic, implemented by subclasses + * + * @return mixed + */ + abstract protected function parseDataFromResponse(); + + /** + * Whether the operation is successful + * + * @return mixed + */ + public function isOK() + { + return $this->isOk; + } + + /** + * @throws OssException + */ + public function parseResponse() + { + $this->isOk = $this->isResponseOk(); + if ($this->isOk) { + $this->parsedData = $this->parseDataFromResponse(); + } else { + $httpStatus = strval($this->rawResponse->status); + $requestId = strval($this->getRequestId()); + $code = $this->retrieveErrorCode($this->rawResponse->body); + $message = $this->retrieveErrorMessage($this->rawResponse->body); + $body = $this->rawResponse->body; + + $details = array( + 'status' => $httpStatus, + 'request-id' => $requestId, + 'code' => $code, + 'message' => $message, + 'body' => $body + ); + throw new OssException($details); + } + } + + /** + * Try to get the error message from body + * + * @param $body + * @return string + */ + private function retrieveErrorMessage($body) + { + if (empty($body) || false === strpos($body, 'Message)) { + return strval($xml->Message); + } + $flag = true; + } catch (\Exception $e) { + $flag = true; + } + if ($flag === true) { + $start = strpos($body, ''); + if ($start === false) { + return ''; + } + $start += 9; + $end = strpos($body, '', $start); + if ($end === false) { + return ''; + } + return substr($body, $start, $end - $start); + } + + return ''; + } + + /** + * Try to get the error Code from body + * + * @param $body + * @return string + */ + private function retrieveErrorCode($body) + { + if (empty($body) || false === strpos($body, 'Code)) { + return strval($xml->Code); + } + $flag = true; + } catch (\Exception $e) { + $flag = true; + } + if ($flag === true) { + $start = strpos($body, ''); + if ($start === false) { + return ''; + } + $start += 6; + $end = strpos($body, '', $start); + if ($end === false) { + return ''; + } + return substr($body, $start, $end - $start); + } + + return ''; + } + + /** + * Judging from the return http status code, [200-299] that is OK + * + * @return bool + */ + protected function isResponseOk() + { + $status = $this->rawResponse->status; + if ((int)(intval($status) / 100) == 2) { + return true; + } + return false; + } + + /** + * Return the original return data + * + * @return ResponseCore + */ + public function getRawResponse() + { + return $this->rawResponse; + } + + /** + * Indicate whether the request is successful + */ + protected $isOk = false; + /** + * Data parsed by subclasses + */ + protected $parsedData = null; + /** + * Store the original Response returned by the auth function + * + * @var ResponseCore + */ + protected $rawResponse; +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/SymlinkResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/SymlinkResult.php new file mode 100644 index 0000000..9c6d861 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/SymlinkResult.php @@ -0,0 +1,24 @@ +rawResponse->header[OssClient::OSS_SYMLINK_TARGET] = rawurldecode($this->rawResponse->header[OssClient::OSS_SYMLINK_TARGET]); + return $this->rawResponse->header; + } +} + diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/UploadPartResult.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/UploadPartResult.php new file mode 100644 index 0000000..c6b66d4 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Result/UploadPartResult.php @@ -0,0 +1,28 @@ +rawResponse->header; + if (isset($header["etag"])) { + return $header["etag"]; + } + throw new OssException("cannot get ETag"); + + } +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerInterface.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerInterface.php new file mode 100644 index 0000000..c592a4f --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerInterface.php @@ -0,0 +1,12 @@ +request_headers['Date'])) { + $request->add_header('Date', gmdate('D, d M Y H:i:s \G\M\T')); + } + // Credentials information + if (!empty($credentials->getSecurityToken())) { + $request->add_header("x-oss-security-token", $credentials->getSecurityToken()); + } + $headers = $request->request_headers; + $method = strtoupper($request->method); + $date = $headers['Date']; + $resourcePath = $this->getResourcePath($options); + $queryString = parse_url($request->request_url, PHP_URL_QUERY); + $query = array(); + if ($queryString !== null) { + parse_str($queryString, $query); + } + $stringToSign = $this->calcStringToSign($method, $date, $headers, $resourcePath, $query); +// printf("sign str:%s" . PHP_EOL, $stringToSign); + $options['string_to_sign'] = $stringToSign; + $signature = base64_encode(hash_hmac('sha1', $stringToSign, $credentials->getAccessKeySecret(), true)); + $request->add_header('Authorization', 'OSS ' . $credentials->getAccessKeyId() . ':' . $signature); + } + + public function presign(RequestCore $request, Credentials $credentials, array &$options) + { + $headers = $request->request_headers; + // Date + $expiration = $options['expiration']; + if (!isset($request->request_headers['Date'])) { + $request->add_header('Date', gmdate('D, d M Y H:i:s \G\M\T')); + } + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + if ($queryString !== null) { + parse_str($queryString, $query); + } + // Credentials information + if (!empty($credentials->getSecurityToken())) { + $query["security-token"] = $credentials->getSecurityToken(); + } + $method = strtoupper($request->method); + $date = $expiration . ""; + $resourcePath = $this->getResourcePath($options); + $stringToSign = $this->calcStringToSign($method, $date, $headers, $resourcePath, $query); + $options['string_to_sign'] = $stringToSign; + $signature = base64_encode(hash_hmac('sha1', $stringToSign, $credentials->getAccessKeySecret(), true)); + $query['OSSAccessKeyId'] = $credentials->getAccessKeyId(); + $query['Expires'] = $date; + $query['Signature'] = $signature; + $queryString = OssUtil::toQueryString($query); + $parsed_url['query'] = $queryString; + $request->request_url = OssUtil::unparseUrl($parsed_url); + } + + private function getResourcePath(array $options) + { + $resourcePath = '/'; + if (strlen($options['bucket']) > 0) { + $resourcePath .= $options['bucket'] . '/'; + } + if (strlen($options['key']) > 0) { + $resourcePath .= $options['key']; + } + return $resourcePath; + } + + private function calcStringToSign($method, $date, array $headers, $resourcePath, array $query) + { + /* + SignToString = + VERB + "\n" + + Content-MD5 + "\n" + + Content-Type + "\n" + + Date + "\n" + + CanonicalizedOSSHeaders + + CanonicalizedResource + Signature = base64(hmac-sha1(AccessKeySecret, SignToString)) + */ + $contentMd5 = ''; + $contentType = ''; + // CanonicalizedOSSHeaders + $signheaders = array(); + foreach ($headers as $key => $value) { + $lowk = strtolower($key); + if (strncmp($lowk, "x-oss-", 6) == 0) { + $signheaders[$lowk] = $value; + } else if ($lowk === 'content-md5') { + $contentMd5 = $value; + } else if ($lowk === 'content-type') { + $contentType = $value; + } + } + ksort($signheaders); + $canonicalizedOSSHeaders = ''; + foreach ($signheaders as $key => $value) { + $canonicalizedOSSHeaders .= $key . ':' . $value . "\n"; + } + // CanonicalizedResource + $signquery = array(); + foreach ($query as $key => $value) { + if (in_array($key, $this->signKeyList)) { + $signquery[$key] = $value; + } + } + ksort($signquery); + $sortedQueryList = array(); + foreach ($signquery as $key => $value) { + if (strlen($value) > 0) { + $sortedQueryList[] = $key . '=' . $value; + } else { + $sortedQueryList[] = $key; + } + } + $queryStringSorted = implode('&', $sortedQueryList); + $canonicalizedResource = $resourcePath; + if (!empty($queryStringSorted)) { + $canonicalizedResource .= '?' . $queryStringSorted; + } + return $method . "\n" . $contentMd5 . "\n" . $contentType . "\n" . $date . "\n" . $canonicalizedOSSHeaders . $canonicalizedResource; + } + + private $signKeyList = array( + "acl", "uploads", "location", "cors", + "logging", "website", "referer", "lifecycle", + "delete", "append", "tagging", "objectMeta", + "uploadId", "partNumber", "security-token", "x-oss-security-token", + "position", "img", "style", "styleName", + "replication", "replicationProgress", + "replicationLocation", "cname", "bucketInfo", + "comp", "qos", "live", "status", "vod", + "startTime", "endTime", "symlink", + "x-oss-process", "response-content-type", "x-oss-traffic-limit", + "response-content-language", "response-expires", + "response-cache-control", "response-content-disposition", + "response-content-encoding", "udf", "udfName", "udfImage", + "udfId", "udfImageDesc", "udfApplication", + "udfApplicationLog", "restore", "callback", "callback-var", "qosInfo", + "policy", "stat", "encryption", "versions", "versioning", "versionId", "requestPayment", + "x-oss-request-payer", "sequential", + "inventory", "inventoryId", "continuation-token", "asyncFetch", + "worm", "wormId", "wormExtend", "withHashContext", + "x-oss-enable-md5", "x-oss-enable-sha1", "x-oss-enable-sha256", + "x-oss-hash-ctx", "x-oss-md5-ctx", "transferAcceleration", + "regionList", "cloudboxes", "x-oss-ac-source-ip", "x-oss-ac-subnet-mask", "x-oss-ac-vpc-id", "x-oss-ac-forward-allow", + "metaQuery", "resourceGroup", "rtc", "x-oss-async-process", "responseHeader" + ); +} \ No newline at end of file diff --git a/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerV4.php b/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerV4.php new file mode 100644 index 0000000..039b04a --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/src/OSS/Signer/SignerV4.php @@ -0,0 +1,244 @@ +request_headers['Date'])) { + $request->add_header('Date', gmdate('D, d M Y H:i:s \G\M\T')); + } + $timestamp = strtotime($request->request_headers['Date']); + if ($timestamp === false) { + $timestamp = time(); + } + $datetime = gmdate('Ymd\THis\Z', $timestamp); + $date = substr($datetime, 0, 8); + $request->add_header("x-oss-date", $datetime); + if (!isset($request->request_headers['x-oss-content-sha256'])) { + $request->add_header("x-oss-content-sha256", 'UNSIGNED-PAYLOAD'); + } + // Credentials information + if (!empty($credentials->getSecurityToken())) { + $request->add_header("x-oss-security-token", $credentials->getSecurityToken()); + } + $headers = $request->request_headers; + $method = strtoupper($request->method); + $region = $options['region']; + $product = $options['product']; + $scope = $this->buildScope($date, $region, $product); + $resourcePath = $this->getResourcePath($options); + $additionalHeaders = $this->getCommonAdditionalHeaders($request, $options); + $queryString = parse_url($request->request_url, PHP_URL_QUERY); + $query = array(); + if ($queryString !== null) { + parse_str($queryString, $query); + } + $canonicalRequest = $this->calcCanonicalRequest($method, $resourcePath, $query, $headers, $additionalHeaders); + $stringToSign = $this->calcStringToSign($datetime, $scope, $canonicalRequest); +// printf('canonical request:%s' . PHP_EOL, $canonicalRequest); +// printf('sign str:%s' . PHP_EOL, $stringToSign); + $options['string_to_sign'] = $stringToSign; + $signature = $this->calcSignature($credentials->getAccessKeySecret(), $date, $region, $product, $stringToSign); + $authorization = 'OSS4-HMAC-SHA256 Credential=' . $credentials->getAccessKeyId() . '/' . $scope; + $additionalHeadersString = implode(';', $additionalHeaders); + if ($additionalHeadersString !== '') { + $authorization .= ',AdditionalHeaders=' . $additionalHeadersString; + } + $authorization .= ',Signature=' . $signature; + $request->add_header('Authorization', $authorization); + } + + public function presign(RequestCore $request, Credentials $credentials, array &$options) + { + if (!isset($request->request_headers['Date'])) { + $request->add_header('Date', gmdate('D, d M Y H:i:s \G\M\T')); + } + $timestamp = strtotime($request->request_headers['Date']); + if ($timestamp === false) { + $timestamp = time(); + } + $datetime = gmdate('Ymd\THis\Z', $timestamp); + $expiration = $options['expiration']; + $date = substr($datetime, 0, 8); + $expires = $expiration - $timestamp; + $headers = $request->request_headers; + $method = strtoupper($request->method); + $region = $options['region']; + $product = $options['product']; + $scope = $this->buildScope($date, $region, $product); + $resourcePath = $this->getResourcePath($options); + $additionalHeaders = $this->getCommonAdditionalHeaders($request, $options); + $queryString = parse_url($request->request_url, PHP_URL_QUERY); + $query = array(); + if ($queryString !== null) { + parse_str($queryString, $query); + } + if (!empty($credentials->getSecurityToken())) { + $query["x-oss-security-token"] = $credentials->getSecurityToken(); + } + $query["x-oss-signature-version"] = 'OSS4-HMAC-SHA256'; + $query["x-oss-date"] = $datetime; + $query["x-oss-expires"] = $expires; + $query["x-oss-credential"] = $credentials->getAccessKeyId() . '/' . $scope; + if (count($additionalHeaders) > 0) { + $query["x-oss-additional-headers"] = implode(";", $additionalHeaders); + } + $canonicalRequest = $this->calcCanonicalRequest($method, $resourcePath, $query, $headers, $additionalHeaders); + $stringToSign = $this->calcStringToSign($datetime, $scope, $canonicalRequest); +// printf('canonical request:%s' . PHP_EOL, $canonicalRequest); +// printf('sign str:%s' . PHP_EOL, $stringToSign); + $options['string_to_sign'] = $stringToSign; + $signature = $this->calcSignature($credentials->getAccessKeySecret(), $date, $region, $product, $stringToSign); + $query["x-oss-signature"] = $signature; + $queryStr = OssUtil::toQueryString($query); + $explodeUrl = explode('?', $request->request_url); + $index = count($explodeUrl); + if ($index === 1) { + $request->request_url .= '?' . $queryStr; + } else { + $baseUrl = $explodeUrl[0]; + $request->request_url = $baseUrl . '?' . $queryStr; + } + } + + private function getResourcePath(array $options) + { + $resourcePath = '/'; + if (strlen($options['bucket']) > 0) { + $resourcePath .= $options['bucket'] . '/'; + } + if (strlen($options['key']) > 0) { + $resourcePath .= $options['key']; + } + return $resourcePath; + } + + private function getCommonAdditionalHeaders(RequestCore $request, array $options) + { + if (isset($options[OssClient::OSS_ADDITIONAL_HEADERS])) { + $addHeaders = array(); + foreach ($options[OssClient::OSS_ADDITIONAL_HEADERS] as $key) { + $lowk = strtolower($key); + if ($this->isDefaultSignedHeader($lowk)) { + continue; + } + $addHeaders[$lowk] = ''; + } + $headers = array(); + foreach ($request->request_headers as $key => $value) { + $lowk = strtolower($key); + if (isset($addHeaders[$lowk])) { + $headers[$lowk] = ''; + } + } + ksort($headers); + return array_keys($headers); + } + return array(); + } + + private function isDefaultSignedHeader($low) + { + if (strncmp($low, "x-oss-", 6) == 0 || + $low === "content-type" || + $low === "content-md5") { + return true; + } + return false; + } + + private function calcStringToSign($datetime, $scope, $canonicalRequest) + { + /* + StringToSign + "OSS4-HMAC-SHA256" + "\n" + + TimeStamp + "\n" + + Scope + "\n" + + Hex(SHA256Hash(Canonical Request)) + */ + $hashedRequest = hash('sha256', $canonicalRequest); + return "OSS4-HMAC-SHA256" . "\n" . $datetime . "\n" . $scope . "\n" . $hashedRequest; + } + + private function calcCanonicalRequest($method, $resourcePath, array $query, array $headers, array $additionalHeaders) + { + /* + Canonical Request + HTTP Verb + "\n" + + Canonical URI + "\n" + + Canonical Query String + "\n" + + Canonical Headers + "\n" + + Additional Headers + "\n" + + Hashed PayLoad + */ + + //Canonical Uri + $canonicalUri = str_replace(array('%2F'), array('/'), rawurlencode($resourcePath)); + //Canonical Query + $querySigned = array(); + foreach ($query as $key => $value) { + $querySigned[rawurlencode($key)] = rawurlencode($value); + } + ksort($querySigned); + $sortedQueryList = array(); + foreach ($querySigned as $key => $value) { + if (strlen($value) > 0) { + $sortedQueryList[] = $key . '=' . $value; + } else { + $sortedQueryList[] = $key; + } + } + $canonicalQuery = implode('&', $sortedQueryList); + //Canonical Headers + $headersSigned = array(); + foreach ($headers as $key => $value) { + $lowk = strtolower($key); + if (SignerV4::isDefaultSignedHeader($lowk) || + in_array($lowk, $additionalHeaders)) { + $headersSigned[$lowk] = trim($value); + } + } + ksort($headersSigned); + $canonicalizedHeaders = ''; + foreach ($headersSigned as $key => $value) { + $canonicalizedHeaders .= $key . ':' . $value . "\n"; + } + //Additional Headers + $canonicalAdditionalHeaders = implode(';', $additionalHeaders); + $hashPayload = "UNSIGNED-PAYLOAD"; + if (isset($headersSigned['x-oss-content-sha256'])) { + $hashPayload = $headersSigned['x-oss-content-sha256']; + } + + $stringToSign = $method . "\n" + . $canonicalUri . "\n" + . $canonicalQuery . "\n" + . $canonicalizedHeaders . "\n" + . $canonicalAdditionalHeaders . "\n" + . $hashPayload; + return $stringToSign; + } + + private function buildScope($date, $region, $product) + { + return $date . "/" . $region . "/" . $product . "/aliyun_v4_request"; + } + + private function calcSignature($secret, $date, $region, $product, $stringToSign) + { + $h1Key = hash_hmac("sha256", $date, "aliyun_v4" . $secret, true); + $h2Key = hash_hmac("sha256", $region, $h1Key, true); + $h3Key = hash_hmac("sha256", $product, $h2Key, true); + $h4Key = hash_hmac("sha256", "aliyun_v4_request", $h3Key, true); + return bin2hex(hash_hmac("sha256", $stringToSign, $h4Key, true)); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AclResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AclResultTest.php new file mode 100644 index 0000000..82168d0 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AclResultTest.php @@ -0,0 +1,59 @@ + + + + 00220120222 + user_example + + + public-read + + +BBBB; + + private $invalidXml = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new AclResult($response); + $this->assertEquals("public-read", $result->getData()); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + try { + new AclResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('body is null', $e->getMessage()); + } + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + try { + new AclResult($response); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals("xml format exception", $e->getMessage()); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AssumeRole.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AssumeRole.php new file mode 100644 index 0000000..e47f705 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/AssumeRole.php @@ -0,0 +1,32 @@ +$name = $value; + } + + public function __construct() + { + parent::__construct(); + $this->RoleSessionName = "sts"; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BodyResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BodyResultTest.php new file mode 100644 index 0000000..290e61a --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BodyResultTest.php @@ -0,0 +1,26 @@ +assertTrue($result->isOK()); + $this->assertEquals($result->getData(), "hi"); + } + + public function testParseInvalid404() + { + $response = new ResponseCore(array(), null, 200); + $result = new BodyResult($response); + $this->assertTrue($result->isOK()); + $this->assertEquals($result->getData(), ""); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketCnameTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketCnameTest.php new file mode 100644 index 0000000..290f585 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketCnameTest.php @@ -0,0 +1,65 @@ +client = Common::getOssClient(); + $this->bucketName = 'php-sdk-test-bucket-' . strval(rand(0, 10000)); + $this->client->createBucket($this->bucketName); + } + + protected function tearDown(): void + { + $this->client->deleteBucket($this->bucketName); + } + + public function testBucketWithoutCname() + { + $cnameConfig = $this->client->getBucketCname($this->bucketName); + $this->assertEquals(0, count($cnameConfig->getCnames())); + } + + public function testAddCname() + { + try { + $this->client->addBucketCname($this->bucketName, 'www.baidu.com'); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertTrue(true); + } + + try { + $ret = $this->client->getBucketCname($this->bucketName); + $this->assertEquals(0, count($ret->getCnames())); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testDeleteCname() + { + try { + $this->client->deleteBucketCname($this->bucketName, 'www.not-exist.com'); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $ret = $this->client->getBucketCname($this->bucketName); + $this->assertEquals(0, count($ret->getCnames())); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketInfoTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketInfoTest.php new file mode 100644 index 0000000..f99bcee --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketInfoTest.php @@ -0,0 +1,21 @@ +assertNotNull($bucketInfo); + $this->assertEquals('cn-beijing', $bucketInfo->getLocation()); + $this->assertEquals('name', $bucketInfo->getName()); + $this->assertEquals('today', $bucketInfo->getCreateDate()); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketLiveChannelTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketLiveChannelTest.php new file mode 100644 index 0000000..dacae0b --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/BucketLiveChannelTest.php @@ -0,0 +1,320 @@ +client = Common::getOssClient(); + $this->bucketName = 'php-sdk-test-rtmp-bucket-name-' . strval(rand(0, 10000)); + $this->client->createBucket($this->bucketName); + Common::waitMetaSync(); + }catch(\Exception $e) { + + } + } + + protected function tearDown(): void + { + ////to delete created bucket + //1. delele live channel + $list = $this->client->listBucketLiveChannels($this->bucketName); + if (count($list->getChannelList()) != 0) + { + foreach($list->getChannelList() as $list) + { + $this->client->deleteBucketLiveChannel($this->bucketName, $list->getName()); + } + } + //2. delete exsited object + $prefix = 'live-test/'; + $delimiter = '/'; + $nextMarker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $nextMarker, + ); + + try { + $listObjectInfo = $this->client->listObjects($this->bucketName, $options); + } catch (OssException $e) { + printf($e->getMessage() . "\n"); + return; + } + + $objectList = $listObjectInfo->getObjectList(); // 文件列表 + if (!empty($objectList)) + { + foreach($objectList as $objectInfo) + $this->client->deleteObject($this->bucketName, $objectInfo->getKey()); + } + //3. delete the bucket + $this->client->deleteBucket($this->bucketName); + } + + public function testPutLiveChannel() + { + $config = new LiveChannelConfig(array( + 'description' => 'live channel 1', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); + $info = $this->client->putBucketLiveChannel($this->bucketName, 'live-1', $config); + $this->client->deleteBucketLiveChannel($this->bucketName, 'live-1'); + + $this->assertEquals('live-1', $info->getName()); + $this->assertEquals('live channel 1', $info->getDescription()); + $this->assertEquals(1, count($info->getPublishUrls())); + $this->assertEquals(1, count($info->getPlayUrls())); + } + + public function testPutLiveChannelWithDefaultParams() + { + $config = new LiveChannelConfig(array( + 'description' => 'live channel 1', + 'type' => 'HLS', + )); + $info = $this->client->putBucketLiveChannel($this->bucketName, 'live-1', $config); + $this->client->deleteBucketLiveChannel($this->bucketName, 'live-1'); + + $this->assertEquals('live-1', $info->getName()); + $this->assertEquals('live channel 1', $info->getDescription()); + $this->assertEquals(1, count($info->getPublishUrls())); + $this->assertEquals(1, count($info->getPlayUrls())); + } + + public function testListLiveChannels() + { + $config = new LiveChannelConfig(array( + 'description' => 'live channel 1', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); + $this->client->putBucketLiveChannel($this->bucketName, 'live-1', $config); + + $config = new LiveChannelConfig(array( + 'description' => 'live channel 2', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); + $this->client->putBucketLiveChannel($this->bucketName, 'live-2', $config); + + $list = $this->client->listBucketLiveChannels($this->bucketName); + + $this->assertEquals($this->bucketName, $list->getBucketName()); + $this->assertEquals(false, $list->getIsTruncated()); + $channels = $list->getChannelList(); + $this->assertEquals(2, count($channels)); + + $chan1 = $channels[0]; + $this->assertEquals('live-1', $chan1->getName()); + $this->assertEquals('live channel 1', $chan1->getDescription()); + $this->assertEquals(1, count($chan1->getPublishUrls())); + $this->assertEquals(1, count($chan1->getPlayUrls())); + + $chan2 = $channels[1]; + $this->assertEquals('live-2', $chan2->getName()); + $this->assertEquals('live channel 2', $chan2->getDescription()); + $this->assertEquals(1, count($chan2->getPublishUrls())); + $this->assertEquals(1, count($chan2->getPlayUrls())); + + $list = $this->client->listBucketLiveChannels($this->bucketName, array( + 'prefix' => 'live-', + 'marker' => 'live-1', + 'max-keys' => 10 + )); + $channels = $list->getChannelList(); + $this->assertEquals(1, count($channels)); + $chan2 = $channels[0]; + $this->assertEquals('live-2', $chan2->getName()); + $this->assertEquals('live channel 2', $chan2->getDescription()); + $this->assertEquals(1, count($chan2->getPublishUrls())); + $this->assertEquals(1, count($chan2->getPlayUrls())); + + $this->client->deleteBucketLiveChannel($this->bucketName, 'live-1'); + $this->client->deleteBucketLiveChannel($this->bucketName, 'live-2'); + $list = $this->client->listBucketLiveChannels($this->bucketName, array( + 'prefix' => 'live-' + )); + $this->assertEquals(0, count($list->getChannelList())); + } + + public function testDeleteLiveChannel() + { + $channelName = 'live-to-delete'; + $config = new LiveChannelConfig(array( + 'description' => 'live channel to delete', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); + $this->client->putBucketLiveChannel($this->bucketName, $channelName, $config); + + $this->client->deleteBucketLiveChannel($this->bucketName, $channelName); + $list = $this->client->listBucketLiveChannels($this->bucketName, array( + 'prefix' => $channelName + )); + + $this->assertEquals(0, count($list->getChannelList())); + } + + public function testSignRtmpUrl() + { + $channelName = '90475'; + $bucket = 'douyu'; + $now = time(); + $url = $this->client->signRtmpUrl($bucket, $channelName, 900, array( + 'params' => array( + 'playlistName' => 'playlist.m3u8' + ) + )); + + $ret = parse_url($url); + $this->assertEquals('rtmp', $ret['scheme']); + parse_str($ret['query'], $query); + + $this->assertTrue(isset($query['OSSAccessKeyId'])); + $this->assertTrue(isset($query['Signature'])); + $this->assertTrue(intval($query['Expires']) - ($now + 900) < 3); + $this->assertEquals('playlist.m3u8', $query['playlistName']); + } + + public function testGetgenPreSignedRtmpUrlVsSignedRtmpUrl() + { + $channelName = '90475'; + $bucket = 'douyu'; + $url1 = '245'; + $url2 = '123'; + $expiration = 0; + + do { + $begin = time(); + $expiration = time() + 900; + $url1 = $this->client->generatePresignedRtmpUrl($bucket, $channelName, $expiration, array( + 'params' => array( + 'playlistName' => 'playlist.m3u8' + ) + )); + + $url2 = $this->client->signRtmpUrl($bucket, $channelName, 900, array( + 'params' => array( + 'playlistName' => 'playlist.m3u8' + ) + )); + + $end = time(); + + if ($begin == $end) + break; + usleep(500000); + } while (true); + $this->assertEquals($url1, $url1); + $this->assertTrue(strpos($url1, 'Expires='.$expiration) !== false); + } + + public function testLiveChannelInfo() + { + $channelName = 'live-to-put-status'; + $config = new LiveChannelConfig(array( + 'description' => 'test live channel info', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); + $this->client->putBucketLiveChannel($this->bucketName, $channelName, $config); + + $info = $this->client->getLiveChannelInfo($this->bucketName, $channelName); + $this->assertEquals('test live channel info', $info->getDescription()); + $this->assertEquals('enabled', $info->getStatus()); + $this->assertEquals('HLS', $info->getType()); + $this->assertEquals(10, $info->getFragDuration()); + $this->assertEquals(5, $info->getFragCount()); + $this->assertEquals('playlist.m3u8', $info->getPlayListName()); + + $this->client->deleteBucketLiveChannel($this->bucketName, $channelName); + $list = $this->client->listBucketLiveChannels($this->bucketName, array( + 'prefix' => $channelName + )); + $this->assertEquals(0, count($list->getChannelList())); + } + + public function testPutLiveChannelStatus() + { + $channelName = 'live-to-put-status'; + $config = new LiveChannelConfig(array( + 'description' => 'test live channel info', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); + $this->client->putBucketLiveChannel($this->bucketName, $channelName, $config); + + $info = $this->client->getLiveChannelInfo($this->bucketName, $channelName); + $this->assertEquals('test live channel info', $info->getDescription()); + $this->assertEquals('enabled', $info->getStatus()); + $this->assertEquals('HLS', $info->getType()); + $this->assertEquals(10, $info->getFragDuration()); + $this->assertEquals(5, $info->getFragCount()); + $this->assertEquals('playlist.m3u8', $info->getPlayListName()); + $status = $this->client->getLiveChannelStatus($this->bucketName, $channelName); + $this->assertEquals('Idle', $status->getStatus()); + + + $resp = $this->client->putLiveChannelStatus($this->bucketName, $channelName, "disabled"); + $info = $this->client->getLiveChannelInfo($this->bucketName, $channelName); + $this->assertEquals('test live channel info', $info->getDescription()); + $this->assertEquals('disabled', $info->getStatus()); + $this->assertEquals('HLS', $info->getType()); + $this->assertEquals(10, $info->getFragDuration()); + $this->assertEquals(5, $info->getFragCount()); + $this->assertEquals('playlist.m3u8', $info->getPlayListName()); + + $status = $this->client->getLiveChannelStatus($this->bucketName, $channelName); + //getLiveChannelInfo + $this->assertEquals('Disabled', $status->getStatus()); + + $this->client->deleteBucketLiveChannel($this->bucketName, $channelName); + $list = $this->client->listBucketLiveChannels($this->bucketName, array( + 'prefix' => $channelName + )); + $this->assertEquals(0, count($list->getChannelList())); + + } + public function testLiveChannelHistory() + { + $channelName = 'live-test-history'; + $config = new LiveChannelConfig(array( + 'description' => 'test live channel info', + 'type' => 'HLS', + 'fragDuration' => 10, + 'fragCount' => 5, + 'playListName' => 'hello.m3u8' + )); + $this->client->putBucketLiveChannel($this->bucketName, $channelName, $config); + + $history = $this->client->getLiveChannelHistory($this->bucketName, $channelName); + $this->assertEquals(0, count($history->getLiveRecordList())); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CallbackTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CallbackTest.php new file mode 100644 index 0000000..feb0801 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CallbackTest.php @@ -0,0 +1,297 @@ +ossClient->putObject($this->bucket, $copiedObject, file_get_contents(__FILE__)); + + /** + * step 1. Initialize a block upload event, which is initialized to upload Multipart, get the upload id + */ + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + /* + * step 2. uploadPartCopy + */ + $copyId = 1; + $eTag = $this->ossClient->uploadPartCopy($this->bucket, $copiedObject, $this->bucket, $object, $copyId, $upload_id); + $upload_parts[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); + + try { + $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * step 3. + */ + $json = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size},\"x:var1\":${x:var1},\"x:var2\":${x:var2}}", + "callbackBodyType":"application/json" + }'; + + $var = + '{ + "x:var1":"value1", + "x:var2":"值2" + }'; + $options = array(OssClient::OSS_CALLBACK => $json, + OssClient::OSS_CALLBACK_VAR => $var + ); + + try { + $result = $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts, $options); + $this->assertEquals("200", $result['info']['http_code']); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testMultipartUploadCallbackFailed() + { + $object = "multipart-callback-test.txt"; + $copiedObject = "multipart-callback-test.txt.copied"; + $this->ossClient->putObject($this->bucket, $copiedObject, file_get_contents(__FILE__)); + + /** + * step 1. Initialize a block upload event, which is initialized to upload Multipart, get the upload id + */ + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + /* + * step 2. uploadPartCopy + */ + $copyId = 1; + $eTag = $this->ossClient->uploadPartCopy($this->bucket, $copiedObject, $this->bucket, $object, $copyId, $upload_id); + $upload_parts[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); + + try { + $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * step 3. + */ + + $json = + '{ + "callbackUrl":"www.baidu.com", + "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size},\"x:var1\":${x:var1},\"x:var2\":${x:var2}}", + "callbackBodyType":"application/json" + }'; + + $var = + '{ + "x:var1":"value1", + "x:var2":"值2" + }'; + $options = array(OssClient::OSS_CALLBACK => $json, + OssClient::OSS_CALLBACK_VAR => $var + ); + + try { + $result = $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts, $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + $this->assertEquals("203", $e->getHTTPStatus()); + } + + } + + public function testPutObjectCallbackNormal() + { + //json + { + $json = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size}}", + "callbackBodyType":"application/json" + }'; + $options = array(OssClient::OSS_CALLBACK => $json); + $this->putObjectCallbackOk($options, "200"); + } + //url + { + $url = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&imageInfo.height=${imageInfo.height}&imageInfo.width=${imageInfo.width}&imageInfo.format=${imageInfo.format}", + "callbackBodyType":"application/x-www-form-urlencoded" + }'; + $options = array(OssClient::OSS_CALLBACK => $url); + $this->putObjectCallbackOk($options, "200"); + } + // Unspecified typre + { + $url = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&imageInfo.height=${imageInfo.height}&imageInfo.width=${imageInfo.width}&imageInfo.format=${imageInfo.format}" + }'; + $options = array(OssClient::OSS_CALLBACK => $url); + $this->putObjectCallbackOk($options, "200"); + } + //json and body is chinese + { + $json = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"{\" 春水碧于天,画船听雨眠。\":\"垆边人似月,皓腕凝霜雪。\"}", + "callbackBodyType":"application/json" + }'; + $options = array(OssClient::OSS_CALLBACK => $json); + $this->putObjectCallbackOk($options, "200"); + } + //url and body is chinese + { + $url = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"春水碧于天,画船听雨眠。垆边人似月,皓腕凝霜雪", + "callbackBodyType":"application/x-www-form-urlencoded" + }'; + $options = array(OssClient::OSS_CALLBACK => $url); + $this->putObjectCallbackOk($options, "200"); + } + //json and add callback_var + { + $json = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size},\"x:var1\":${x:var1},\"x:var2\":${x:var2}}", + "callbackBodyType":"application/json" + }'; + + $var = + '{ + "x:var1":"value1", + "x:var2":"aliyun.com" + }'; + $options = array(OssClient::OSS_CALLBACK => $json, + OssClient::OSS_CALLBACK_VAR => $var + ); + $this->putObjectCallbackOk($options, "200"); + } + //url and add callback_var + { + $url = + '{ + "callbackUrl":"' . Common::getCallbackUrl() . '",' . + ' "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&imageInfo.height=${imageInfo.height}&imageInfo.width=${imageInfo.width}&imageInfo.format=${imageInfo.format}&my_var1=${x:var1}&my_var2=${x:var2}", + "callbackBodyType":"application/x-www-form-urlencoded" + }'; + $var = + '{ + "x:var1":"value1凌波不过横塘路,但目送,芳", + "x:var2":"值2" + }'; + $options = array(OssClient::OSS_CALLBACK => $url, + OssClient::OSS_CALLBACK_VAR => $var + ); + $this->putObjectCallbackOk($options, "200"); + } + + } + + public function testPutCallbackWithCallbackFailed() + { + { + $json = + '{ + "callbackUrl":"http://www.baidu.com", + "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"{\"mimeType\":${mimeType},\"size\":${size}}", + "callbackBodyType":"application/json" + }'; + $options = array(OssClient::OSS_CALLBACK => $json); + $this->putObjectCallbackFailed($options, "203"); + } + + { + $url = + '{ + "callbackUrl":"http://www.baidu.com", + "callbackHost":"oss-cn-hangzhou.aliyuncs.com", + "callbackBody":"bucket=${bucket}&object=${object}&etag=${etag}&size=${size}&mimeType=${mimeType}&imageInfo.height=${imageInfo.height}&imageInfo.width=${imageInfo.width}&imageInfo.format=${imageInfo.format}&my_var1=${x:var1}&my_var2=${x:var2}", + "callbackBodyType":"application/x-www-form-urlencoded" + }'; + $options = array(OssClient::OSS_CALLBACK => $url); + $this->putObjectCallbackFailed($options, "203"); + } + + } + + private function putObjectCallbackOk($options, $status) + { + $object = "oss-php-sdk-callback-test.txt"; + $content = file_get_contents(__FILE__); + try { + $result = $this->ossClient->putObject($this->bucket, $object, $content, $options); + $this->assertEquals($status, $result['info']['http_code']); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + private function putObjectCallbackFailed($options, $status) + { + $object = "oss-php-sdk-callback-test.txt"; + $content = file_get_contents(__FILE__); + try { + $result = $this->ossClient->putObject($this->bucket, $object, $content, $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals($status, $e->getHTTPStatus()); + $this->assertTrue(true); + } + } + + protected function setUp(): void + { + parent::setUp(); + if (strlen(Common::getCallbackUrl()) == 0) { + throw new OssException("callback url can not be empty!"); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CnameConfigTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CnameConfigTest.php new file mode 100644 index 0000000..8f7529c --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CnameConfigTest.php @@ -0,0 +1,77 @@ + + + + www.foo.com + enabled + 20150101 + + + bar.com + disabled + 20160101 + + +BBBB; + + public function testFromXml() + { + $cnameConfig = new CnameConfig(); + $cnameConfig->parseFromXml($this->xml1); + + $cnames = $cnameConfig->getCnames(); + $this->assertEquals(2, count($cnames)); + $this->assertEquals('www.foo.com', $cnames[0]['Domain']); + $this->assertEquals('enabled', $cnames[0]['Status']); + $this->assertEquals('20150101', $cnames[0]['LastModified']); + + $this->assertEquals('bar.com', $cnames[1]['Domain']); + $this->assertEquals('disabled', $cnames[1]['Status']); + $this->assertEquals('20160101', $cnames[1]['LastModified']); + } + + public function testToXml() + { + $cnameConfig = new CnameConfig(); + $cnameConfig->addCname('www.foo.com'); + $cnameConfig->addCname('bar.com'); + + $xml = $cnameConfig->serializeToXml(); + $comp = new CnameConfig(); + $comp->parseFromXml($xml); + + $cnames1 = $cnameConfig->getCnames(); + $cnames2 = $comp->getCnames(); + + $this->assertEquals(count($cnames1), count($cnames2)); + $this->assertEquals(count($cnames1[0]), count($cnames2[0])); + $this->assertEquals(1, count($cnames1[0])); + $this->assertEquals($cnames1[0]['Domain'], $cnames2[0]['Domain']); + } + + public function testCnameNumberLimit() + { + $cnameConfig = new CnameConfig(); + for ($i = 0; $i < CnameConfig::OSS_MAX_RULES; $i += 1) { + $cnameConfig->addCname(strval($i) . '.foo.com'); + } + try { + $cnameConfig->addCname('www.foo.com'); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals( + $e->getMessage(), + "num of cname in the config exceeds self::OSS_MAX_RULES: " . strval(CnameConfig::OSS_MAX_RULES)); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CnameTokenInfoTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CnameTokenInfoTest.php new file mode 100644 index 0000000..082118e --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CnameTokenInfoTest.php @@ -0,0 +1,31 @@ + + + bucket + www.foo.com + 1234 + 20150101 + +BBBB; + + public function testFromXml() + { + $info = new CnameTokenInfo(); + $info->parseFromXml($this->xml1); + + $this->assertEquals('bucket', $info->getBucket()); + $this->assertEquals('www.foo.com', $info->getCname()); + $this->assertEquals('1234', $info->getToken()); + $this->assertEquals('20150101', $info->getExpireTime()); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/Common.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/Common.php new file mode 100644 index 0000000..5b76a76 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/Common.php @@ -0,0 +1,169 @@ + self::getRegion(), + 'endpoint' => self::getEndpoint(), + 'provider' => $provider, + 'signatureVersion' => self::getSignVersion() + ); + + if ($conf != null) { + foreach ($conf as $key => $value) { + $config[$key] = $value; + } + } + + $ossClient = new OssClient($config); + + } catch (OssException $e) { + printf(__FUNCTION__ . "creating OssClient instance: FAILED\n"); + printf($e->getMessage() . "\n"); + } + return $ossClient; + } + + public static function getStsOssClient($conf = NULL) + { + $stsClient = new StsClient(); + $assumeRole = new AssumeRole(); + $stsClient->AccessSecret = getenv('OSS_ACCESS_KEY_SECRET'); + $assumeRole->AccessKeyId = getenv('OSS_ACCESS_KEY_ID'); + $assumeRole->RoleArn = getenv('OSS_TEST_RAM_ROLE_ARN'); + $params = $assumeRole->getAttributes(); + $response = $stsClient->doAction($params); + + try { + $provider = new StaticCredentialsProvider( + $response->Credentials->AccessKeyId, + $response->Credentials->AccessKeySecret, + $response->Credentials->SecurityToken + ); + $config = array( + 'region' => self::getRegion(), + 'endpoint' => self::getEndpoint(), + 'provider' => $provider, + 'signatureVersion' => self::getSignVersion() + ); + + if ($conf != null) { + foreach ($conf as $key => $value) { + $config[$key] = $value; + } + } + + $ossStsClient = new OssClient($config); + + } catch (OssException $e) { + printf(__FUNCTION__ . "creating OssClient instance: FAILED\n"); + printf($e->getMessage() . "\n"); + return null; + } + return $ossStsClient; + } + + public static function getBucketName() + { + $name = getenv('OSS_BUCKET'); + if (empty($name)) { + return "skyranch-php-test"; + } + return $name; + } + + public static function getRegion() + { + return getenv('OSS_TEST_REGION'); + } + + public static function getEndpoint() + { + return getenv('OSS_TEST_ENDPOINT'); + } + + public static function getCallbackUrl() + { + return getenv('OSS_TEST_CALLBACK_URL'); + } + + public static function getPayerUid() + { + return getenv('OSS_TEST_PAYER_UID'); + } + + public static function getPayerAccessKeyId() + { + return getenv('OSS_TEST_PAYER_ACCESS_KEY_ID'); + } + + public static function getPayerAccessKeySecret() + { + return getenv('OSS_TEST_PAYER_ACCESS_KEY_SECRET'); + } + + public static function getSignVersion() + { + return OssClient::OSS_SIGNATURE_VERSION_V1; + } + + public static function getPathStyleBucket() + { + return getenv('OSS_TEST_PATHSTYLE_BUCKET'); + } + + /** + * Tool method, create a bucket + */ + public static function createBucket() + { + $ossClient = self::getOssClient(); + if (is_null($ossClient)) exit(1); + $bucket = self::getBucketName(); + $acl = OssClient::OSS_ACL_TYPE_PUBLIC_READ; + try { + $ossClient->createBucket($bucket, $acl); + } catch (OssException $e) { + printf(__FUNCTION__ . ": FAILED\n"); + printf($e->getMessage() . "\n"); + return; + } + print(__FUNCTION__ . ": OK" . "\n"); + } + + /** + * Wait for bucket meta sync + */ + public static function waitMetaSync() + { + if (getenv('TRAVIS')) { + sleep(10); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ContentTypeTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ContentTypeTest.php new file mode 100644 index 0000000..98c5998 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ContentTypeTest.php @@ -0,0 +1,123 @@ +ossClient; + $headers = $client->getObjectMeta($bucket, $object); + return $headers['content-type']; + } + + public function testByFileName() + { + $client = $this->ossClient; + $bucket = $this->bucket; + + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.html'; + $object = 'test/x'; + OssUtil::generateFile($file, 5); + + $client->uploadFile($bucket, $object, $file); + $type = $this->getContentType($bucket, $object); + $this->assertEquals('text/html', $type); + unlink($file); + + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.json'; + $object = 'test/y'; + OssUtil::generateFile($file, 100 * 1024); + + $client->multiuploadFile($bucket, $object, $file, array('partSize' => 100)); + $type = $this->getContentType($bucket, $object); + unlink($file); + $this->assertEquals('application/json', $type); + } + + public function testByObjectKey() + { + $client = $this->ossClient; + $bucket = $this->bucket; + + $object = "test/x.txt"; + $client->putObject($bucket, $object, "hello world"); + $type = $this->getContentType($bucket, $object); + $this->assertEquals('text/plain', $type); + + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.html'; + $object = 'test/x.txt'; + OssUtil::generateFile($file, 5); + $client->uploadFile($bucket, $object, $file); + unlink($file); + $type = $this->getContentType($bucket, $object); + $this->assertEquals('text/html', $type); + + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.none'; + $object = 'test/x.txt'; + OssUtil::generateFile($file, 5); + $client->uploadFile($bucket, $object, $file); + unlink($file); + $type = $this->getContentType($bucket, $object); + $this->assertEquals('text/plain', $type); + + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.mp3'; + OssUtil::generateFile($file, 1024 * 100); + $object = 'test/y.json'; + $client->multiuploadFile($bucket, $object, $file, array('partSize' => 100)); + unlink($file); + $type = $this->getContentType($bucket, $object); + $this->assertEquals('audio/mpeg', $type); + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.none'; + OssUtil::generateFile($file, 1024 * 100); + $object = 'test/y.json'; + $client->multiuploadFile($bucket, $object, $file, array('partSize' => 100)); + unlink($file); + $type = $this->getContentType($bucket, $object); + $this->assertEquals('application/json', $type); + } + + public function testByUser() + { + $client = $this->ossClient; + $bucket = $this->bucket; + + $object = "test/x.txt"; + $client->putObject($bucket, $object, "hello world", array( + 'Content-Type' => 'text/html' + )); + $type = $this->getContentType($bucket, $object); + + $this->assertEquals('text/html', $type); + + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.html'; + $object = 'test/x'; + OssUtil::generateFile($file, 100); + + $client->uploadFile($bucket, $object, $file, array(OssClient::OSS_HEADERS => array( + 'Content-Type' => 'application/json' + ))); + unlink($file); + $type = $this->getContentType($bucket, $object); + + $this->assertEquals('application/json', $type); + + $file = __DIR__ . DIRECTORY_SEPARATOR . 'x.json'; + $object = 'test/y'; + OssUtil::generateFile($file, 100 * 1024); + + $client->multiuploadFile($bucket, $object, $file, array( + 'partSize' => 100, + 'Content-Type' => 'audio/mpeg' + )); + unlink($file); + $type = $this->getContentType($bucket, $object); + $this->assertEquals('audio/mpeg', $type); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CopyObjectResult.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CopyObjectResult.php new file mode 100644 index 0000000..7d1b0fb --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CopyObjectResult.php @@ -0,0 +1,52 @@ + + + Fri, 24 Feb 2012 07:18:48 GMT + "5B3C1A2E053D763E1B002CC607C5A0FE" + +BBBB; + + public function testNullResponse() + { + $response = null; + try { + new CopyObjectResult($response); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('raw response is null', $e->getMessage()); + } + } + + public function testOkResponse() + { + $header= array(); + $response = new ResponseCore($header, $this->body, 200); + $result = new CopyObjectResult($response); + $data = $result->getData(); + $this->assertTrue($result->isOK()); + $this->assertEquals("Fri, 24 Feb 2012 07:18:48 GMT", $data[0]); + $this->assertEquals("\"5B3C1A2E053D763E1B002CC607C5A0FE\"", $data[1]); + } + + public function testFailResponse() + { + $response = new ResponseCore(array(), "", 404); + try { + new CopyObjectResult($response); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertFalse(false); + } + } + +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CorsConfigTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CorsConfigTest.php new file mode 100644 index 0000000..42a46fa --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/CorsConfigTest.php @@ -0,0 +1,211 @@ + + + +http://www.b.com +http://www.a.com +http://www.a.com +GET +PUT +POST +x-oss-test +x-oss-test2 +x-oss-test2 +x-oss-test3 +x-oss-test1 +x-oss-test1 +x-oss-test2 +10 + + +http://www.b.com +GET +x-oss-test +x-oss-test1 +110 + +false + +BBBB; + + private $validXml2 = << + + +http://www.b.com +http://www.a.com +http://www.a.com +GET +PUT +POST +x-oss-test +x-oss-test2 +x-oss-test2 +x-oss-test3 +x-oss-test1 +x-oss-test1 +x-oss-test2 +10 + + +BBBB; + + private $validXml3 = << + + +http://www.b.com +http://www.a.com +http://www.a.com +GET +PUT +POST +x-oss-test +10 + +true + +BBBB; + + public function testParseValidXml() + { + $corsConfig = new CorsConfig(); + $corsConfig->parseFromXml($this->validXml); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($corsConfig->serializeToXml())); + $this->assertNotNull($corsConfig->getRules()); + $rules = $corsConfig->getRules(); + $this->assertNotNull($rules[0]->getAllowedHeaders()); + $this->assertNotNull($rules[0]->getAllowedMethods()); + $this->assertNotNull($rules[0]->getAllowedOrigins()); + $this->assertNotNull($rules[0]->getExposeHeaders()); + $this->assertNotNull($rules[0]->getMaxAgeSeconds()); + } + + public function testParseValidXml2() + { + $corsConfig = new CorsConfig(); + $corsConfig->parseFromXml($this->validXml2); + $this->assertEquals($this->cleanXml($this->validXml2), $this->cleanXml($corsConfig->serializeToXml())); + } + + public function testParseValidXml3() + { + $corsConfig = new CorsConfig(); + $corsConfig->parseFromXml($this->validXml3); + $this->assertEquals($this->cleanXml($this->validXml3), $this->cleanXml($corsConfig->serializeToXml())); + $this->assertTrue($corsConfig->getResponseVary()); + } + + public function testResponseValidXml3() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetCorsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $this->assertNotNull($result->getRawResponse()->body); + $corsConfig = $result->getData(); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($corsConfig->serializeToXml())); + $this->assertNotNull($corsConfig->getRules()); + $rules = $corsConfig->getRules(); + $this->assertNotNull($rules[0]->getAllowedHeaders()); + $this->assertNotNull($rules[0]->getAllowedMethods()); + $this->assertNotNull($rules[0]->getAllowedOrigins()); + $this->assertNotNull($rules[0]->getExposeHeaders()); + $this->assertNotNull($rules[0]->getMaxAgeSeconds()); + $this->assertFalse($corsConfig->getResponseVary()); + + } + + public function testResponseValidXml4() + { + $response = new ResponseCore(array(), $this->validXml3, 200); + $result = new GetCorsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $this->assertNotNull($result->getRawResponse()->body); + $corsConfig = $result->getData(); + $this->assertEquals($this->cleanXml($this->validXml3), $this->cleanXml($corsConfig->serializeToXml())); + $this->assertNotNull($corsConfig->getRules()); + $rules = $corsConfig->getRules(); + $this->assertNotNull($rules[0]->getAllowedHeaders()); + $this->assertNotNull($rules[0]->getAllowedMethods()); + $this->assertNotNull($rules[0]->getAllowedOrigins()); + $this->assertNotNull($rules[0]->getExposeHeaders()); + $this->assertNotNull($rules[0]->getMaxAgeSeconds()); + $this->assertTrue($corsConfig->getResponseVary()); + + } + + public function testCreateCorsConfigFromMoreThan10Rules() + { + $corsConfig = new CorsConfig(); + $rule = new CorsRule(); + for ($i = 0; $i < CorsConfig::OSS_MAX_RULES; $i += 1) { + $corsConfig->addRule($rule); + } + try { + $corsConfig->addRule($rule); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals($e->getMessage(), "num of rules in the config exceeds self::OSS_MAX_RULES: " . strval(CorsConfig::OSS_MAX_RULES)); + } + } + + public function testCreateCorsConfigParamAbsent() + { + $corsConfig = new CorsConfig(); + $rule = new CorsRule(); + $corsConfig->addRule($rule); + + try { + $xml = $corsConfig->serializeToXml(); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals($e->getMessage(), "maxAgeSeconds is not set in the Rule"); + } + } + + public function testCreateCorsConfigFromScratch() + { + $corsConfig = new CorsConfig(); + $rule = new CorsRule(); + $rule->addAllowedHeader("x-oss-test"); + $rule->addAllowedHeader("x-oss-test2"); + $rule->addAllowedHeader("x-oss-test2"); + $rule->addAllowedHeader("x-oss-test3"); + $rule->addAllowedOrigin("http://www.b.com"); + $rule->addAllowedOrigin("http://www.a.com"); + $rule->addAllowedOrigin("http://www.a.com"); + $rule->addAllowedMethod("GET"); + $rule->addAllowedMethod("PUT"); + $rule->addAllowedMethod("POST"); + $rule->addExposeHeader("x-oss-test1"); + $rule->addExposeHeader("x-oss-test1"); + $rule->addExposeHeader("x-oss-test2"); + $rule->setMaxAgeSeconds(10); + $corsConfig->addRule($rule); + $this->assertEquals($this->cleanXml($this->validXml2), $this->cleanXml($corsConfig->serializeToXml())); + $this->assertEquals($this->cleanXml($this->validXml2), $this->cleanXml(strval($corsConfig))); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/DeleteObjectVersionsResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/DeleteObjectVersionsResultTest.php new file mode 100644 index 0000000..2419e55 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/DeleteObjectVersionsResultTest.php @@ -0,0 +1,187 @@ + + + + demo.jpg + CAEQNRiBgICEoPiC0BYiIGMxZWJmYmMzYjE0OTQ0ZmZhYjgzNzkzYjc2NjZk**** + true + 111111 + + +BBBB; + + private $validXml1 = << + + + multipart.data + CAEQNRiBgIDyz.6C0BYiIGQ2NWEwNmVhNTA3ZTQ3MzM5ODliYjM1ZTdjYjA4**** + + +BBBB; + + private $validXml2 = << + + + multipart.data + true + CAEQMhiBgIDXiaaB0BYiIGQzYmRkZGUxMTM1ZDRjOTZhNjk4YjRjMTAyZjhl**** + + + test.jpg + true + CAEQMhiBgIDB3aWB0BYiIGUzYTA3YzliMzVmNzRkZGM5NjllYTVlMjYyYWEy**** + + +BBBB; + + private $validXml3 = << + + + multipart.data + + + test.jpg + + + demo.jpg + + +BBBB; + + private $validXml4 = << + + url + + multipart%2F.data + + + test%2F.jpg + + + demo%2F.jpg + + +BBBB; + + private $invalidXml = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new DeleteObjectVersionsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $list = $result->getData(); + $this->assertEquals(1, count($list)); + $this->assertEquals('demo.jpg', $list[0]->getKey()); + $this->assertEquals('CAEQNRiBgICEoPiC0BYiIGMxZWJmYmMzYjE0OTQ0ZmZhYjgzNzkzYjc2NjZk****', $list[0]->getVersionId()); + $this->assertEquals('true', $list[0]->getDeleteMarker()); + $this->assertEquals('111111', $list[0]->getDeleteMarkerVersionId()); + + + $response = new ResponseCore(array(), $this->validXml1, 200); + $result = new DeleteObjectVersionsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $list = $result->getData(); + $this->assertEquals(1, count($list)); + $this->assertEquals('multipart.data', $list[0]->getKey()); + $this->assertEquals('CAEQNRiBgIDyz.6C0BYiIGQ2NWEwNmVhNTA3ZTQ3MzM5ODliYjM1ZTdjYjA4****', $list[0]->getVersionId()); + $this->assertEquals('', $list[0]->getDeleteMarker()); + $this->assertEquals('', $list[0]->getDeleteMarkerVersionId()); + + $response = new ResponseCore(array(), $this->validXml2, 200); + $result = new DeleteObjectVersionsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $list = $result->getData(); + $this->assertEquals(2, count($list)); + $this->assertEquals('multipart.data', $list[0]->getKey()); + $this->assertEquals('', $list[0]->getVersionId()); + $this->assertEquals('true', $list[0]->getDeleteMarker()); + $this->assertEquals('CAEQMhiBgIDXiaaB0BYiIGQzYmRkZGUxMTM1ZDRjOTZhNjk4YjRjMTAyZjhl****', $list[0]->getDeleteMarkerVersionId()); + $this->assertEquals('test.jpg', $list[1]->getKey()); + $this->assertEquals('', $list[1]->getVersionId()); + $this->assertEquals('true', $list[1]->getDeleteMarker()); + $this->assertEquals('CAEQMhiBgIDB3aWB0BYiIGUzYTA3YzliMzVmNzRkZGM5NjllYTVlMjYyYWEy****', $list[1]->getDeleteMarkerVersionId()); + + + $response = new ResponseCore(array(), $this->validXml3, 200); + $result = new DeleteObjectVersionsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $list = $result->getData(); + $this->assertEquals(3, count($list)); + $this->assertEquals('multipart.data', $list[0]->getKey()); + $this->assertEquals('', $list[0]->getVersionId()); + $this->assertEquals('', $list[0]->getDeleteMarker()); + $this->assertEquals('', $list[0]->getDeleteMarkerVersionId()); + $this->assertEquals('test.jpg', $list[1]->getKey()); + $this->assertEquals('', $list[1]->getVersionId()); + $this->assertEquals('', $list[1]->getDeleteMarker()); + $this->assertEquals('', $list[1]->getDeleteMarkerVersionId()); + $this->assertEquals('demo.jpg', $list[2]->getKey()); + $this->assertEquals('', $list[2]->getVersionId()); + $this->assertEquals('', $list[2]->getDeleteMarker()); + $this->assertEquals('', $list[2]->getDeleteMarkerVersionId()); + + $response = new ResponseCore(array(), $this->validXml4, 200); + $result = new DeleteObjectVersionsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $list = $result->getData(); + $this->assertEquals(3, count($list)); + $this->assertEquals('multipart/.data', $list[0]->getKey()); + $this->assertEquals('', $list[0]->getVersionId()); + $this->assertEquals('', $list[0]->getDeleteMarker()); + $this->assertEquals('', $list[0]->getDeleteMarkerVersionId()); + $this->assertEquals('test/.jpg', $list[1]->getKey()); + $this->assertEquals('', $list[1]->getVersionId()); + $this->assertEquals('', $list[1]->getDeleteMarker()); + $this->assertEquals('', $list[1]->getDeleteMarkerVersionId()); + $this->assertEquals('demo/.jpg', $list[2]->getKey()); + $this->assertEquals('', $list[2]->getVersionId()); + $this->assertEquals('', $list[2]->getDeleteMarker()); + $this->assertEquals('', $list[2]->getDeleteMarkerVersionId()); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + $result = new DeleteObjectVersionsResult($response); + $list = $result->getData(); + $this->assertEquals(0, count($list)); + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + $result = new DeleteObjectVersionsResult($response); + $list = $result->getData(); + $this->assertEquals(0, count($list)); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ExistResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ExistResultTest.php new file mode 100644 index 0000000..f9c552e --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ExistResultTest.php @@ -0,0 +1,38 @@ +assertTrue($result->isOK()); + $this->assertEquals($result->getData(), true); + } + + public function testParseInvalid404() + { + $response = new ResponseCore(array(), "", 404); + $result = new ExistResult($response); + $this->assertTrue($result->isOK()); + $this->assertEquals($result->getData(), false); + } + + public function testInvalidResponse() + { + $response = new ResponseCore(array(), "", 300); + try { + new ExistResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketEncryptionResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketEncryptionResultTest.php new file mode 100644 index 0000000..87e4996 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketEncryptionResultTest.php @@ -0,0 +1,95 @@ + + + + AES256 + + + +BBBB; + + private $validXml1 = << + + + KMS + kms-id + + +BBBB; + + private $validXml2 = << + + +KMS + + +BBBB; + + private $invalidXml = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetBucketEncryptionResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $config = $result->getData(); + $this->assertEquals("AES256", $config->getSSEAlgorithm()); + $this->assertEquals("", $config->getKMSMasterKeyID()); + + + $response = new ResponseCore(array(), $this->validXml1, 200); + $result = new GetBucketEncryptionResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $config = $result->getData(); + $this->assertEquals("KMS", $config->getSSEAlgorithm()); + $this->assertEquals("kms-id", $config->getKMSMasterKeyID()); + + $response = new ResponseCore(array(), $this->validXml2, 200); + $result = new GetBucketEncryptionResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $config = $result->getData(); + $this->assertEquals("KMS", $config->getSSEAlgorithm()); + $this->assertEquals(null, $config->getKMSMasterKeyID()); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + $result = new GetBucketEncryptionResult($response); + $config = $result->getData(); + $this->assertEquals(null, $config->getSSEAlgorithm()); + $this->assertEquals(null, $config->getKMSMasterKeyID()); + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + $result = new GetBucketEncryptionResult($response); + $config = $result->getData(); + $this->assertEquals(null, $config->getSSEAlgorithm()); + $this->assertEquals(null, $config->getKMSMasterKeyID()); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketRequestPaymentResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketRequestPaymentResultTest.php new file mode 100644 index 0000000..227028b --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketRequestPaymentResultTest.php @@ -0,0 +1,66 @@ + + + Requester + +BBBB; + + private $validXml2 = << + + BucketOwner + +BBBB; + + private $invalidXml = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetBucketRequestPaymentResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $payer = $result->getData(); + $this->assertEquals("Requester", $payer); + + $response = new ResponseCore(array(), $this->validXml2, 200); + $result = new GetBucketRequestPaymentResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $payer = $result->getData(); + $this->assertEquals("BucketOwner", $payer); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + $result = new GetBucketRequestPaymentResult($response); + $payer = $result->getData(); + $this->assertEquals(null, $payer); + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + $result = new GetBucketRequestPaymentResult($response); + $payer = $result->getData(); + $this->assertEquals(null, $payer); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketStatResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketStatResultTest.php new file mode 100644 index 0000000..74cb04a --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketStatResultTest.php @@ -0,0 +1,85 @@ + + + 1600 + 230 + 40 + 4 + 1643341269 + 430 + 66 + 2359296 + 360 + 54 + 2949120 + 450 + 74 + 2359296 + 360 + 36 + +BBBB; + +private $invalidXml = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetBucketStatResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $stat = $result->getData(); + $this->assertEquals(1600, $stat->getStorage()); + $this->assertEquals(230, $stat->getObjectCount()); + $this->assertEquals(40, $stat->getMultipartUploadCount()); + $this->assertEquals(4, $stat->getLiveChannelCount()); + $this->assertEquals(1643341269, $stat->getLastModifiedTime()); + $this->assertEquals(430, $stat->getStandardStorage()); + $this->assertEquals(66, $stat->getStandardObjectCount()); + $this->assertEquals(2359296, $stat->getInfrequentAccessStorage()); + $this->assertEquals(360, $stat->getInfrequentAccessRealStorage()); + $this->assertEquals(54, $stat->getInfrequentAccessObjectCount()); + $this->assertEquals(2949120, $stat->getArchiveStorage()); + $this->assertEquals(450, $stat->getArchiveRealStorage()); + $this->assertEquals(74, $stat->getArchiveObjectCount()); + $this->assertEquals(2359296, $stat->getColdArchiveStorage()); + $this->assertEquals(360, $stat->getColdArchiveRealStorage()); + $this->assertEquals(36, $stat->getColdArchiveObjectCount()); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + $result = new GetBucketStatResult($response); + $stat = $result->getData(); + $this->assertEquals(0, $stat->getStorage()); + $this->assertEquals(0, $stat->getObjectCount()); + $this->assertEquals(0, $stat->getMultipartUploadCount()); + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + $result = new GetBucketStatResult($response); + $stat = $result->getData(); + $this->assertEquals(0, $stat->getStorage()); + $this->assertEquals(0, $stat->getObjectCount()); + $this->assertEquals(0, $stat->getMultipartUploadCount()); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketTagsResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketTagsResultTest.php new file mode 100644 index 0000000..b292309 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketTagsResultTest.php @@ -0,0 +1,77 @@ + + + + + testa + value1-test + + + testb + value2-test + + + +BBBB; + + private $invalidXml = << + + +BBBB; + + private $invalidXml2 = << + + + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetBucketTagsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $config = $result->getData(); + $this->assertEquals(2, count($config->getTags())); + $this->assertEquals("testa", $config->getTags()[0]->getKey()); + $this->assertEquals("value1-test", $config->getTags()[0]->getValue()); + $this->assertEquals("testb", $config->getTags()[1]->getKey()); + $this->assertEquals("value2-test", $config->getTags()[1]->getValue()); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + $result = new GetBucketTagsResult($response); + $config = $result->getData(); + $this->assertEquals(0, count($config->getTags())); + + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + $result = new GetBucketTagsResult($response); + $config = $result->getData(); + $this->assertEquals(0, count($config->getTags())); + + $response = new ResponseCore(array(), $this->invalidXml2, 200); + $result = new GetBucketTagsResult($response); + $config = $result->getData(); + $this->assertEquals(0, count($config->getTags())); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketTransferAccelerationResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketTransferAccelerationResultTest.php new file mode 100644 index 0000000..56a3dd4 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketTransferAccelerationResultTest.php @@ -0,0 +1,61 @@ + +true + +BBBB; + private $validXml1 = << +false + +BBBB; + + private $invalidXml2 = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetBucketTransferAccelerationResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $enabled = $result->getData(); + $this->assertEquals(true, $enabled); + } + + public function testParseValidXml1() + { + $response = new ResponseCore(array(), $this->validXml1, 200); + $result = new GetBucketTransferAccelerationResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $enabled = $result->getData(); + $this->assertEquals(false, $enabled); + } + + public function testParseInvalidXml2() + { + $response = new ResponseCore(array(), $this->invalidXml2, 200); + $result = new GetBucketTransferAccelerationResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $this->assertNotNull($result->getRawResponse()->body); + $enabled = $result->getData(); + $this->assertEquals(false, $enabled); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketWormResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketWormResultTest.php new file mode 100644 index 0000000..3bb90da --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetBucketWormResultTest.php @@ -0,0 +1,84 @@ + + +ID1 +Locked +1 +2018-08-14T15:50:32 + +BBBB; + + private $validXml2 = << + + ID2 + InProgress + 10 + 2018-09-14T15:50:32 + +BBBB; + + private $invalidXml = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetBucketWormResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $config = $result->getData(); + $this->assertEquals("ID1", $config->getWormId()); + $this->assertEquals("Locked", $config->getState()); + $this->assertEquals(1, $config->getDay()); + $this->assertEquals("2018-08-14T15:50:32", $config->getCreationDate()); + + $response = new ResponseCore(array(), $this->validXml2, 200); + $result = new GetBucketWormResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $config = $result->getData(); + $this->assertEquals("ID2", $config->getWormId()); + $this->assertEquals("InProgress", $config->getState()); + $this->assertEquals(10, $config->getDay()); + $this->assertEquals("2018-09-14T15:50:32", $config->getCreationDate()); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + $result = new GetBucketWormResult($response); + $config = $result->getData(); + $this->assertEquals("", $config->getWormId()); + $this->assertEquals("", $config->getState()); + $this->assertEquals(0, $config->getDay()); + $this->assertEquals("", $config->getCreationDate()); + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + $result = new GetBucketWormResult($response); + $config = $result->getData(); + $this->assertEquals("", $config->getWormId()); + $this->assertEquals("", $config->getState()); + $this->assertEquals(0, $config->getDay()); + $this->assertEquals("", $config->getCreationDate()); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetCorsResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetCorsResultTest.php new file mode 100644 index 0000000..76d87dc --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetCorsResultTest.php @@ -0,0 +1,67 @@ + + + +http://www.b.com +http://www.a.com +http://www.a.com +GET +PUT +POST +x-oss-test +x-oss-test2 +x-oss-test2 +x-oss-test3 +x-oss-test1 +x-oss-test1 +x-oss-test2 +10 + + +http://www.b.com +GET +x-oss-test +x-oss-test1 +110 + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetCorsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $corsConfig = $result->getData(); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($corsConfig->serializeToXml())); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } + + public function testInvalidResponse() + { + $response = new ResponseCore(array(), $this->validXml, 300); + try { + $result = new GetCorsResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetLifecycleResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetLifecycleResultTest.php new file mode 100644 index 0000000..e6d9a72 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetLifecycleResultTest.php @@ -0,0 +1,59 @@ + + + +delete obsoleted files +obsoleted/ +Enabled +3 + + +delete temporary files +temporary/ +Enabled +2022-10-12T00:00:00.000Z +2022-10-12T00:00:00.000Z + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetLifecycleResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $lifecycleConfig = $result->getData(); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($lifecycleConfig->serializeToXml())); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } + + public function testInvalidResponse() + { + $response = new ResponseCore(array(), $this->validXml, 300); + try { + $result = new GetLifecycleResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } + +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetLoggingResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetLoggingResultTest.php new file mode 100644 index 0000000..35f7436 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetLoggingResultTest.php @@ -0,0 +1,51 @@ + + + +TargetBucket +TargetPrefix + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetLoggingResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $loggingConfig = $result->getData(); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($loggingConfig->serializeToXml())); + $this->assertEquals("TargetBucket", $loggingConfig->getTargetBucket()); + $this->assertEquals("TargetPrefix", $loggingConfig->getTargetPrefix()); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } + + public function testInvalidResponse() + { + $response = new ResponseCore(array(), $this->validXml, 300); + try { + $result = new GetLoggingResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetRefererResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetRefererResultTest.php new file mode 100644 index 0000000..774aae9 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetRefererResultTest.php @@ -0,0 +1,51 @@ + + +true + +http://www.aliyun.com +https://www.aliyun.com +http://www.*.com +https://www.?.aliyuncs.com + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetRefererResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $refererConfig = $result->getData(); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($refererConfig->serializeToXml())); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } + + public function testInvalidResponse() + { + $response = new ResponseCore(array(), $this->validXml, 300); + try { + $result = new GetRefererResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetWebsiteResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetWebsiteResultTest.php new file mode 100644 index 0000000..d853306 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/GetWebsiteResultTest.php @@ -0,0 +1,50 @@ + + + +index.html + + +errorDocument.html + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetWebsiteResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $websiteConfig = $result->getData(); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($websiteConfig->serializeToXml())); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } + + public function testInvalidResponse() + { + $response = new ResponseCore(array(), $this->validXml, 300); + try { + $result = new GetWebsiteResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/HeaderResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/HeaderResultTest.php new file mode 100644 index 0000000..9354422 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/HeaderResultTest.php @@ -0,0 +1,23 @@ + 'value'), "", 200); + $result = new HeaderResult($response); + $this->assertTrue($result->isOK()); + $this->assertTrue(is_array($result->getData())); + $data = $result->getData(); + $this->assertEquals($data['key'], 'value'); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/HttpTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/HttpTest.php new file mode 100644 index 0000000..989644c --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/HttpTest.php @@ -0,0 +1,77 @@ +assertFalse($res->isOK()); + $this->assertTrue($res->isOK(500)); + } + + public function testGet() + { + $httpCore = new RequestCore("http://www.baidu.com"); + $httpResponse = $httpCore->send_request(); + $this->assertNotNull($httpResponse); + } + + public function testSetProxyAndTimeout() + { + $httpCore = new RequestCore("http://www.baidu.com"); + $httpCore->set_proxy("1.0.2.1:8888"); + $httpCore->connect_timeout = 1; + try { + $httpResponse = $httpCore->send_request(); + $this->assertTrue(false); + } catch (RequestCore_Exception $e) { + $this->assertTrue(true); + } + } + + public function testGetParseTrue() + { + $httpCore = new RequestCore("http://www.baidu.com"); + $httpCore->curlopts = array(CURLOPT_HEADER => true); + $url = $httpCore->send_request(true); + foreach ($httpCore->get_response_header() as $key => $value) { + $this->assertEquals($httpCore->get_response_header($key), $value); + } + $this->assertNotNull($url); + } + + public function testParseResponse() + { + $httpCore = new RequestCore("http://www.baidu.com"); + $response = $httpCore->send_request(); + $parsed = $httpCore->process_response(null, $response); + $this->assertNotNull($parsed); + } + + public function testExceptionGet() + { + $httpCore = null; + $exception = false; + try { + $httpCore = new RequestCore("http://www.notexistsitexx.com"); + $httpCore->set_body(""); + $httpCore->set_method("GET"); + $httpCore->connect_timeout = 10; + $httpCore->timeout = 10; + $res = $httpCore->send_request(); + } catch (RequestCore_Exception $e) { + $exception = true; + } + $this->assertTrue($exception); + } +} + + diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/InitiateMultipartUploadResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/InitiateMultipartUploadResultTest.php new file mode 100644 index 0000000..76b10a6 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/InitiateMultipartUploadResultTest.php @@ -0,0 +1,47 @@ + + + multipart_upload + multipart.data + 0004B9894A22E5B1888A1E29F8236E2D + +BBBB; + + private $invalidXml = << + + multipart_upload + multipart.data + +BBBB; + + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new InitiateMultipartUploadResult($response); + $this->assertEquals("0004B9894A22E5B1888A1E29F8236E2D", $result->getData()); + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + try { + $result = new InitiateMultipartUploadResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LifecycleConfigTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LifecycleConfigTest.php new file mode 100644 index 0000000..063e436 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LifecycleConfigTest.php @@ -0,0 +1,130 @@ + + + +delete obsoleted files +obsoleted/ +Enabled +3 + + +delete temporary files +temporary/ +Enabled +2022-10-12T00:00:00.000Z +2022-10-12T00:00:00.000Z + + +BBBB; + + private $validLifecycle2 = << + +delete temporary files +temporary/ +Enabled +2022-10-12T00:00:00.000Z +2022-10-12T00:00:00.000Z + + +BBBB; + + private $nullLifecycle = << + +BBBB; + + public function testConstructValidConfig() + { + $lifecycleConfig = new LifecycleConfig(); + $actions = array(); + $actions[] = new LifecycleAction("Expiration", "Days", 3); + $lifecycleRule = new LifecycleRule("delete obsoleted files", "obsoleted/", "Enabled", $actions); + $lifecycleConfig->addRule($lifecycleRule); + $actions = array(); + $actions[] = new LifecycleAction("Expiration", "Date", '2022-10-12T00:00:00.000Z'); + $actions[] = new LifecycleAction("Expiration2", "Date", '2022-10-12T00:00:00.000Z'); + $lifecycleRule = new LifecycleRule("delete temporary files", "temporary/", "Enabled", $actions); + $lifecycleConfig->addRule($lifecycleRule); + try { + $lifecycleConfig->addRule(null); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('lifecycleRule is null', $e->getMessage()); + } + $this->assertEquals($this->cleanXml(strval($lifecycleConfig)), $this->cleanXml($this->validLifecycle)); + } + + public function testParseValidXml() + { + $lifecycleConfig = new LifecycleConfig(); + $lifecycleConfig->parseFromXml($this->validLifecycle); + $this->assertEquals($this->cleanXml($lifecycleConfig->serializeToXml()), $this->cleanXml($this->validLifecycle)); + $this->assertEquals(2, count($lifecycleConfig->getRules())); + $rules = $lifecycleConfig->getRules(); + $this->assertEquals('delete temporary files', $rules[1]->getId()); + } + + public function testParseValidXml2() + { + $lifecycleConfig = new LifecycleConfig(); + $lifecycleConfig->parseFromXml($this->validLifecycle2); + $this->assertEquals($this->cleanXml($lifecycleConfig->serializeToXml()), $this->cleanXml($this->validLifecycle2)); + $this->assertEquals(1, count($lifecycleConfig->getRules())); + $rules = $lifecycleConfig->getRules(); + $this->assertEquals('delete temporary files', $rules[0]->getId()); + } + + public function testParseNullXml() + { + $lifecycleConfig = new LifecycleConfig(); + $lifecycleConfig->parseFromXml($this->nullLifecycle); + $this->assertEquals($this->cleanXml($lifecycleConfig->serializeToXml()), $this->cleanXml($this->nullLifecycle)); + $this->assertEquals(0, count($lifecycleConfig->getRules())); + } + + public function testLifecycleRule() + { + $lifecycleRule = new LifecycleRule("x", "x", "x", array('x')); + $lifecycleRule->setId("id"); + $lifecycleRule->setPrefix("prefix"); + $lifecycleRule->setStatus("Enabled"); + $lifecycleRule->setActions(array()); + + $this->assertEquals('id', $lifecycleRule->getId()); + $this->assertEquals('prefix', $lifecycleRule->getPrefix()); + $this->assertEquals('Enabled', $lifecycleRule->getStatus()); + $this->assertEmpty($lifecycleRule->getActions()); + } + + public function testLifecycleAction() + { + $action = new LifecycleAction('x', 'x', 'x'); + $this->assertEquals($action->getAction(), 'x'); + $this->assertEquals($action->getTimeSpec(), 'x'); + $this->assertEquals($action->getTimeValue(), 'x'); + $action->setAction('y'); + $action->setTimeSpec('y'); + $action->setTimeValue('y'); + $this->assertEquals($action->getAction(), 'y'); + $this->assertEquals($action->getTimeSpec(), 'y'); + $this->assertEquals($action->getTimeValue(), 'y'); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListBucketsResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListBucketsResultTest.php new file mode 100644 index 0000000..959b011 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListBucketsResultTest.php @@ -0,0 +1,168 @@ + + + + ut_test_put_bucket + ut_test_put_bucket + + + + oss-cn-hangzhou-a + xz02tphky6fjfiuc0 + 2014-05-15T11:18:32.000Z + + + oss-cn-hangzhou-a + xz02tphky6fjfiuc1 + 2014-05-15T11:18:32.000Z + + + +BBBB; + + private $nullXml = << + + + ut_test_put_bucket + ut_test_put_bucket + + + + +BBBB; + + + private $errorBody = <<< BBBB + + + NoSuchBucket + The specified bucket does not exist. + 566B870D207FB3044302EB0A + hello.oss-test.aliyun-inc.com + hello + +BBBB; + + private $xml = << + + + ut_test_put_bucket + ut_test_put_bucket + + + + 2015-12-17T18:12:43.000Z + oss-cn-shanghai.aliyuncs.com + oss-cn-shanghai-internal.aliyuncs.com + oss-cn-shanghai + app-base-oss + cn-shanghai + Standard + + + 2014-12-25T11:21:04.000Z + oss-cn-hangzhou.aliyuncs.com + oss-cn-hangzhou-internal.aliyuncs.com + oss-cn-hangzhou + atestleo23 + cn-hangzhou + IA + + + 2014-12-25T11:21:04.000Z + oss-cn-hangzhou + atestleo23 + + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new ListBucketsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $bucketListInfo = $result->getData(); + $this->assertEquals(2, count($bucketListInfo->getBucketList())); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), $this->nullXml, 200); + $result = new ListBucketsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $bucketListInfo = $result->getData(); + $this->assertEquals(0, count($bucketListInfo->getBucketList())); + } + + public function test403() + { + $errorHeader = array( + 'x-oss-request-id' => '1a2b-3c4d' + ); + $response = new ResponseCore($errorHeader, $this->errorBody, 403); + try { + new ListBucketsResult($response); + } catch (OssException $e) { + $this->assertEquals( + $e->getMessage(), + 'NoSuchBucket: The specified bucket does not exist. RequestId: 1a2b-3c4d'); + $this->assertEquals($e->getHTTPStatus(), '403'); + $this->assertEquals($e->getRequestId(), '1a2b-3c4d'); + $this->assertEquals($e->getErrorCode(), 'NoSuchBucket'); + $this->assertEquals($e->getErrorMessage(), 'The specified bucket does not exist.'); + $this->assertEquals($e->getDetails(), $this->errorBody); + } + } + + public function testParseXml2() + { + $response = new ResponseCore(array(), $this->xml, 200); + $result = new ListBucketsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $bucketListInfo = $result->getData(); + $this->assertEquals(3, count($bucketListInfo->getBucketList())); + $this->assertEquals("2015-12-17T18:12:43.000Z", $bucketListInfo->getBucketList()[0]->getCreateDate()); + $this->assertEquals("oss-cn-shanghai", $bucketListInfo->getBucketList()[0]->getLocation()); + $this->assertEquals("app-base-oss", $bucketListInfo->getBucketList()[0]->getName()); + $this->assertEquals("oss-cn-shanghai.aliyuncs.com", $bucketListInfo->getBucketList()[0]->getExtranetEndpoint()); + $this->assertEquals("oss-cn-shanghai-internal.aliyuncs.com", $bucketListInfo->getBucketList()[0]->getIntranetEndpoint()); + $this->assertEquals("cn-shanghai", $bucketListInfo->getBucketList()[0]->getRegion()); + $this->assertEquals("Standard", $bucketListInfo->getBucketList()[0]->getStorageClass()); + + $this->assertEquals("2014-12-25T11:21:04.000Z", $bucketListInfo->getBucketList()[1]->getCreateDate()); + $this->assertEquals("oss-cn-hangzhou", $bucketListInfo->getBucketList()[1]->getLocation()); + $this->assertEquals("atestleo23", $bucketListInfo->getBucketList()[1]->getName()); + $this->assertEquals("oss-cn-hangzhou.aliyuncs.com", $bucketListInfo->getBucketList()[1]->getExtranetEndpoint()); + $this->assertEquals("oss-cn-hangzhou-internal.aliyuncs.com", $bucketListInfo->getBucketList()[1]->getIntranetEndpoint()); + $this->assertEquals("cn-hangzhou", $bucketListInfo->getBucketList()[1]->getRegion()); + $this->assertEquals("IA", $bucketListInfo->getBucketList()[1]->getStorageClass()); + + $this->assertEquals("2014-12-25T11:21:04.000Z", $bucketListInfo->getBucketList()[2]->getCreateDate()); + $this->assertEquals("oss-cn-hangzhou", $bucketListInfo->getBucketList()[2]->getLocation()); + $this->assertEquals("atestleo23", $bucketListInfo->getBucketList()[2]->getName()); + $this->assertEquals(null, $bucketListInfo->getBucketList()[2]->getExtranetEndpoint()); + $this->assertEquals(null, $bucketListInfo->getBucketList()[2]->getIntranetEndpoint()); + $this->assertEquals(null, $bucketListInfo->getBucketList()[2]->getRegion()); + $this->assertEquals(null, $bucketListInfo->getBucketList()[2]->getStorageClass()); + + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListMultipartUploadResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListMultipartUploadResultTest.php new file mode 100644 index 0000000..88bd0a7 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListMultipartUploadResultTest.php @@ -0,0 +1,114 @@ + + + oss-example + xx + 3 + oss.avi + 0004B99B8E707874FC2D692FA5D77D3F + x + xx + 1000 + false + + multipart.data + 0004B999EF518A1FE585B0C9360DC4C8 + 2012-02-23T04:18:23.000Z + + + multipart.data + 0004B999EF5A239BB9138C6227D69F95 + 2012-02-23T04:18:23.000Z + + + oss.avi + 0004B99B8E707874FC2D692FA5D77D3F + 2012-02-23T06:14:27.000Z + + +BBBB; + + private $validXmlWithEncodedKey = << + + oss-example + url + php%2Bkey-marker + 3 + php%2Bnext-key-marker + 0004B99B8E707874FC2D692FA5D77D3F + %2F + php%2Bprefix + 1000 + true + + php%2Bkey-1 + 0004B999EF518A1FE585B0C9360DC4C8 + 2012-02-23T04:18:23.000Z + + + php%2Bkey-2 + 0004B999EF5A239BB9138C6227D69F95 + 2012-02-23T04:18:23.000Z + + + php%2Bkey-3 + 0004B99B8E707874FC2D692FA5D77D3F + 2012-02-23T06:14:27.000Z + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new ListMultipartUploadResult($response); + $listMultipartUploadInfo = $result->getData(); + $this->assertEquals("oss-example", $listMultipartUploadInfo->getBucket()); + $this->assertEquals("xx", $listMultipartUploadInfo->getKeyMarker()); + $this->assertEquals(3, $listMultipartUploadInfo->getUploadIdMarker()); + $this->assertEquals("oss.avi", $listMultipartUploadInfo->getNextKeyMarker()); + $this->assertEquals("0004B99B8E707874FC2D692FA5D77D3F", $listMultipartUploadInfo->getNextUploadIdMarker()); + $this->assertEquals("x", $listMultipartUploadInfo->getDelimiter()); + $this->assertEquals("xx", $listMultipartUploadInfo->getPrefix()); + $this->assertEquals(1000, $listMultipartUploadInfo->getMaxUploads()); + $this->assertEquals("false", $listMultipartUploadInfo->getIsTruncated()); + $uploads = $listMultipartUploadInfo->getUploads(); + $this->assertEquals("multipart.data", $uploads[0]->getKey()); + $this->assertEquals("0004B999EF518A1FE585B0C9360DC4C8", $uploads[0]->getUploadId()); + $this->assertEquals("2012-02-23T04:18:23.000Z", $uploads[0]->getInitiated()); + } + + public function testParseValidXmlWithEncodedKey() + { + $response = new ResponseCore(array(), $this->validXmlWithEncodedKey, 200); + $result = new ListMultipartUploadResult($response); + $listMultipartUploadInfo = $result->getData(); + $this->assertEquals("oss-example", $listMultipartUploadInfo->getBucket()); + $this->assertEquals("php+key-marker", $listMultipartUploadInfo->getKeyMarker()); + $this->assertEquals("php+next-key-marker", $listMultipartUploadInfo->getNextKeyMarker()); + $this->assertEquals(3, $listMultipartUploadInfo->getUploadIdMarker()); + $this->assertEquals("0004B99B8E707874FC2D692FA5D77D3F", $listMultipartUploadInfo->getNextUploadIdMarker()); + $this->assertEquals("/", $listMultipartUploadInfo->getDelimiter()); + $this->assertEquals("php+prefix", $listMultipartUploadInfo->getPrefix()); + $this->assertEquals(1000, $listMultipartUploadInfo->getMaxUploads()); + $this->assertEquals("true", $listMultipartUploadInfo->getIsTruncated()); + $uploads = $listMultipartUploadInfo->getUploads(); + $this->assertEquals("php+key-1", $uploads[0]->getKey()); + $this->assertEquals("0004B999EF518A1FE585B0C9360DC4C8", $uploads[0]->getUploadId()); + $this->assertEquals("2012-02-23T04:18:23.000Z", $uploads[0]->getInitiated()); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectVersionsResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectVersionsResultTest.php new file mode 100644 index 0000000..7fdfd7e --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectVersionsResultTest.php @@ -0,0 +1,215 @@ + + + oss-example + + example + CAEQMxiBgICbof2D0BYiIGRhZjgwMzJiMjA3MjQ0ODE5MWYxZDYwMzJlZjU1**** + 100 + + false + + example + CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm**** + false + 2019-04-09T07:27:28.000Z + + 1234512528586**** + 12345125285864390 + + + + example + CAEQMxiBgMDNoP2D0BYiIDE3MWUxNzgxZDQxNTRiODI5OGYwZGMwNGY3MzZjN**** + false + 2019-04-09T07:27:28.000Z + "250F8A0AE989679A22926A875F0A2****" + Normal + 93731 + Standard + + 1234512528586**** + 12345125285864390 + + + + pic.jpg + CAEQMxiBgMCZov2D0BYiIDY4MDllOTc2YmY5MjQxMzdiOGI3OTlhNTU0ODIx**** + true + 2019-04-09T07:27:28.000Z + "3663F7B0B9D3153F884C821E7CF4****" + Normal + 574768 + IA + + 1234512528586**** + 12345125285864390 + + + +BBBB; + + private $validXml1 = << + + oss-example + + example + CAEQMxiBgICbof2D0BYiIGRhZjgwMzJiMjA3MjQ0ODE5MWYxZDYwMzJlZjU1**** + 100 + + false + + example + CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm**** + true + 2019-04-09T07:27:28.000Z + + 1234512528586**** + 12345125285864390 + + + + example-1 + CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm**** + 2019-04-09T07:27:28.000Z + + 1234512528586**** + 12345125285864390 + + + + example-2 + CAEQMxiBgMDNoP2D0BYiIDE3MWUxNzgxZDQxNTRiODI5OGYwZGMwNGY3MzZjN**** + 2019-04-09T07:27:28.000Z + "250F8A0AE989679A22926A875F0A2****" + Normal + 93731 + Standard + + 1234512528586**** + 12345125285864390 + + + +BBBB; + + private $invalidXml = << + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new ListObjectVersionsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $list = $result->getData(); + $this->assertEquals(0, count($list->getPrefixList())); + $this->assertEquals(1, count($list->getDeleteMarkerList())); + $this->assertEquals(2, count($list->getObjectVersionList())); + + $this->assertEquals('oss-example', $list->getBucketName()); + $this->assertEquals('', $list->getPrefix()); + $this->assertEquals('example', $list->getKeyMarker()); + $this->assertEquals('CAEQMxiBgICbof2D0BYiIGRhZjgwMzJiMjA3MjQ0ODE5MWYxZDYwMzJlZjU1****', $list->getVersionIdMarker()); + $this->assertEquals(100, $list->getMaxKeys()); + $this->assertEquals('', $list->getDelimiter()); + $this->assertEquals('false', $list->getIsTruncated()); + + $deleteMarkerList = $list->getDeleteMarkerList(); + $this->assertEquals('example', $deleteMarkerList[0]->getKey()); + $this->assertEquals('CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****', $deleteMarkerList[0]->getVersionId()); + $this->assertEquals('false', $deleteMarkerList[0]->getIsLatest()); + $this->assertEquals('2019-04-09T07:27:28.000Z', $deleteMarkerList[0]->getLastModified()); + + $objectVersionList = $list->getObjectVersionList(); + $this->assertEquals('example', $objectVersionList[0]->getKey()); + $this->assertEquals('CAEQMxiBgMDNoP2D0BYiIDE3MWUxNzgxZDQxNTRiODI5OGYwZGMwNGY3MzZjN****', $objectVersionList[0]->getVersionId()); + $this->assertEquals('false', $objectVersionList[0]->getIsLatest()); + $this->assertEquals('2019-04-09T07:27:28.000Z', $objectVersionList[0]->getLastModified()); + $this->assertEquals('"250F8A0AE989679A22926A875F0A2****"', $objectVersionList[0]->getETag()); + $this->assertEquals('Normal', $objectVersionList[0]->getType()); + $this->assertEquals(93731, $objectVersionList[0]->getSize()); + $this->assertEquals('Standard', $objectVersionList[0]->getStorageClass()); + + $this->assertEquals('pic.jpg', $objectVersionList[1]->getKey()); + $this->assertEquals('CAEQMxiBgMCZov2D0BYiIDY4MDllOTc2YmY5MjQxMzdiOGI3OTlhNTU0ODIx****', $objectVersionList[1]->getVersionId()); + $this->assertEquals('true', $objectVersionList[1]->getIsLatest()); + $this->assertEquals('2019-04-09T07:27:28.000Z', $objectVersionList[1]->getLastModified()); + $this->assertEquals('"3663F7B0B9D3153F884C821E7CF4****"', $objectVersionList[1]->getETag()); + $this->assertEquals('Normal', $objectVersionList[1]->getType()); + $this->assertEquals(574768, $objectVersionList[1]->getSize()); + $this->assertEquals('IA', $objectVersionList[1]->getStorageClass()); + + + $response = new ResponseCore(array(), $this->validXml1, 200); + $result = new ListObjectVersionsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $list = $result->getData(); + $this->assertEquals(0, count($list->getPrefixList())); + $this->assertEquals(2, count($list->getDeleteMarkerList())); + $this->assertEquals(1, count($list->getObjectVersionList())); + + $this->assertEquals('oss-example', $list->getBucketName()); + $this->assertEquals('', $list->getPrefix()); + $this->assertEquals('example', $list->getKeyMarker()); + $this->assertEquals('CAEQMxiBgICbof2D0BYiIGRhZjgwMzJiMjA3MjQ0ODE5MWYxZDYwMzJlZjU1****', $list->getVersionIdMarker()); + $this->assertEquals(100, $list->getMaxKeys()); + $this->assertEquals('', $list->getDelimiter()); + $this->assertEquals('false', $list->getIsTruncated()); + + $deleteMarkerList = $list->getDeleteMarkerList(); + $this->assertEquals('example', $deleteMarkerList[0]->getKey()); + $this->assertEquals('CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****', $deleteMarkerList[0]->getVersionId()); + $this->assertEquals('true', $deleteMarkerList[0]->getIsLatest()); + $this->assertEquals('2019-04-09T07:27:28.000Z', $deleteMarkerList[0]->getLastModified()); + + $this->assertEquals('example-1', $deleteMarkerList[1]->getKey()); + $this->assertEquals('CAEQMxiBgICAof2D0BYiIDJhMGE3N2M1YTI1NDQzOGY5NTkyNTI3MGYyMzJm****', $deleteMarkerList[1]->getVersionId()); + $this->assertEquals('', $deleteMarkerList[1]->getIsLatest()); + $this->assertEquals('2019-04-09T07:27:28.000Z', $deleteMarkerList[1]->getLastModified()); + + $objectVersionList = $list->getObjectVersionList(); + $this->assertEquals('example-2', $objectVersionList[0]->getKey()); + $this->assertEquals('CAEQMxiBgMDNoP2D0BYiIDE3MWUxNzgxZDQxNTRiODI5OGYwZGMwNGY3MzZjN****', $objectVersionList[0]->getVersionId()); + $this->assertEquals('', $objectVersionList[0]->getIsLatest()); + $this->assertEquals('2019-04-09T07:27:28.000Z', $objectVersionList[0]->getLastModified()); + $this->assertEquals('"250F8A0AE989679A22926A875F0A2****"', $objectVersionList[0]->getETag()); + $this->assertEquals('Normal', $objectVersionList[0]->getType()); + $this->assertEquals(93731, $objectVersionList[0]->getSize()); + $this->assertEquals('Standard', $objectVersionList[0]->getStorageClass()); + } + + public function testParseNullXml() + { + $response = new ResponseCore(array(), "", 200); + $result = new ListObjectVersionsResult($response); + $list = $result->getData(); + $this->assertTrue(true); + } + + public function testParseInvalidXml() + { + $response = new ResponseCore(array(), $this->invalidXml, 200); + $result = new ListObjectVersionsResult($response); + $stat = $result->getData(); + $this->assertTrue(true); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectsResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectsResultTest.php new file mode 100644 index 0000000..d778c24 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectsResultTest.php @@ -0,0 +1,208 @@ + + + testbucket-hf + + + 1000 + / + false + + oss-php-sdk-test/ + + + test/ + + +BBBB; + + private $validXml2 = << + + testbucket-hf + oss-php-sdk-test/ + xx + 1000 + / + false + + oss-php-sdk-test/upload-test-object-name.txt + 2015-11-18T03:36:00.000Z + "89B9E567E7EB8815F2F7D41851F9A2CD" + Normal + 13115 + Standard + + cname_user + cname_user + + + +BBBB; + + private $validXmlWithEncodedKey = << + + testbucket-hf + url + php%2Fprefix + php%2Fmarker + php%2Fnext-marker + 1000 + %2F + true + + php/a%2Bb + 2015-11-18T03:36:00.000Z + "89B9E567E7EB8815F2F7D41851F9A2CD" + Normal + 13115 + Standard + + cname_user + cname_user + + + +BBBB; + + private $validXmlWithResoreInfo = << + + testbucket-hf + url + php%2Fprefix + php%2Fmarker + php%2Fnext-marker + 1000 + %2F + true + + php/a%2Bb + 2015-11-18T03:36:00.000Z + "89B9E567E7EB8815F2F7D41851F9A2CD" + Normal + 13115 + Standard + + cname_user + cname_user + + ongoing-request="false", expiry-date="Tue, 25 Apr 2023 07:30:00 GMT" + + +BBBB; + + public function testParseValidXml1() + { + $response = new ResponseCore(array(), $this->validXml1, 200); + $result = new ListObjectsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(2, count($objectListInfo->getPrefixList())); + $this->assertEquals(0, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('', $objectListInfo->getPrefix()); + $this->assertEquals('', $objectListInfo->getMarker()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('false', $objectListInfo->getIsTruncated()); + $prefixes = $objectListInfo->getPrefixList(); + $this->assertEquals('oss-php-sdk-test/', $prefixes[0]->getPrefix()); + $this->assertEquals('test/', $prefixes[1]->getPrefix()); + } + + public function testParseValidXml2() + { + $response = new ResponseCore(array(), $this->validXml2, 200); + $result = new ListObjectsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(0, count($objectListInfo->getPrefixList())); + $this->assertEquals(1, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('oss-php-sdk-test/', $objectListInfo->getPrefix()); + $this->assertEquals('xx', $objectListInfo->getMarker()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('false', $objectListInfo->getIsTruncated()); + $objects = $objectListInfo->getObjectList(); + $this->assertEquals('oss-php-sdk-test/upload-test-object-name.txt', $objects[0]->getKey()); + $this->assertEquals('2015-11-18T03:36:00.000Z', $objects[0]->getLastModified()); + $this->assertEquals('"89B9E567E7EB8815F2F7D41851F9A2CD"', $objects[0]->getETag()); + $this->assertEquals('Normal', $objects[0]->getType()); + $this->assertEquals(13115, $objects[0]->getSize()); + $this->assertEquals('Standard', $objects[0]->getStorageClass()); + } + + public function testParseValidXmlWithEncodedKey() + { + $response = new ResponseCore(array(), $this->validXmlWithEncodedKey, 200); + $result = new ListObjectsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(0, count($objectListInfo->getPrefixList())); + $this->assertEquals(1, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('php/prefix', $objectListInfo->getPrefix()); + $this->assertEquals('php/marker', $objectListInfo->getMarker()); + $this->assertEquals('php/next-marker', $objectListInfo->getNextMarker()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('true', $objectListInfo->getIsTruncated()); + $objects = $objectListInfo->getObjectList(); + $this->assertEquals('php/a+b', $objects[0]->getKey()); + $this->assertEquals('2015-11-18T03:36:00.000Z', $objects[0]->getLastModified()); + $this->assertEquals('"89B9E567E7EB8815F2F7D41851F9A2CD"', $objects[0]->getETag()); + $this->assertEquals('Normal', $objects[0]->getType()); + $this->assertEquals(13115, $objects[0]->getSize()); + $this->assertEquals('Standard', $objects[0]->getStorageClass()); + } + + + public function testParseValidXmlWithRestoreInfo() + { + $response = new ResponseCore(array(), $this->validXmlWithResoreInfo, 200); + $result = new ListObjectsResult($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(0, count($objectListInfo->getPrefixList())); + $this->assertEquals(1, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('php/prefix', $objectListInfo->getPrefix()); + $this->assertEquals('php/marker', $objectListInfo->getMarker()); + $this->assertEquals('php/next-marker', $objectListInfo->getNextMarker()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('true', $objectListInfo->getIsTruncated()); + $objects = $objectListInfo->getObjectList(); + $this->assertEquals('php/a+b', $objects[0]->getKey()); + $this->assertEquals('2015-11-18T03:36:00.000Z', $objects[0]->getLastModified()); + $this->assertEquals('"89B9E567E7EB8815F2F7D41851F9A2CD"', $objects[0]->getETag()); + $this->assertEquals('Normal', $objects[0]->getType()); + $this->assertEquals(13115, $objects[0]->getSize()); + $this->assertEquals('Standard', $objects[0]->getStorageClass()); + $this->assertEquals('ongoing-request="false", expiry-date="Tue, 25 Apr 2023 07:30:00 GMT"', $objects[0]->getRestoreInfo()); + $this->assertEquals('cname_user', $objects[0]->getOwner()->getId()); + $this->assertEquals('cname_user', $objects[0]->getOwner()->getDisplayName()); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectsV2ResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectsV2ResultTest.php new file mode 100644 index 0000000..7f07ecf --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListObjectsV2ResultTest.php @@ -0,0 +1,215 @@ + + + testbucket-hf + + + 1000 + / + false + + oss-php-sdk-test/ + + + test/ + + +BBBB; + + private $validXml2 = << + + testbucket-hf + oss-php-sdk-test/ + xx + 1000 + / + false + + oss-php-sdk-test/upload-test-object-name.txt + 2015-11-18T03:36:00.000Z + "89B9E567E7EB8815F2F7D41851F9A2CD" + Normal + 13115 + Standard + + 1 + +BBBB; + + private $validXmlWithEncodedKey = << + + testbucket-hf + url + php%2Fprefix + php%2Fmarker + 1gJiYw-- + CgJiYw-- + 1000 + %2F + true + + php/a%2Bb + 2015-11-18T03:36:00.000Z + "89B9E567E7EB8815F2F7D41851F9A2CD" + Normal + 13115 + Standard + + cname_user + cname_user + + + 1 + +BBBB; + + private $validXmlWithRestoreInfo = << + + testbucket-hf + url + php%2Fprefix + php%2Fmarker + 1gJiYw-- + CgJiYw-- + 1000 + %2F + true + + php/a%2Bb + 2015-11-18T03:36:00.000Z + "89B9E567E7EB8815F2F7D41851F9A2CD" + Normal + 13115 + Standard + + cname_user + cname_user + + ongoing-request="false", expiry-date="Tue, 25 Apr 2023 07:30:00 GMT" + + 1 + +BBBB; + + public function testParseValidXml1() + { + $response = new ResponseCore(array(), $this->validXml1, 200); + $result = new ListObjectsV2Result($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(2, count($objectListInfo->getPrefixList())); + $this->assertEquals(0, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('', $objectListInfo->getPrefix()); + $this->assertEquals('', $objectListInfo->getStartAfter()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('false', $objectListInfo->getIsTruncated()); + $this->assertEquals(0, $objectListInfo->getKeyCount()); + $prefixes = $objectListInfo->getPrefixList(); + $this->assertEquals('oss-php-sdk-test/', $prefixes[0]->getPrefix()); + $this->assertEquals('test/', $prefixes[1]->getPrefix()); + } + + public function testParseValidXml2() + { + $response = new ResponseCore(array(), $this->validXml2, 200); + $result = new ListObjectsV2Result($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(0, count($objectListInfo->getPrefixList())); + $this->assertEquals(1, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('oss-php-sdk-test/', $objectListInfo->getPrefix()); + $this->assertEquals('xx', $objectListInfo->getStartAfter()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('false', $objectListInfo->getIsTruncated()); + $this->assertEquals(1, $objectListInfo->getKeyCount()); + $objects = $objectListInfo->getObjectList(); + $this->assertEquals('oss-php-sdk-test/upload-test-object-name.txt', $objects[0]->getKey()); + $this->assertEquals('2015-11-18T03:36:00.000Z', $objects[0]->getLastModified()); + $this->assertEquals('"89B9E567E7EB8815F2F7D41851F9A2CD"', $objects[0]->getETag()); + $this->assertEquals('Normal', $objects[0]->getType()); + $this->assertEquals(13115, $objects[0]->getSize()); + $this->assertEquals('Standard', $objects[0]->getStorageClass()); + } + + public function testParseValidXmlWithEncodedKey() + { + $response = new ResponseCore(array(), $this->validXmlWithEncodedKey, 200); + $result = new ListObjectsV2Result($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(0, count($objectListInfo->getPrefixList())); + $this->assertEquals(1, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('php/prefix', $objectListInfo->getPrefix()); + $this->assertEquals('php/marker', $objectListInfo->getStartAfter()); + $this->assertEquals('CgJiYw--', $objectListInfo->getNextContinuationToken()); + $this->assertEquals('1gJiYw--', $objectListInfo->getContinuationToken()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('true', $objectListInfo->getIsTruncated()); + $this->assertEquals(1, $objectListInfo->getKeyCount()); + $objects = $objectListInfo->getObjectList(); + $this->assertEquals('php/a+b', $objects[0]->getKey()); + $this->assertEquals('2015-11-18T03:36:00.000Z', $objects[0]->getLastModified()); + $this->assertEquals('"89B9E567E7EB8815F2F7D41851F9A2CD"', $objects[0]->getETag()); + $this->assertEquals('Normal', $objects[0]->getType()); + $this->assertEquals(13115, $objects[0]->getSize()); + $this->assertEquals('Standard', $objects[0]->getStorageClass()); + } + + + public function testParseValidXmlWithRestoreInfo() + { + $response = new ResponseCore(array(), $this->validXmlWithRestoreInfo, 200); + $result = new ListObjectsV2Result($response); + $this->assertTrue($result->isOK()); + $this->assertNotNull($result->getData()); + $this->assertNotNull($result->getRawResponse()); + $objectListInfo = $result->getData(); + $this->assertEquals(0, count($objectListInfo->getPrefixList())); + $this->assertEquals(1, count($objectListInfo->getObjectList())); + $this->assertEquals('testbucket-hf', $objectListInfo->getBucketName()); + $this->assertEquals('php/prefix', $objectListInfo->getPrefix()); + $this->assertEquals('php/marker', $objectListInfo->getStartAfter()); + $this->assertEquals('CgJiYw--', $objectListInfo->getNextContinuationToken()); + $this->assertEquals('1gJiYw--', $objectListInfo->getContinuationToken()); + $this->assertEquals(1000, $objectListInfo->getMaxKeys()); + $this->assertEquals('/', $objectListInfo->getDelimiter()); + $this->assertEquals('true', $objectListInfo->getIsTruncated()); + $this->assertEquals(1, $objectListInfo->getKeyCount()); + $objects = $objectListInfo->getObjectList(); + $this->assertEquals('php/a+b', $objects[0]->getKey()); + $this->assertEquals('2015-11-18T03:36:00.000Z', $objects[0]->getLastModified()); + $this->assertEquals('"89B9E567E7EB8815F2F7D41851F9A2CD"', $objects[0]->getETag()); + $this->assertEquals('Normal', $objects[0]->getType()); + $this->assertEquals(13115, $objects[0]->getSize()); + $this->assertEquals('Standard', $objects[0]->getStorageClass()); + $this->assertEquals('ongoing-request="false", expiry-date="Tue, 25 Apr 2023 07:30:00 GMT"', $objects[0]->getRestoreInfo()); + $this->assertEquals('cname_user', $objects[0]->getOwner()->getId()); + $this->assertEquals('cname_user', $objects[0]->getOwner()->getDisplayName()); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListPartsResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListPartsResultTest.php new file mode 100644 index 0000000..bdc61a2 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ListPartsResultTest.php @@ -0,0 +1,62 @@ + + + multipart_upload + multipart.data + 0004B999EF5A239BB9138C6227D69F95 + 5 + 1000 + false + + 1 + 2012-02-23T07:01:34.000Z + "3349DC700140D7F86A078484278075A9" + 6291456 + + + 2 + 2012-02-23T07:01:12.000Z + "3349DC700140D7F86A078484278075A9" + 6291456 + + + 5 + 2012-02-23T07:02:03.000Z + "7265F4D211B56873A381D321F586E4A9" + 1024 + + +BBBB; + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new ListPartsResult($response); + $listPartsInfo = $result->getData(); + $this->assertEquals("multipart_upload", $listPartsInfo->getBucket()); + $this->assertEquals("multipart.data", $listPartsInfo->getKey()); + $this->assertEquals("0004B999EF5A239BB9138C6227D69F95", $listPartsInfo->getUploadId()); + $this->assertEquals(5, $listPartsInfo->getNextPartNumberMarker()); + $this->assertEquals(1000, $listPartsInfo->getMaxParts()); + $this->assertEquals("false", $listPartsInfo->getIsTruncated()); + $this->assertEquals(3, count($listPartsInfo->getListPart())); + $parts = $listPartsInfo->getListPart(); + $this->assertEquals(1, $parts[0]->getPartNumber()); + $this->assertEquals('2012-02-23T07:01:34.000Z', $parts[0]->getLastModified()); + $this->assertEquals('"3349DC700140D7F86A078484278075A9"', $parts[0]->getETag()); + $this->assertEquals(6291456, $parts[0]->getSize()); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LiveChannelXmlTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LiveChannelXmlTest.php new file mode 100644 index 0000000..b69ef7c --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LiveChannelXmlTest.php @@ -0,0 +1,277 @@ + + + xxx + enabled + + hls + 1000 + 5 + hello.m3u8 + + +BBBB; + + private $info = << + + live-1 + xxx + + rtmp://bucket.oss-cn-hangzhou.aliyuncs.com/live/213443245345 + + + http://bucket.oss-cn-hangzhou.aliyuncs.com/213443245345/播放列表.m3u8 + + enabled + 2015-11-24T14:25:31.000Z + +BBBB; + + private $list = << + +xxx + yyy + 100 + false + 121312132 + + 12123214323431 + xxx + + rtmp://bucket.oss-cn-hangzhou.aliyuncs.com/live/1 + + + http://bucket.oss-cn-hangzhou.aliyuncs.com/1/播放列表.m3u8 + + enabled + 2015-11-24T14:25:31.000Z + + + 432423432423 + yyy + + rtmp://bucket.oss-cn-hangzhou.aliyuncs.com/live/2 + + + http://bucket.oss-cn-hangzhou.aliyuncs.com/2/播放列表.m3u8 + + enabled + 2016-11-24T14:25:31.000Z + + +BBBB; + + private $status = << + + Live + 2016-10-20T14:25:31.000Z + 10.1.2.4:47745 + + + +BBBB; + + private $history = << + + + 2013-11-24T14:25:31.000Z + 2013-11-24T15:25:31.000Z + 10.101.194.148:56861 + + + 2014-11-24T14:25:31.000Z + 2014-11-24T15:25:31.000Z + 10.101.194.148:56862 + + + 2015-11-24T14:25:31.000Z + 2015-11-24T15:25:31.000Z + 10.101.194.148:56863 + + +BBBB; + + public function testLiveChannelStatus() + { + $stat = new GetLiveChannelStatus(); + $stat->parseFromXml($this->status); + + $this->assertEquals('Live', $stat->getStatus()); + $this->assertEquals('2016-10-20T14:25:31.000Z', $stat->getConnectedTime()); + $this->assertEquals('10.1.2.4:47745', $stat->getRemoteAddr()); + + $this->assertEquals(1280, $stat->getVideoWidth()); + $this->assertEquals(536, $stat->getVideoHeight()); + $this->assertEquals(24, $stat->getVideoFrameRate()); + $this->assertEquals(72513, $stat->getVideoBandwidth()); + $this->assertEquals('H264', $stat->getVideoCodec()); + $this->assertEquals(6519, $stat->getAudioBandwidth()); + $this->assertEquals(44100, $stat->getAudioSampleRate()); + $this->assertEquals('AAC', $stat->getAudioCodec()); + + } + + public function testGetLiveChannelHistory() + { + $history = new GetLiveChannelHistory(); + $history->parseFromXml($this->history); + + $recordList = $history->getLiveRecordList(); + $this->assertEquals(3, count($recordList)); + + $list0 = $recordList[0]; + $this->assertEquals('2013-11-24T14:25:31.000Z', $list0->getStartTime()); + $this->assertEquals('2013-11-24T15:25:31.000Z', $list0->getEndTime()); + $this->assertEquals('10.101.194.148:56861', $list0->getRemoteAddr()); + + $list1 = $recordList[1]; + $this->assertEquals('2014-11-24T14:25:31.000Z', $list1->getStartTime()); + $this->assertEquals('2014-11-24T15:25:31.000Z', $list1->getEndTime()); + $this->assertEquals('10.101.194.148:56862', $list1->getRemoteAddr()); + + $list2 = $recordList[2]; + $this->assertEquals('2015-11-24T14:25:31.000Z', $list2->getStartTime()); + $this->assertEquals('2015-11-24T15:25:31.000Z', $list2->getEndTime()); + $this->assertEquals('10.101.194.148:56863', $list2->getRemoteAddr()); + + } + + public function testLiveChannelConfig() + { + $config = new LiveChannelConfig(array('name' => 'live-1')); + $config->parseFromXml($this->config); + + $this->assertEquals('xxx', $config->getDescription()); + $this->assertEquals('enabled', $config->getStatus()); + $this->assertEquals('hls', $config->getType()); + $this->assertEquals(1000, $config->getFragDuration()); + $this->assertEquals(5, $config->getFragCount()); + $this->assertEquals('hello.m3u8', $config->getPlayListName()); + + $xml = $config->serializeToXml(); + $config2 = new LiveChannelConfig(array('name' => 'live-2')); + $config2->parseFromXml($xml); + $this->assertEquals('xxx', $config2->getDescription()); + $this->assertEquals('enabled', $config2->getStatus()); + $this->assertEquals('hls', $config2->getType()); + $this->assertEquals(1000, $config2->getFragDuration()); + $this->assertEquals(5, $config2->getFragCount()); + $this->assertEquals('hello.m3u8', $config2->getPlayListName()); + } + + public function testLiveChannelInfo() + { + $info = new LiveChannelInfo(array('name' => 'live-1')); + $info->parseFromXml($this->info); + + $this->assertEquals('live-1', $info->getName()); + $this->assertEquals('xxx', $info->getDescription()); + $this->assertEquals('enabled', $info->getStatus()); + $this->assertEquals('2015-11-24T14:25:31.000Z', $info->getLastModified()); + $pubs = $info->getPublishUrls(); + $this->assertEquals(1, count($pubs)); + $this->assertEquals('rtmp://bucket.oss-cn-hangzhou.aliyuncs.com/live/213443245345', $pubs[0]); + + $plays = $info->getPlayUrls(); + $this->assertEquals(1, count($plays)); + $this->assertEquals('http://bucket.oss-cn-hangzhou.aliyuncs.com/213443245345/播放列表.m3u8', $plays[0]); + } + + public function testLiveChannelList() + { + $list = new LiveChannelListInfo(); + $list->parseFromXml($this->list); + + $this->assertEquals('xxx', $list->getPrefix()); + $this->assertEquals('yyy', $list->getMarker()); + $this->assertEquals(100, $list->getMaxKeys()); + $this->assertEquals(false, $list->getIsTruncated()); + $this->assertEquals('121312132', $list->getNextMarker()); + + $channels = $list->getChannelList(); + $this->assertEquals(2, count($channels)); + + $chan1 = $channels[0]; + $this->assertEquals('12123214323431', $chan1->getName()); + $this->assertEquals('xxx', $chan1->getDescription()); + $this->assertEquals('enabled', $chan1->getStatus()); + $this->assertEquals('2015-11-24T14:25:31.000Z', $chan1->getLastModified()); + $pubs = $chan1->getPublishUrls(); + $this->assertEquals(1, count($pubs)); + $this->assertEquals('rtmp://bucket.oss-cn-hangzhou.aliyuncs.com/live/1', $pubs[0]); + + $plays = $chan1->getPlayUrls(); + $this->assertEquals(1, count($plays)); + $this->assertEquals('http://bucket.oss-cn-hangzhou.aliyuncs.com/1/播放列表.m3u8', $plays[0]); + + $chan2 = $channels[1]; + $this->assertEquals('432423432423', $chan2->getName()); + $this->assertEquals('yyy', $chan2->getDescription()); + $this->assertEquals('enabled', $chan2->getStatus()); + $this->assertEquals('2016-11-24T14:25:31.000Z', $chan2->getLastModified()); + $pubs = $chan2->getPublishUrls(); + $this->assertEquals(1, count($pubs)); + $this->assertEquals('rtmp://bucket.oss-cn-hangzhou.aliyuncs.com/live/2', $pubs[0]); + + $plays = $chan2->getPlayUrls(); + $this->assertEquals(1, count($plays)); + $this->assertEquals('http://bucket.oss-cn-hangzhou.aliyuncs.com/2/播放列表.m3u8', $plays[0]); + } + + public function testLiveChannelHistory() + { + $xml = "2013-11-24T14:25:31.000Z2013-11-24T15:25:31.000Z10.101.194.148:56861"; + $history = new LiveChannelHistory(); + $history->parseFromXml($xml); + + $this->assertEquals('2013-11-24T14:25:31.000Z', $history->getStartTime()); + $this->assertEquals('2013-11-24T15:25:31.000Z', $history->getEndTime()); + $this->assertEquals('10.101.194.148:56861', $history->getRemoteAddr()); + } + + public function testGetLiveChannelHistorySerializeToXml() + { + try { + $history = new GetLiveChannelHistory (); + $history->serializeToXml(); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "Not implemented.") == false) + { + $this->assertTrue(false); + } + } + } + +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LoggingConfigTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LoggingConfigTest.php new file mode 100644 index 0000000..05336c8 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/LoggingConfigTest.php @@ -0,0 +1,47 @@ + + + +TargetBucket +TargetPrefix + + +BBBB; + + private $nullXml = << + +BBBB; + + public function testParseValidXml() + { + $loggingConfig = new LoggingConfig(); + $loggingConfig->parseFromXml($this->validXml); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml(strval($loggingConfig))); + } + + public function testConstruct() + { + $loggingConfig = new LoggingConfig('TargetBucket', 'TargetPrefix'); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($loggingConfig->serializeToXml())); + } + + public function testFailedConstruct() + { + $loggingConfig = new LoggingConfig('TargetBucket', null); + $this->assertEquals($this->cleanXml($this->nullXml), $this->cleanXml($loggingConfig->serializeToXml())); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/MimeTypesTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/MimeTypesTest.php new file mode 100644 index 0000000..1403d09 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/MimeTypesTest.php @@ -0,0 +1,13 @@ +assertEquals('application/xml', MimeTypes::getMimetype('file.xml')); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ObjectAclTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ObjectAclTest.php new file mode 100644 index 0000000..ec003ca --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/ObjectAclTest.php @@ -0,0 +1,29 @@ +ossClient; + $bucket = $this->bucket; + + $object = 'test/object-acl'; + $client->deleteObject($bucket, $object); + $client->putObject($bucket, $object, "hello world"); + + $acl = $client->getObjectAcl($bucket, $object); + $this->assertEquals('default', $acl); + + $client->putObjectAcl($bucket, $object, 'public-read'); + $acl = $client->getObjectAcl($bucket, $object); + $this->assertEquals('public-read', $acl); + + $content = $client->getObject($bucket, $object); + $this->assertEquals('hello world', $content); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientAsyncProcessObjectTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientAsyncProcessObjectTest.php new file mode 100644 index 0000000..cbf85e3 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientAsyncProcessObjectTest.php @@ -0,0 +1,68 @@ +client = $this->ossClient; + $this->bucketName = $this->bucket; + + $url = 'https://oss-console-img-demo-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/video.mp4?spm=a2c4g.64555.0.0.515675979u4B8w&file=video.mp4'; + $file_name = "video.mp4"; + $fp = fopen($file_name, 'w'); + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_FILE, $fp); + curl_exec($ch); + curl_close($ch); + fclose($fp); + + $this->local_file = $file_name; + $this->object = "oss-example.mp4"; + + Common::waitMetaSync(); + $this->client->uploadFile($this->bucketName, $this->object, $this->local_file); + } + + protected function tearDown(): void + { + parent::tearDown(); + unlink($this->local_file); + } + + public function testAsyncProcessObject() + { + + try { + $object = 'php-async-copy'; + $process = 'video/convert,f_avi,vcodec_h265,s_1920x1080,vb_2000000,fps_30,acodec_aac,ab_100000,sn_1'. + '|sys/saveas'. + ',o_'.$this->base64url_encode($object). + ',b_'.$this->base64url_encode($this->bucketName); + $result = $this->client->asyncProcessObject($this->bucketName, $this->object, $process); + }catch (OssException $e){ + $this->assertEquals($e->getErrorCode(),"Imm Client"); + $this->assertTrue(strpos($e->getErrorMessage(), "ResourceNotFound, The specified resource Attachment is not found") !== false); + } + + } + + private function base64url_encode($data) + { + return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketCnameTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketCnameTest.php new file mode 100644 index 0000000..dabe93f --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketCnameTest.php @@ -0,0 +1,61 @@ +bucket . '-cname'; + $client = new OssClient( + getenv('OSS_ACCESS_KEY_ID'), + getenv('OSS_ACCESS_KEY_SECRET'), + "oss-ap-southeast-2.aliyuncs.com", false); + + $client->createBucket($bucketName); + + try { + $info1 = $client->createBucketCnameToken($bucketName, "www.example.com"); + $this->assertEquals("www.example.com", $info1->getCname()); + $this->assertEquals($bucketName, $info1->getBucket()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $info2 = $client->getBucketCnameToken($bucketName, "www.example.com"); + $this->assertEquals("www.example.com", $info2->getCname()); + $this->assertEquals($bucketName, $info2->getBucket()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $result = $client->addBucketCname($bucketName, "www.example.com"); + } catch (OssException $e) { + $this->assertEquals('NeedVerifyDomainOwnership', $e->getErrorCode()); + } + + try { + $config = $client->getBucketCname($bucketName); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $result = $client->deleteBucketCname($bucketName, "www.example.com"); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $client->deleteBucket($bucketName); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketCorsTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketCorsTest.php new file mode 100644 index 0000000..bbe11f5 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketCorsTest.php @@ -0,0 +1,125 @@ +addAllowedHeader("x-oss-test"); + $rule->addAllowedHeader("x-oss-test2"); + $rule->addAllowedHeader("x-oss-test2"); + $rule->addAllowedHeader("x-oss-test3"); + $rule->addAllowedOrigin("http://www.b.com"); + $rule->addAllowedOrigin("http://www.a.com"); + $rule->addAllowedOrigin("http://www.a.com"); + $rule->addAllowedMethod("GET"); + $rule->addAllowedMethod("PUT"); + $rule->addAllowedMethod("POST"); + $rule->addExposeHeader("x-oss-test1"); + $rule->addExposeHeader("x-oss-test1"); + $rule->addExposeHeader("x-oss-test2"); + $rule->setMaxAgeSeconds(10); + $corsConfig->addRule($rule); + $rule = new CorsRule(); + $rule->addAllowedHeader("x-oss-test"); + $rule->addAllowedMethod("GET"); + $rule->addAllowedOrigin("http://www.b.com"); + $rule->addExposeHeader("x-oss-test1"); + $rule->setMaxAgeSeconds(110); + $corsConfig->addRule($rule); + $corsConfig->setResponseVary(true); + + try { + $this->ossClient->putBucketCors($this->bucket, $corsConfig); + } catch (OssException $e) { + $this->assertFalse(True); + } + + try { + Common::waitMetaSync(); + $object = "cors/test.txt"; + $this->ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $headers = $this->ossClient->optionsObject($this->bucket, $object, "http://www.a.com", "GET", "", null); + $this->assertNotEmpty($headers); + } catch (OssException $e) { + var_dump($e->getMessage()); + } + + try { + Common::waitMetaSync(); + $corsConfig2 = $this->ossClient->getBucketCors($this->bucket); + $this->assertNotNull($corsConfig2); + $this->assertEquals($corsConfig->serializeToXml(), $corsConfig2->serializeToXml()); + } catch (OssException $e) { + $this->assertFalse(True); + } + + try { + Common::waitMetaSync(); + $this->ossClient->deleteBucketCors($this->bucket); + } catch (OssException $e) { + $this->assertFalse(True); + } + + try { + Common::waitMetaSync(); + $corsConfig3 = $this->ossClient->getBucketCors($this->bucket); + $this->assertNotNull($corsConfig3); + $this->assertNotEquals($corsConfig->serializeToXml(), $corsConfig3->serializeToXml()); + } catch (OssException $e) { + $this->assertFalse(True); + } + + + try { + Common::waitMetaSync(); + $this->ossClient->deleteBucketCors($this->bucket); + } catch (OssException $e) { + $this->assertFalse(True); + } + + $corsConfig = new CorsConfig(); + $rule = new CorsRule(); + $rule->addAllowedHeader("x-oss-test"); + $rule->addAllowedOrigin("http://www.b.com"); + $rule->addAllowedMethod("GET"); + $rule->addExposeHeader("x-oss-test1"); + $rule->setMaxAgeSeconds(10); + $corsConfig->addRule($rule); + $rule = new CorsRule(); + $rule->addAllowedHeader("x-oss-test"); + $rule->addAllowedMethod("GET"); + $rule->addAllowedOrigin("http://www.b.com"); + $rule->addExposeHeader("x-oss-test1"); + $rule->setMaxAgeSeconds(110); + $corsConfig->addRule($rule); + $corsConfig->setResponseVary(false); + + try { + $this->ossClient->putBucketCors($this->bucket, $corsConfig); + } catch (OssException $e) { + $this->assertFalse(True); + } + + try { + Common::waitMetaSync(); + $corsConfig4 = $this->ossClient->getBucketCors($this->bucket); + $this->assertNotNull($corsConfig4); + $this->assertEquals($corsConfig->serializeToXml(), $corsConfig4->serializeToXml()); + } catch (OssException $e) { + $this->assertFalse(True); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketEncryptionTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketEncryptionTest.php new file mode 100644 index 0000000..42c51b2 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketEncryptionTest.php @@ -0,0 +1,63 @@ +ossClient->putBucketEncryption($this->bucket, $config); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $config2 = $this->ossClient->getBucketEncryption($this->bucket); + $this->assertEquals($config->serializeToXml(), $config2->serializeToXml()); + $this->assertEquals("AES256", $config2->getSSEAlgorithm()); + $this->assertEquals(null, $config2->getKMSMasterKeyID()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $config = new ServerSideEncryptionConfig("KMS", "kms-id"); + try { + $this->ossClient->putBucketEncryption($this->bucket, $config); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $config2 = $this->ossClient->getBucketEncryption($this->bucket); + $this->assertEquals($config->serializeToXml(), $config2->serializeToXml()); + $this->assertEquals("KMS", $config2->getSSEAlgorithm()); + $this->assertEquals("kms-id", $config2->getKMSMasterKeyID()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + Common::waitMetaSync(); + $this->ossClient->deleteBucketEncryption($this->bucket); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $config2 = $this->ossClient->getBucketEncryption($this->bucket); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals("NoSuchServerSideEncryptionRule", $e->getErrorCode()); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketInfoTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketInfoTest.php new file mode 100644 index 0000000..759e536 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketInfoTest.php @@ -0,0 +1,20 @@ +ossClient->getBucketInfo($this->bucket); + $this->assertEquals($this->bucket, $info->getName()); + $this->assertEquals("Standard", $info->getStorageClass()); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketLifecycleTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketLifecycleTest.php new file mode 100644 index 0000000..46da1f0 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketLifecycleTest.php @@ -0,0 +1,57 @@ +addRule($lifecycleRule); + $actions = array(); + $actions[] = new LifecycleAction("Expiration", "Date", '2022-10-12T00:00:00.000Z'); + $lifecycleRule = new LifecycleRule("delete temporary files", "temporary/", "Enabled", $actions); + $lifecycleConfig->addRule($lifecycleRule); + + try { + $this->ossClient->putBucketLifecycle($this->bucket, $lifecycleConfig); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + Common::waitMetaSync(); + $lifecycleConfig2 = $this->ossClient->getBucketLifecycle($this->bucket); + $this->assertEquals($lifecycleConfig->serializeToXml(), $lifecycleConfig2->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + Common::waitMetaSync(); + $this->ossClient->deleteBucketLifecycle($this->bucket); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + Common::waitMetaSync(); + $lifecycleConfig3 = $this->ossClient->getBucketLifecycle($this->bucket); + $this->assertNotEquals($lifecycleConfig->serializeToXml(), $lifecycleConfig3->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketLoggingTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketLoggingTest.php new file mode 100644 index 0000000..16a10eb --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketLoggingTest.php @@ -0,0 +1,43 @@ +bucket, 'prefix'); + try { + $this->ossClient->putBucketLogging($this->bucket, $this->bucket, 'prefix'); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $loggingConfig2 = $this->ossClient->getBucketLogging($this->bucket); + $this->assertEquals($loggingConfig->serializeToXml(), $loggingConfig2->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $this->ossClient->deleteBucketLogging($this->bucket); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $loggingConfig3 = $this->ossClient->getBucketLogging($this->bucket); + $this->assertNotEquals($loggingConfig->serializeToXml(), $loggingConfig3->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketPolicyTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketPolicyTest.php new file mode 100644 index 0000000..6007f10 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketPolicyTest.php @@ -0,0 +1,54 @@ +ossClient->deleteBucketPolicy($this->bucket); + $policy = $this->ossClient->getBucketPolicy($this->bucket); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + $this->assertEquals("NoSuchBucketPolicy", $e->getErrorCode()); + } + + try { + $this->ossClient->putBucketPolicy($this->bucket, $policy_str); + $policy = $this->ossClient->getBucketPolicy($this->bucket); + $data1 = json_decode($policy_str, true); + $data2 = json_decode($policy, true); + $this->assertEquals($data1, $data2); + $this->ossClient->deleteBucketPolicy($this->bucket); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketRefererTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketRefererTest.php new file mode 100644 index 0000000..ba7d14f --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketRefererTest.php @@ -0,0 +1,48 @@ +addReferer('http://www.aliyun.com'); + + try { + $this->ossClient->putBucketReferer($this->bucket, $refererConfig); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $refererConfig2 = $this->ossClient->getBucketReferer($this->bucket); + $this->assertEquals($refererConfig->serializeToXml(), $refererConfig2->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $nullRefererConfig = new RefererConfig(); + $nullRefererConfig->setAllowEmptyReferer(false); + $this->ossClient->putBucketReferer($this->bucket, $nullRefererConfig); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $refererConfig3 = $this->ossClient->getBucketLogging($this->bucket); + $this->assertNotEquals($refererConfig->serializeToXml(), $refererConfig3->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketRequestPaymentTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketRequestPaymentTest.php new file mode 100644 index 0000000..9a4b412 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketRequestPaymentTest.php @@ -0,0 +1,51 @@ +ossClient->getBucketRequestPayment($this->bucket); + $this->assertEquals("BucketOwner", $payer); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->putBucketRequestPayment($this->bucket, "Requester"); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $payer = $this->ossClient->getBucketRequestPayment($this->bucket); + $this->assertEquals("Requester", $payer); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->putBucketRequestPayment($this->bucket, "BucketOwner"); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $payer = $this->ossClient->getBucketRequestPayment($this->bucket); + $this->assertEquals("BucketOwner", $payer); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketStatTestTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketStatTestTest.php new file mode 100644 index 0000000..7f847d8 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketStatTestTest.php @@ -0,0 +1,34 @@ +ossClient->putObject($this->bucket, "name-1.txt", $content); + $this->ossClient->putObject($this->bucket, "name-2.txt", $content); + $this->ossClient->putObject($this->bucket, "name-3.txt", $content); + + $object = "multipart-test.txt"; + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + + Common::waitMetaSync(); + Common::waitMetaSync(); + Common::waitMetaSync(); + $stat = $this->ossClient->getBucketStat($this->bucket); + $this->assertEquals(3, $stat->getObjectCount()); + $this->assertEquals(15, $stat->getStorage()); + $this->assertEquals(1, $stat->getMultipartUploadCount()); + + } catch (OssException $e) { + $this->assertTrue(false); + } + } + +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketStorageCapacityTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketStorageCapacityTest.php new file mode 100644 index 0000000..87548f9 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketStorageCapacityTest.php @@ -0,0 +1,56 @@ +ossClient->getBucketStorageCapacity($this->bucket); + $this->assertEquals($storageCapacity, -1); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->putBucketStorageCapacity($this->bucket, 1000); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + Common::waitMetaSync(); + $storageCapacity = $this->ossClient->getBucketStorageCapacity($this->bucket); + $this->assertEquals($storageCapacity, 1000); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->putBucketStorageCapacity($this->bucket, 0); + + Common::waitMetaSync(); + + $storageCapacity = $this->ossClient->getBucketStorageCapacity($this->bucket); + $this->assertEquals($storageCapacity, 0); + + $this->ossClient->putObject($this->bucket, 'test-storage-capacity','test-content'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('Bucket storage exceed max storage capacity.',$e->getErrorMessage()); + } + + try { + $this->ossClient->putBucketStorageCapacity($this->bucket, -2); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals(400, $e->getHTTPStatus()); + $this->assertEquals('InvalidArgument', $e->getErrorCode()); + } + } + +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTagsTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTagsTest.php new file mode 100644 index 0000000..bafa64b --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTagsTest.php @@ -0,0 +1,76 @@ +ossClient->getBucketTags($this->bucket); + $this->assertEquals(0, count($config->getTags())); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $config = new TaggingConfig(); + $config->addTag(new Tag("key1", "value1")); + $config->addTag(new Tag("key2", "value2")); + $config->addTag(new Tag("key3", "value3")); + $this->ossClient->putBucketTags($this->bucket, $config); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + Common::waitMetaSync(); + $config2 = $this->ossClient->getBucketTags($this->bucket); + $this->assertEquals(3, count($config2->getTags())); + $this->assertEquals("key1", $config2->getTags()[0]->getKey()); + $this->assertEquals("value1", $config2->getTags()[0]->getValue()); + $this->assertEquals("key2", $config2->getTags()[1]->getKey()); + $this->assertEquals("value2", $config2->getTags()[1]->getValue()); + $this->assertEquals("key3", $config2->getTags()[2]->getKey()); + $this->assertEquals("value3", $config2->getTags()[2]->getValue()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + + try { + Common::waitMetaSync(); + //del key1, key3 + $tags = array(); + $tags[] = new Tag("key1", "value1"); + $tags[] = new Tag("key3", "value3"); + + $this->ossClient->deleteBucketTags($this->bucket, $tags); + $config2 = $this->ossClient->getBucketTags($this->bucket); + $this->assertEquals(1, count($config2->getTags())); + $this->assertEquals("key2", $config2->getTags()[0]->getKey()); + $this->assertEquals("value2", $config2->getTags()[0]->getValue()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + + try { + Common::waitMetaSync(); + //del all + $this->ossClient->deleteBucketTags($this->bucket); + $config2 = $this->ossClient->getBucketTags($this->bucket); + $this->assertEquals(0, count($config2->getTags())); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTest.php new file mode 100644 index 0000000..dc63685 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTest.php @@ -0,0 +1,140 @@ +ossClient->createBucket("s"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('"s"bucket name is invalid', $e->getMessage()); + } + } + + public function testBucketWithInvalidACL() + { + try { + $this->ossClient->createBucket($this->bucket, "invalid"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('invalid:acl is invalid(private,public-read,public-read-write)', $e->getMessage()); + } + } + + public function testBucket() + { + $this->ossClient->createBucket($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + + $bucketListInfo = $this->ossClient->listBuckets(); + $this->assertNotNull($bucketListInfo); + + $bucketList = $bucketListInfo->getBucketList(); + $this->assertTrue(is_array($bucketList)); + $this->assertGreaterThan(0, count($bucketList)); + + $this->ossClient->putBucketAcl($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + Common::waitMetaSync(); + $this->assertEquals($this->ossClient->getBucketAcl($this->bucket), OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + + $this->assertTrue($this->ossClient->doesBucketExist($this->bucket)); + $this->assertFalse($this->ossClient->doesBucketExist($this->bucket . '-notexist')); + + //$this->assertContains(Common::getRegion(), $this->ossClient->getBucketLocation($this->bucket)); + + $res = $this->ossClient->getBucketMeta($this->bucket); + $this->assertEquals('200', $res['info']['http_code']); + //$this->assertContains(Common::getRegion(), $res['x-oss-bucket-region']); + } + + public function testCreateBucketWithStorageType() + { + $object = 'storage-object'; + + $this->ossClient->putObject($this->archiveBucket, $object,'testcontent'); + try { + $this->ossClient->getObject($this->archiveBucket, $object); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('403', $e->getHTTPStatus()); + $this->assertEquals('InvalidObjectState', $e->getErrorCode()); + } + + $this->ossClient->putObject($this->iaBucket, $object,'testcontent'); + $result = $this->ossClient->getObject($this->iaBucket, $object); + $this->assertEquals($result, 'testcontent'); + + $this->ossClient->putObject($this->bucket, $object,'testcontent'); + $result = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($result, 'testcontent'); + } + + public function testCreateBucketWithInvalidStorageType() + { + try { + $options = array( + OssClient::OSS_STORAGE => 'unknown' + ); + $this->ossClient->createBucket('bucket-name', OssClient::OSS_ACL_TYPE_PRIVATE, $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "storage name is invalid") == false) + { + $this->assertTrue(false); + } + } + } + + protected function setUp(): void + { + parent::setUp(); + + $this->iaBucket = 'ia-' . $this->bucket; + $this->archiveBucket = 'archive-' . $this->bucket; + $this->standardBucket = 'standard-' . $this->bucket; + + $options = array( + OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_IA + ); + + $this->ossClient->createBucket($this->iaBucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options); + + $options = array( + OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_ARCHIVE + ); + + $this->ossClient->createBucket($this->archiveBucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options); + + $options = array( + OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_STANDARD + ); + + $this->ossClient->createBucket($this->standardBucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options); + } + + protected function tearDown(): void + { + parent::tearDown(); + + $object = 'storage-object'; + + $this->ossClient->deleteObject($this->iaBucket, $object); + $this->ossClient->deleteObject($this->archiveBucket, $object); + $this->ossClient->deleteBucket($this->iaBucket); + $this->ossClient->deleteBucket($this->archiveBucket); + $this->ossClient->deleteBucket($this->standardBucket); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTransferAccelerationTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTransferAccelerationTest.php new file mode 100644 index 0000000..24c8b51 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketTransferAccelerationTest.php @@ -0,0 +1,40 @@ +ossClient->getBucketTransferAcceleration($this->bucket); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals("NoSuchTransferAccelerationConfiguration", $e->getErrorCode()); + } + + try { + $this->ossClient->putBucketTransferAcceleration($this->bucket, true); + Common::waitMetaSync(); + $status = $this->ossClient->getBucketTransferAcceleration($this->bucket); + $this->assertEquals(true, $status); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->putBucketTransferAcceleration($this->bucket, false); + Common::waitMetaSync(); + $status = $this->ossClient->getBucketTransferAcceleration($this->bucket); + $this->assertEquals(false, $status); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketVersioningTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketVersioningTest.php new file mode 100644 index 0000000..d9aa5a4 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketVersioningTest.php @@ -0,0 +1,40 @@ +ossClient->getBucketVersioning($this->bucket); + $this->assertEquals(null, $status); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->putBucketVersioning($this->bucket, "Enabled"); + Common::waitMetaSync(); + $status = $this->ossClient->getBucketVersioning($this->bucket); + $this->assertEquals("Enabled", $status); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->putBucketVersioning($this->bucket, "Suspended"); + Common::waitMetaSync(); + $status = $this->ossClient->getBucketVersioning($this->bucket); + $this->assertEquals("Suspended", $status); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketWebsiteTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketWebsiteTest.php new file mode 100644 index 0000000..dfa9cc1 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketWebsiteTest.php @@ -0,0 +1,46 @@ +ossClient->putBucketWebsite($this->bucket, $websiteConfig); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + + try { + Common::waitMetaSync(); + $websiteConfig2 = $this->ossClient->getBucketWebsite($this->bucket); + $this->assertEquals($websiteConfig->serializeToXml(), $websiteConfig2->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $this->ossClient->deleteBucketWebsite($this->bucket); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + Common::waitMetaSync(); + $websiteConfig3 = $this->ossClient->getBucketLogging($this->bucket); + $this->assertNotEquals($websiteConfig->serializeToXml(), $websiteConfig3->serializeToXml()); + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketWormTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketWormTest.php new file mode 100644 index 0000000..85df417 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientBucketWormTest.php @@ -0,0 +1,36 @@ +ossClient->initiateBucketWorm($this->bucket, 30); + $config = $this->ossClient->getBucketWorm($this->bucket); + $this->assertEquals($wormId, $config->getWormId()); + $this->assertEquals("InProgress", $config->getState()); + $this->assertEquals(30, $config->getDay()); + $this->ossClient->abortBucketWorm($this->bucket); + + $wormId = $this->ossClient->initiateBucketWorm($this->bucket, 60); + $this->ossClient->completeBucketWorm($this->bucket, $wormId); + $config = $this->ossClient->getBucketWorm($this->bucket); + + $this->ossClient->ExtendBucketWorm($this->bucket, $wormId, 120); + $config = $this->ossClient->getBucketWorm($this->bucket); + $this->assertEquals($wormId, $config->getWormId()); + $this->assertEquals("Locked", $config->getState()); + $this->assertEquals(120, $config->getDay()); + + } catch (OssException $e) { + $this->assertTrue(false); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientForcePathStyleTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientForcePathStyleTest.php new file mode 100644 index 0000000..a441718 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientForcePathStyleTest.php @@ -0,0 +1,124 @@ + OssClient::OSS_SIGNATURE_VERSION_V4, + 'forcePathStyle' => true, + ); + + $pathStyleClient = Common::getOssClient($config); + + try { + $pathStyleClient->getBucketInfo($this->bucket); + $this->assertTrue(false, "should not here"); + } catch (OssException $e) { + $this->assertEquals($e->getErrorCode(), "SecondLevelDomainForbidden"); + $this->assertTrue(true); + } + + try { + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $pathStyleClient->putObject($this->bucket, $object, 'hi oss'); + $this->assertTrue(false, "should not here"); + } catch (OssException $e) { + $this->assertEquals($e->getErrorCode(), "SecondLevelDomainForbidden"); + $this->assertTrue(true); + } + + try { + $endpoint = Common::getEndpoint(); + $endpoint = str_replace(array('http://', 'https://'), '', $endpoint); + $strUrl = $endpoint . "/" . $this->bucket . '/' . $object; + $signUrl = $pathStyleClient->signUrl($this->bucket, $object, 3600); + $this->assertTrue(strpos($signUrl, $strUrl) !== false); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testForcePathStyleOKV1() + { + $bucket = Common::getPathStyleBucket(); + + $this->assertFalse(empty($bucket), "path style bucket is not set."); + + $config = array( + 'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V1, + 'forcePathStyle' => true, + ); + + $pathStyleClient = Common::getOssClient($config); + + // bucket + $info = $pathStyleClient->getBucketInfo($bucket); + $this->assertEquals($bucket, $info->getName()); + + // object + $object = "upload-test-object-name.txt"; + $pathStyleClient->putObject($bucket, $object, 'hi oss'); + $res = $pathStyleClient->getObject($bucket, $object); + $this->assertEquals($res, 'hi oss'); + + //presign + $signUrl = $pathStyleClient->signUrl($bucket, $object, 3600); + + $httpCore = new RequestCore($signUrl); + $httpCore->set_body(""); + $httpCore->set_method("GET"); + $httpCore->connect_timeout = 10; + $httpCore->timeout = 10; + $httpCore->add_header("Content-Type", ""); + $httpCore->send_request(); + $this->assertEquals(200, $httpCore->response_code); + } + + public function testForcePathStyleOKV4() + { + $bucket = Common::getPathStyleBucket(); + + $this->assertFalse(empty($bucket), "path style bucket is not set."); + + $config = array( + 'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4, + 'forcePathStyle' => true, + ); + + $pathStyleClient = Common::getOssClient($config); + + // bucket + $info = $pathStyleClient->getBucketInfo($bucket); + $this->assertEquals($bucket, $info->getName()); + + // object + $object = "upload-test-object-name.txt"; + $pathStyleClient->putObject($bucket, $object, 'hi oss'); + $res = $pathStyleClient->getObject($bucket, $object); + $this->assertEquals($res, 'hi oss'); + + //presign + $signUrl = $pathStyleClient->signUrl($bucket, $object, 3600); + + #print("signUrl" . $signUrl . "\n"); + + $httpCore = new RequestCore($signUrl); + $httpCore->set_body(""); + $httpCore->set_method("GET"); + $httpCore->connect_timeout = 10; + $httpCore->timeout = 10; + $httpCore->add_header("Content-Type", ""); + $httpCore->send_request(); + $this->assertEquals(200, $httpCore->response_code); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientImageTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientImageTest.php new file mode 100644 index 0000000..a43584e --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientImageTest.php @@ -0,0 +1,149 @@ +client = $this->ossClient; + $this->bucketName = $this->bucket; + $this->local_file = "example.jpg"; + $this->object = "oss-example.jpg"; + $this->download_file = "image.jpg"; + + Common::waitMetaSync(); + $this->client->uploadFile($this->bucketName, $this->object, $this->local_file); + } + + protected function tearDown(): void + { + parent::tearDown(); + unlink($this->download_file); + } + + public function testImageResize() + { + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + OssClient::OSS_PROCESS => "image/resize,m_fixed,h_100,w_100",); + $this->check($options, 100, 100, 3267, 'jpg'); + } + + public function testImageCrop() + { + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + OssClient::OSS_PROCESS => "image/crop,w_100,h_100,x_100,y_100,r_1",); + $this->check($options, 100, 100, 1969, 'jpg'); + } + + public function testImageRotate() + { + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + OssClient::OSS_PROCESS => "image/rotate,90",); + $this->check($options, 267, 400, 20998, 'jpg'); + } + + public function testImageSharpen() + { + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + OssClient::OSS_PROCESS => "image/sharpen,100",); + $this->check($options, 400, 267, 23015, 'jpg'); + } + + public function testImageWatermark() + { + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + OssClient::OSS_PROCESS => "image/watermark,text_SGVsbG8g5Zu-54mH5pyN5YqhIQ",); + $this->check($options, 400, 267, 26369, 'jpg'); + } + + public function testImageFormat() + { + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + OssClient::OSS_PROCESS => "image/format,png",); + $this->check($options, 400, 267, 160733, 'png'); + } + + public function testImageTofile() + { + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + OssClient::OSS_PROCESS => "image/resize,m_fixed,w_100,h_100",); + $this->check($options, 100, 100, 3267, 'jpg'); + } + + public function testProcesObject() + { + $object = 'process-object.jpg'; + $process = 'image/resize,m_fixed,w_100,h_100' . + '|sys/saveas' . + ',o_' . $this->base64url_encode($object) . + ',b_' . $this->base64url_encode($this->bucketName); + $result = $this->client->processObject($this->bucketName, $this->object, $process); + $this->assertTrue(stripos($result, '"object": "process-object.jpg",') > 0); + $this->assertTrue(stripos($result, '"status": "OK"') > 0); + + + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + ); + $this->client->getObject($this->bucketName, $object, $options); + $array = getimagesize($this->download_file); + $this->assertEquals(100, $array[0]); + $this->assertEquals(100, $array[1]); + $this->assertEquals(2, $array[2]); + + //without bucket + $object = 'process-object-1.jpg'; + $process = 'image/watermark,text_SGVsbG8g5Zu-54mH5pyN5YqhIQ' . + '|sys/saveas' . + ',o_' . $this->base64url_encode($object); + $result = $this->client->processObject($this->bucketName, $this->object, $process); + $this->assertTrue(stripos($result, '"object": "process-object-1.jpg",') > 0); + $this->assertTrue(stripos($result, '"status": "OK"') > 0); + + + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $this->download_file, + ); + $this->client->getObject($this->bucketName, $object, $options); + $array = getimagesize($this->download_file); + $this->assertEquals(400, $array[0]); + $this->assertEquals(267, $array[1]); + $this->assertEquals(2, $array[2]); + } + + private function check($options, $width, $height, $size, $type) + { + $this->client->getObject($this->bucketName, $this->object, $options); + $array = getimagesize($this->download_file); + $this->assertEquals($width, $array[0]); + $this->assertEquals($height, $array[1]); + $this->assertEquals($type === 'jpg' ? 2 : 3, $array[2]);//2 <=> jpg + } + + private function base64url_encode($data) + { + return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientListObjectsTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientListObjectsTest.php new file mode 100644 index 0000000..8ee47a2 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientListObjectsTest.php @@ -0,0 +1,184 @@ +ossClient->listObjects($this->bucket); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + $this->assertEquals((2), count($objectList)); + $this->assertEquals(4, count($prefixList)); + + $this->assertEquals('file++00', $objectList[0]->getKey()); + $this->assertEquals('file++01', $objectList[1]->getKey()); + + $this->assertEquals('folder/', $prefixList[0]->getPrefix()); + $this->assertEquals('sub++/', $prefixList[1]->getPrefix()); + $this->assertEquals('test/', $prefixList[2]->getPrefix()); + $this->assertEquals('work/', $prefixList[3]->getPrefix()); + + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testListObjectsWithPrefix() + { + /** + * List the files in your bucket. + */ + $prefix = 'folder/'; + $delimiter = ''; + $next_marker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $next_marker, + ); + + try { + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + $this->assertEquals(12, count($objectList)); + $this->assertEquals(0, count($prefixList)); + + $this->assertEquals('folder/00', $objectList[0]->getKey()); + $this->assertEquals('folder/01', $objectList[1]->getKey()); + $this->assertEquals('folder/11', $objectList[11]->getKey()); + + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testListObjectsWithMaxKeysAndMarker() + { + $count = 0; + $nextMarker = ''; + + while (true) { + try { + $options = array( + 'delimiter' => '', + 'marker' => $nextMarker, + 'max-keys' => 2, + ); + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + } catch (OssException $e) { + $this->assertTrue(false); + } + $nextMarker = $listObjectInfo->getNextMarker(); + $listObject = $listObjectInfo->getObjectList(); + $count += count($listObject); + $this->assertEquals(2, count($listObject)); + if ($listObjectInfo->getIsTruncated() !== "true") { + break; + } + } + $this->assertEquals(12 + 8 + 5 + 3 + 2, $count); + } + + public function testListObjectsWithMarker() + { + $count = 0; + $nextMarker = 'h'; + + while (true) { + try { + $options = array( + 'delimiter' => '', + 'marker' => $nextMarker, + 'max-keys' => 1, + ); + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + } catch (OssException $e) { + $this->assertTrue(false); + } + $nextMarker = $listObjectInfo->getNextMarker(); + $listObject = $listObjectInfo->getObjectList(); + $count += count($listObject); + $this->assertEquals(1, count($listObject)); + if ($listObjectInfo->getIsTruncated() !== "true") { + break; + } + } + $this->assertEquals(8 + 5 + 3, $count); + + + $nextMarker = 'h'; + + try { + $options = array( + 'delimiter' => '', + 'marker' => $nextMarker, + 'max-keys' => 5, + ); + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + } catch (OssException $e) { + $this->assertTrue(false); + } + $nextMarker = $listObjectInfo->getNextMarker(); + $listObject = $listObjectInfo->getObjectList(); + $this->assertEquals('test/01', $nextMarker); + $this->assertEquals(5, count($listObject)); + $this->assertEquals("true", $listObjectInfo->getIsTruncated()); + } + + protected function setUp(): void + { + parent::setUp(); + //folder + for ($i = 0; $i < 12; $i++) { + $key = 'folder/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //test + for ($i = 0; $i < 8; $i++) { + $key = 'test/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //work + for ($i = 0; $i < 5; $i++) { + $key = 'work/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //sub++ + for ($i = 0; $i < 3; $i++) { + $key = 'sub++/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + + //file++ + for ($i = 0; $i < 2; $i++) { + $key = 'file++'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + + } + + protected function tearDown(): void + { + parent::tearDown(); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientListObjectsV2Test.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientListObjectsV2Test.php new file mode 100644 index 0000000..c913283 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientListObjectsV2Test.php @@ -0,0 +1,175 @@ +ossClient->putObject($this->bucket, $key, "content"); + } + //test + for ($i = 0; $i < 8; $i++) { + $key = 'test/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //work + for ($i = 0; $i < 5; $i++) { + $key = 'work/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //sub++ + for ($i = 0; $i < 3; $i++) { + $key = 'sub++/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + + //file++ + for ($i = 0; $i < 2; $i++) { + $key = 'file++'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + + } + + protected function tearDown(): void + { + parent::tearDown(); + } + public function testListObjectsDefault() + { + try { + $listObjectInfo = $this->ossClient->listObjectsV2($this->bucket); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + $this->assertEquals((2), count($objectList)); + $this->assertEquals(4, count($prefixList)); + + $this->assertEquals('file++00', $objectList[0]->getKey()); + $this->assertEquals('file++01', $objectList[1]->getKey()); + + $this->assertEquals('folder/', $prefixList[0]->getPrefix()); + $this->assertEquals('sub++/', $prefixList[1]->getPrefix()); + $this->assertEquals('test/', $prefixList[2]->getPrefix()); + $this->assertEquals('work/', $prefixList[3]->getPrefix()); + + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + + public function testListObjectsWithPrefix() + { + /** + * List the files in your bucket. + */ + $prefix = 'folder/'; + $delimiter = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + ); + + try { + $listObjectInfo = $this->ossClient->listObjectsV2($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + $this->assertEquals(12, count($objectList)); + $this->assertEquals(0, count($prefixList)); + + $this->assertEquals('folder/00', $objectList[0]->getKey()); + $this->assertEquals('folder/01', $objectList[1]->getKey()); + $this->assertEquals('folder/11', $objectList[11]->getKey()); + + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + + public function testListObjectsWithMaxKeysAndMarker() + { + $count = 0; + $options = array( + 'delimiter' => '', + 'max-keys' => 2, + ); + + while (true) { + try { + + $listObjectInfo = $this->ossClient->listObjectsV2($this->bucket, $options); + } catch (OssException $e) { + $this->assertTrue(false); + } + $options[OssClient::OSS_CONTINUATION_TOKEN] = $listObjectInfo->getNextContinuationToken(); + $listObject = $listObjectInfo->getObjectList(); + $count += count($listObject); + $this->assertEquals(2, count($listObject)); + if ($listObjectInfo->getIsTruncated() !== "true") { + break; + } + } + $this->assertEquals(12 + 8 + 5 + 3 + 2, $count); + } + + + public function testListObjectsWithStartAfter() + { + $count = 0; + $options = array( + 'delimiter' => '', + 'start-after' => 'folder/11', + 'max-keys' => 1, + ); + while (true) { + try { + $listObjectInfo = $this->ossClient->listObjectsV2($this->bucket, $options); + } catch (OssException $e) { + $this->assertTrue(false); + } + $options[OssClient::OSS_CONTINUATION_TOKEN] = $listObjectInfo->getNextContinuationToken(); + $listObject = $listObjectInfo->getObjectList(); + $count += count($listObject); + $this->assertEquals(1, count($listObject)); + if ($listObjectInfo->getIsTruncated() !== "true") { + break; + } + } + $this->assertEquals(8 + 5 + 3, $count); + $options2 = array( + 'delimiter' => '', + 'start-after' => 'folder/11', + 'max-keys' => 5, + ); + try { + $listObjectInfo = $this->ossClient->listObjectsV2($this->bucket, $options2); + } catch (OssException $e) { + $this->assertTrue(false); + } + $listObject = $listObjectInfo->getObjectList(); + $this->assertEquals(5, count($listObject)); + $this->assertEquals("true", $listObjectInfo->getIsTruncated()); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientMultipartUploadTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientMultipartUploadTest.php new file mode 100644 index 0000000..3cd6a1e --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientMultipartUploadTest.php @@ -0,0 +1,476 @@ +ossClient->uploadDir($this->bucket, "", "abc/ds/s/s/notexitst"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals("parameter error: abc/ds/s/s/notexitst is not a directory, please check it", $e->getMessage()); + } + + } + + public function testMultipartUploadBigFile() + { + $bigFileName = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile.tmp"; + $localFilename = __DIR__ . DIRECTORY_SEPARATOR . "/localfile.tmp"; + OssUtil::generateFile($bigFileName, 6 * 1024 * 1024); + $object = 'mpu/multipart-bigfile-test.tmp'; + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $bigFileName, array(OssClient::OSS_PART_SIZE => 1)); + $options = array(OssClient::OSS_FILE_DOWNLOAD => $localFilename); + $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals(md5_file($bigFileName), md5_file($localFilename)); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertFalse(true); + } + unlink($bigFileName); + unlink($localFilename); + } + + public function testMultipartUploadBigFileWithMD5Check() + { + $bigFileName = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile.tmp"; + $localFilename = __DIR__ . DIRECTORY_SEPARATOR . "/localfile.tmp"; + OssUtil::generateFile($bigFileName, 6 * 1024 * 1024); + $object = 'mpu/multipart-bigfile-test.tmp'; + $options = array( + OssClient::OSS_CHECK_MD5 => true, + OssClient::OSS_PART_SIZE => 1, + ); + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $bigFileName, $options); + $options = array(OssClient::OSS_FILE_DOWNLOAD => $localFilename); + $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals(md5_file($bigFileName), md5_file($localFilename)); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertFalse(true); + } + unlink($bigFileName); + unlink($localFilename); + } + + public function testCopyPart() + { + $object = "mpu/multipart-test.txt"; + $copiedObject = "mpu/multipart-test.txt.copied"; + $this->ossClient->putObject($this->bucket, $copiedObject, file_get_contents(__FILE__)); + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $copyId = 1; + $eTag = $this->ossClient->uploadPartCopy($this->bucket, $copiedObject, $this->bucket, $object, $copyId, $upload_id); + $upload_parts[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); + + try { + $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + + $this->assertEquals($this->ossClient->getObject($this->bucket, $object), file_get_contents(__FILE__)); + $this->assertEquals($this->ossClient->getObject($this->bucket, $copiedObject), file_get_contents(__FILE__)); + } + + public function testCopyPartWithRange() + { + $object = "mpu/multipart-test.txt"; + $copiedObject = "mpu/multipart-test.txt.range.copied"; + $this->ossClient->putObject($this->bucket, $copiedObject, file_get_contents(__FILE__)); + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + /* + * step 2. uploadPartCopy + */ + $copyId = 1; + $options = array( + 'start' => 0, + 'end' => 3, + ); + $eTag = $this->ossClient->uploadPartCopy($this->bucket, $copiedObject, $this->bucket, $object, $copyId, $upload_id, $options); + $upload_parts[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); + + try { + $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertTrue(false); + } + + $this->assertEquals($this->ossClient->getObject($this->bucket, $copiedObject), file_get_contents(__FILE__)); + $this->assertEquals($this->ossClient->getObject($this->bucket, $object), 'ossClient->initiateMultipartUpload($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + $part_size = 10 * 1024 * 1024; + $upload_file = __FILE__; + $upload_filesize = sprintf('%u',filesize($upload_file)); + $pieces = $this->ossClient->generateMultiuploadParts($upload_filesize, $part_size); + $response_upload_part = array(); + $upload_position = 0; + $is_check_md5 = true; + foreach ($pieces as $i => $piece) { + $from_pos = $upload_position + (integer)$piece[OssClient::OSS_SEEK_TO]; + $to_pos = (integer)$piece[OssClient::OSS_LENGTH] + $from_pos - 1; + $up_options = array( + OssClient::OSS_FILE_UPLOAD => $upload_file, + OssClient::OSS_PART_NUM => ($i + 1), + OssClient::OSS_SEEK_TO => $from_pos, + OssClient::OSS_LENGTH => $to_pos - $from_pos + 1, + OssClient::OSS_CHECK_MD5 => $is_check_md5, + ); + if ($is_check_md5) { + $content_md5 = OssUtil::getMd5SumForFile($upload_file, $from_pos, $to_pos); + $up_options[OssClient::OSS_CONTENT_MD5] = $content_md5; + } + //2. 将每一分片上传到OSS + try { + $response_upload_part[] = $this->ossClient->uploadPart($this->bucket, $object, $upload_id, $up_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + $upload_parts = array(); + foreach ($response_upload_part as $i => $eTag) { + $upload_parts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $eTag, + ); + } + + try { + $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id, array('max-parts' => 100)); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + $this->assertEquals(1, count($listPartsInfo->getListPart())); + + $numOfMultipartUpload1 = 0; + $options = null; + try { + $listMultipartUploadInfo = $listMultipartUploadInfo = $this->ossClient->listMultipartUploads($this->bucket, $options); + $this->assertNotNull($listMultipartUploadInfo); + $numOfMultipartUpload1 = count($listMultipartUploadInfo->getUploads()); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->ossClient->abortMultipartUpload($this->bucket, $object, $upload_id); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $numOfMultipartUpload2 = 0; + try { + $listMultipartUploadInfo = $listMultipartUploadInfo = $this->ossClient->listMultipartUploads($this->bucket, array('max-uploads' => 1000)); + $this->assertNotNull($listMultipartUploadInfo); + $numOfMultipartUpload2 = count($listMultipartUploadInfo->getUploads()); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertEquals($numOfMultipartUpload1 - 1, $numOfMultipartUpload2); + } + + public function testPutObjectByRawApis() + { + $object = "mpu/multipart-test.txt"; + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + $part_size = 10 * 1024 * 1024; + $upload_file = __FILE__; + $upload_filesize = sprintf('%u',filesize($upload_file)); + $pieces = $this->ossClient->generateMultiuploadParts($upload_filesize, $part_size); + $response_upload_part = array(); + $upload_position = 0; + $is_check_md5 = true; + foreach ($pieces as $i => $piece) { + $from_pos = $upload_position + (integer)$piece[OssClient::OSS_SEEK_TO]; + $to_pos = (integer)$piece[OssClient::OSS_LENGTH] + $from_pos - 1; + $up_options = array( + OssClient::OSS_FILE_UPLOAD => $upload_file, + OssClient::OSS_PART_NUM => ($i + 1), + OssClient::OSS_SEEK_TO => $from_pos, + OssClient::OSS_LENGTH => $to_pos - $from_pos + 1, + OssClient::OSS_CHECK_MD5 => $is_check_md5, + ); + if ($is_check_md5) { + $content_md5 = OssUtil::getMd5SumForFile($upload_file, $from_pos, $to_pos); + $up_options[OssClient::OSS_CONTENT_MD5] = $content_md5; + } + //2. 将每一分片上传到OSS + try { + $response_upload_part[] = $this->ossClient->uploadPart($this->bucket, $object, $upload_id, $up_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + $upload_parts = array(); + foreach ($response_upload_part as $i => $eTag) { + $upload_parts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $eTag, + ); + } + + try { + $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * step 3. + */ + try { + $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + function testPutObjectsByDir() + { + $localDirectory = dirname(__FILE__); + $prefix = "samples/codes"; + try { + $this->ossClient->uploadDir($this->bucket, $prefix, $localDirectory); + } catch (OssException $e) { + var_dump($e->getMessage()); + $this->assertFalse(true); + + } + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, 'samples/codes/' . "OssClientMultipartUploadTest.php")); + } + + public function testPutObjectByMultipartUpload() + { + $object = "mpu/multipart-test.txt"; + $file = __FILE__; + $options = array(); + + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $file, $options); + $this->assertFalse(false); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testPutObjectByMultipartUploadWithMD5Check() + { + $object = "mpu/multipart-test.txt"; + $file = __FILE__; + $options = array(OssClient::OSS_CHECK_MD5 => true); + + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $file, $options); + $this->assertFalse(false); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testPutObjectByMultipartUploadWithOSS_LENGTH() + { + $object = "mpu/multipart-test-length.txt"; + $file = __FILE__; + + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + $options = array(OssClient::OSS_LENGTH => 4, OssClient::OSS_UPLOAD_ID => $upload_id); + $this->ossClient->multiuploadFile($this->bucket, $object, $file, $options); + $this->assertEquals($this->ossClient->getObject($this->bucket, $object), 'assertFalse(true); + } + } + + public function testPutObjectByMultipartUploadWithOSS_CONTENT_LENGTH() + { + $object = "mpu/multipart-test-content-length.txt"; + $file = __FILE__; + + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + $options = array(OssClient::OSS_CONTENT_LENGTH => 4, OssClient::OSS_UPLOAD_ID => $upload_id); + $this->ossClient->multiuploadFile($this->bucket, $object, $file, $options); + $this->assertEquals($this->ossClient->getObject($this->bucket, $object), 'assertFalse(true); + } + } + + public function testPutObjectByMultipartUploadWithException() + { + $object = "mpu/multipart-test-exception.txt"; + $file = ""; + + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $file); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "parameter invalid, file is empty") == false) + { + $this->assertTrue(true); + } + } + } + + public function testListMultipartUploads() + { + $options = null; + try { + $listMultipartUploadInfo = $this->ossClient->listMultipartUploads($this->bucket, $options); + $this->assertNotNull($listMultipartUploadInfo); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testCompleteMultipartUploadWithException() + { + $object = "mpu/multipart-test-complete.txt"; + $uploadId = "uploadId"; + try { + $listMultipartUploadInfo = $this->ossClient->completeMultipartUpload($this->bucket, $object, $uploadId, null); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('NoSuchUpload', $e->getErrorCode()); + } + } + + public function testCompleteMultipartUploadWithEmptyArray(){ + $object = 'multipart-test-complete.txt'; + try { + $uploadId = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + $listMultipartUploadInfo = $this->ossClient->completeMultipartUpload($this->bucket, $object, $uploadId, array()); + $this->assertNotNull($listMultipartUploadInfo); + } catch (OssException $e) { + $this->assertFalse(true); + } + + } + + + public function testCompleteMultipartUploadWithNull(){ + $object = "mpu/multipart-test.txt"; + try { + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $part_size = 5 * 1024 * 1024; + $upload_file = __FILE__; + $upload_filesize = sprintf('%u',filesize($upload_file)); + $pieces = $this->ossClient->generateMultiuploadParts($upload_filesize, $part_size); + $response_upload_part = array(); + $upload_position = 0; + $is_check_md5 = true; + foreach ($pieces as $i => $piece) { + $from_pos = $upload_position + (integer)$piece[OssClient::OSS_SEEK_TO]; + $to_pos = (integer)$piece[OssClient::OSS_LENGTH] + $from_pos - 1; + $up_options = array( + OssClient::OSS_FILE_UPLOAD => $upload_file, + OssClient::OSS_PART_NUM => ($i + 1), + OssClient::OSS_SEEK_TO => $from_pos, + OssClient::OSS_LENGTH => $to_pos - $from_pos + 1, + OssClient::OSS_CHECK_MD5 => $is_check_md5, + ); + if ($is_check_md5) { + $content_md5 = OssUtil::getMd5SumForFile($upload_file, $from_pos, $to_pos); + $up_options[OssClient::OSS_CONTENT_MD5] = $content_md5; + } + try { + $response_upload_part[] = $this->ossClient->uploadPart($this->bucket, $object, $upload_id, $up_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + $upload_parts = array(); + foreach ($response_upload_part as $i => $eTag) { + $upload_parts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $eTag, + ); + } + + try { + $listPartsInfo = $this->ossClient->listParts($this->bucket, $object, $upload_id); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options['headers'] = array( + 'x-oss-forbid-overwrite' => 'false', + 'x-oss-complete-all'=> 'yes' + ); + + try { + $result = $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, null,$options); + $this->assertNotNull($result); + } catch (OssException $e) { + $this->assertTrue(false); + } + + } + + + +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectRequestPaymentTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectRequestPaymentTest.php new file mode 100644 index 0000000..9f645d3 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectRequestPaymentTest.php @@ -0,0 +1,472 @@ +payerClient->listObjects($this->bucket); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->createObjectDir($this->bucket, 'folder/'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->putObject($this->bucket, 'object', 'content'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->putSymlink($this->bucket, 'symlink', 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->getSymlink($this->bucket, 'default-symlink'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->uploadFile($this->bucket, 'file-object', __FILE__); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->appendObject($this->bucket, 'append-object', 'content', 0); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->appendObject($this->bucket, 'append-file', __FILE__, 0); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->copyObject($this->bucket, 'default-object', $this->bucket, 'copy-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->getObjectMeta($this->bucket, 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + try { + $this->payerClient->getSimplifiedObjectMeta($this->bucket, 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + try { + $this->payerClient->deleteObject($this->bucket, 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->getObject($this->bucket, 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->doesObjectExist($this->bucket, 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + try { + $this->payerClient->restoreObject($this->bucket, 'default-ia-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $config = new TaggingConfig(); + $config->addTag(new Tag("key1", "value1")); + $this->payerClient->putObjectTagging($this->bucket, 'default-object', $config); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->getObjectTagging($this->bucket, 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->deleteObjectTagging($this->bucket, 'default-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->initiateMultipartUpload($this->bucket, 'mup-object'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + $uploadId= $this->ossClient->initiateMultipartUpload($this->bucket, 'mup-object'); + + try { + $this->payerClient->listParts($this->bucket, 'mup-object', $uploadId); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->abortMultipartUpload($this->bucket, 'mup-object', $uploadId); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->listMultipartUploads($this->bucket); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + + try { + $this->payerClient->multiuploadFile($this->bucket, 'mup-file', __FILE__); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('AccessDenied', $e->getErrorCode()); + } + } + + public function testObjectOperationsWithRequester() + { + $options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => 'requester', + )); + + try { + $this->payerClient->listObjects($this->bucket, $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->createObjectDir($this->bucket, 'folder/', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->putObject($this->bucket, 'object', 'content', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->putSymlink($this->bucket, 'symlink', 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->getSymlink($this->bucket, 'default-symlink', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->uploadFile($this->bucket, 'file-object', __FILE__, $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->appendObject($this->bucket, 'append-object', 'content', 0, $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->appendObject($this->bucket, 'append-file', __FILE__, 0, $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->copyObject($this->bucket, 'default-object', $this->bucket, 'copy-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->getObjectMeta($this->bucket, 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->getSimplifiedObjectMeta($this->bucket, 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->getObject($this->bucket, 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->putObject($this->bucket, 'test-object', 'content', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->deleteObject($this->bucket, 'test-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->doesObjectExist($this->bucket, 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $ia_options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-storage-class' => 'Archive', + )); + $this->ossClient->putObject($this->bucket, 'default-Archive-object', 'content', $ia_options); + try { + $this->payerClient->restoreObject($this->bucket, 'default-Archive-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $config = new TaggingConfig(); + $config->addTag(new Tag("key1", "value1")); + $this->payerClient->putObjectTagging($this->bucket, 'default-object', $config, $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->getObjectTagging($this->bucket, 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->payerClient->deleteObjectTagging($this->bucket, 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testMultipartOperationsWithRequester() + { + $options = array( + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => 'requester', + )); + + $object = "mpu/multipart-test.txt"; + /** + * step 1. 初始化一个分块上传事件, 也就是初始化上传Multipart, 获取upload id + */ + try { + $upload_id = $this->payerClient->initiateMultipartUpload($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /* + * step 2. 上传分片 + */ + $part_size = 1 * 1024 * 1024; + $upload_file = __FILE__; + $upload_filesize = sprintf('%u',filesize($upload_file)); + $pieces = $this->payerClient->generateMultiuploadParts($upload_filesize, $part_size); + $response_upload_part = array(); + $upload_position = 0; + $is_check_md5 = false; + foreach ($pieces as $i => $piece) { + $from_pos = $upload_position + (integer)$piece[OssClient::OSS_SEEK_TO]; + $to_pos = (integer)$piece[OssClient::OSS_LENGTH] + $from_pos - 1; + $up_options = array( + OssClient::OSS_FILE_UPLOAD => $upload_file, + OssClient::OSS_PART_NUM => ($i + 1), + OssClient::OSS_SEEK_TO => $from_pos, + OssClient::OSS_LENGTH => $to_pos - $from_pos + 1, + OssClient::OSS_CHECK_MD5 => $is_check_md5, + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => 'requester', + ), + ); + + //2. 将每一分片上传到OSS + try { + $response_upload_part[] = $this->ossClient->uploadPart($this->bucket, $object, $upload_id, $up_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + $upload_parts = array(); + foreach ($response_upload_part as $i => $eTag) { + $upload_parts[] = array( + 'PartNumber' => ($i + 1), + 'ETag' => $eTag, + ); + } + + try { + $listPartsInfo = $this->payerClient->listParts($this->bucket, $object, $upload_id, $options); + $this->assertNotNull($listPartsInfo); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $uploads = $this->payerClient->listMultipartUploads($this->bucket, $options); + $this->assertNotNull($uploads); + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * step 3. + */ + try { + $this->payerClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts, $options); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testMiscOperationsWithRequester() + { + //use multipart + $options = array( + OssClient::OSS_PART_SIZE => 1, + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => 'requester', + )); + + $bigFileName = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile.tmp"; + OssUtil::generateFile($bigFileName, 256 * 1024); + $object = 'mpu/multipart-bigfile-test.tmp'; + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $bigFileName, $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertFalse(true); + } + + //use uploadfile + $options = array( + OssClient::OSS_PART_SIZE => 1024*1024, + OssClient::OSS_HEADERS => array( + OssClient::OSS_REQUEST_PAYER => 'requester', + )); + + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $bigFileName, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + unlink($bigFileName); + } + + protected function setUp(): void + { + parent::setUp(); + $this->payerClient = new OssClient( + Common::getPayerAccessKeyId(), + Common::getPayerAccessKeySecret(), + Common::getEndpoint(), false); + + $policy = '{"Version":"1","Statement":[{"Action":["oss:*"],"Effect": "Allow",'. + '"Principal":["' . Common::getPayerUid() . '"],'. + '"Resource": ["acs:oss:*:*:' . $this->bucket . '","acs:oss:*:*:' . $this->bucket . '/*"]}]}'; + + $this->ossClient->putBucketPolicy($this->bucket, $policy); + $this->ossClient->putBucketRequestPayment($this->bucket, 'Requester'); + $this->ossClient->putObject($this->bucket, "default-object", ""); + $this->ossClient->putSymlink($this->bucket, "default-symlink", "default-object"); + } + + protected function tearDown(): void + { + parent::tearDown(); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTaggingTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTaggingTest.php new file mode 100644 index 0000000..401d1b7 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTaggingTest.php @@ -0,0 +1,160 @@ +ossClient->putObject($this->bucket, $object, $content); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $config = $this->ossClient->getObjectTagging($this->bucket, $object); + $this->assertEquals(0, count($config->getTags())); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $config = new TaggingConfig(); + $config->addTag(new Tag("key1", "value1")); + $config->addTag(new Tag("key2", "value2")); + $config->addTag(new Tag("key3", "value3")); + $this->ossClient->putObjectTagging($this->bucket, $object, $config); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $config2 = $this->ossClient->getObjectTagging($this->bucket, $object); + $this->assertEquals(3, count($config2->getTags())); + $this->assertEquals("key1", $config2->getTags()[0]->getKey()); + $this->assertEquals("value1", $config2->getTags()[0]->getValue()); + $this->assertEquals("key2", $config2->getTags()[1]->getKey()); + $this->assertEquals("value2", $config2->getTags()[1]->getValue()); + $this->assertEquals("key3", $config2->getTags()[2]->getKey()); + $this->assertEquals("value3", $config2->getTags()[2]->getValue()); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $this->ossClient->deleteObjectTagging($this->bucket, $object); + $config2 = $this->ossClient->getObjectTagging($this->bucket, $object); + $this->assertEquals(0, count($config2->getTags())); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testPutObjectTaggingFromHeader() + { + $object = "object-tagging-header.txt"; + $content = "hello world"; + + try { + $options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', + )); + + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + + $config2 = $this->ossClient->getObjectTagging($this->bucket, $object); + $this->assertEquals(3, count($config2->getTags())); + $this->assertEquals("key1", $config2->getTags()[0]->getKey()); + $this->assertEquals("value1", $config2->getTags()[0]->getValue()); + $this->assertEquals("key2", $config2->getTags()[1]->getKey()); + $this->assertEquals("value2", $config2->getTags()[1]->getValue()); + $this->assertEquals("key3", $config2->getTags()[2]->getKey()); + $this->assertEquals("value3", $config2->getTags()[2]->getValue()); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testAppendObjectTaggingFromHeader() + { + $object = "append-object-tagging-header.txt"; + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + + try { + $options = array( + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', + )); + + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0, $options); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position, array(OssClient::OSS_LENGTH => strlen($content_array[2]))); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[2])); + + $config2 = $this->ossClient->getObjectTagging($this->bucket, $object); + $this->assertEquals(3, count($config2->getTags())); + $this->assertEquals("key1", $config2->getTags()[0]->getKey()); + $this->assertEquals("value1", $config2->getTags()[0]->getValue()); + $this->assertEquals("key2", $config2->getTags()[1]->getKey()); + $this->assertEquals("value2", $config2->getTags()[1]->getValue()); + $this->assertEquals("key3", $config2->getTags()[2]->getKey()); + $this->assertEquals("value3", $config2->getTags()[2]->getValue()); + + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testMultipartUploadTaggingFromHeader() + { + $file = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile.tmp"; + OssUtil::generateFile($file, 110 * 1024); + + $object = "mpu-object-tagging-header.txt"; + $options = array( + OssClient::OSS_CHECK_MD5 => true, + OssClient::OSS_PART_SIZE => 1, + OssClient::OSS_HEADERS => array( + 'x-oss-tagging' => 'key1=value1&key2=value2&key3=value3', + ), + ); + try { + $this->ossClient->multiuploadFile($this->bucket, $object, $file, $options); + + $config2 = $this->ossClient->getObjectTagging($this->bucket, $object); + $this->assertEquals(3, count($config2->getTags())); + $this->assertEquals("key1", $config2->getTags()[0]->getKey()); + $this->assertEquals("value1", $config2->getTags()[0]->getValue()); + $this->assertEquals("key2", $config2->getTags()[1]->getKey()); + $this->assertEquals("value2", $config2->getTags()[1]->getValue()); + $this->assertEquals("key3", $config2->getTags()[2]->getKey()); + $this->assertEquals("value3", $config2->getTags()[2]->getValue()); + } catch (OssException $e) { + $this->assertFalse(true); + } + + unlink($file); + } + +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTest.php new file mode 100644 index 0000000..a573f15 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectTest.php @@ -0,0 +1,938 @@ +ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertTrue(isset($res['content-encoding'])); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + + try { + $res = $this->ossClient->getObjectMeta($this->bucket, $object, $options); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertEquals('gzip', $res['content-encoding']); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testGetObjectWithAcceptEncoding() + { + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + + try { + $res = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testGetObjectWithHeader() + { + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $res = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_LAST_MODIFIED => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + } + + public function testGetObjectWithIleggalEtag() + { + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $res = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_ETAG => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + } + + public function testObject() + { + /** + * Upload the local variable to bucket + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $result = $this->ossClient->deleteObjects($this->bucket, "stringtype", $options); + $this->assertEquals('stringtype', $result[0]); + } catch (OssException $e) { + $this->assertEquals('objects must be array', $e->getMessage()); + } + + try { + $result = $this->ossClient->deleteObjects($this->bucket, "stringtype", $options); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('objects must be array', $e->getMessage()); + } + + try { + $this->ossClient->uploadFile($this->bucket, $object, "notexist.txt", $options); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('notexist.txt file does not exist', $e->getMessage()); + } + + /** + * GetObject to the local variable and check for match + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject first five bytes + */ + try { + $options = array(OssClient::OSS_RANGE => '0-4'); + $content = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals($content, 'assertFalse(true); + } + + + /** + * Upload the local file to object + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local variable and check for match. + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local file + */ + $localfile = "upload-test-object-name.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->ossClient->getObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertTrue(file_get_contents($localfile) === file_get_contents(__FILE__)); + if (file_exists($localfile)) { + unlink($localfile); + } + + /** + * Download the file to the local file. no such key + */ + $localfile = "upload-test-object-name-no-such-key.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->ossClient->getObject($this->bucket, $object . "no-such-key", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + $this->assertFalse(file_exists($localfile)); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Download the file to the content. no such key + */ + try { + $result = $this->ossClient->getObject($this->bucket, $object . "no-such-key"); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Copy object + */ + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $options = array(); + try { + $result = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object, $options); + $this->assertFalse(empty($result)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($result[0])); + $this->assertEquals(strlen("\"5B3C1A2E053D763E1B002CC607C5A0FE\""), strlen($result[1])); + } catch (OssException $e) { + $this->assertFalse(true); + var_dump($e->getMessage()); + + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $to_object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * List the files in your bucket. + */ + $prefix = ''; + $delimiter = '/'; + $next_marker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $next_marker, + ); + + try { + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * Set the meta information for the file + */ + $from_bucket = $this->bucket; + $from_object = "oss-php-sdk-test/upload-test-object-name.txt"; + $to_bucket = $from_bucket; + $to_object = $from_object; + $copy_options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + try { + $this->ossClient->copyObject($from_bucket, $from_object, $to_bucket, $to_object, $copy_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $objectMeta = $this->ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete single file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $this->ossClient->deleteObject($this->bucket, $object); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete multiple files + */ + $object1 = "oss-php-sdk-test/upload-test-object-name.txt"; + $object2 = "oss-php-sdk-test/upload-test-object-name.txt.copy"; + $list = array($object1, $object2); + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object2)); + + $result = $this->ossClient->deleteObjects($this->bucket, $list); + $this->assertEquals($list[0], $result[0]); + $this->assertEquals($list[1], $result[1]); + + $result = $this->ossClient->deleteObjects($this->bucket, $list, array('quiet' => 'true')); + $this->assertEquals(array(), $result); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object2)); + + $this->ossClient->putObject($this->bucket, $object, $content); + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $result = $this->ossClient->deleteObjects($this->bucket, $list, array('quiet' => true)); + $this->assertEquals(array(), $result); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testAppendObject() + { + $object = "oss-php-sdk-test/append-test-object-name.txt"; + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + + /** + * Append the upload string + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position, array(OssClient::OSS_LENGTH => strlen($content_array[2]))); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[2])); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append the upload of invalid local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, "invalid-file-path", 0); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + /** + * Append the upload of local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, 0); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, $position); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__)) * 2); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + $options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + + /** + * Append upload with option + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, "Hello OSS, ", 0, $options); + $position = $this->ossClient->appendObject($this->bucket, $object, "Hi OSS.", $position); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + try { + $objectMeta = $this->ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testPutIllelObject() + { + $object = "/ilegal.txt"; + try { + $this->ossClient->putObject($this->bucket, $object, "hi", null); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + } + + public function testCheckMD5() + { + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + $content = file_get_contents(__FILE__); + $options = array(OssClient::OSS_CHECK_MD5 => true); + + /** + * Upload data to start MD5 + */ + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Upload file to start MD5 + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $object = "oss-php-sdk-test/append-test-object-name.txt"; + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + $options = array(OssClient::OSS_CHECK_MD5 => true); + + /** + * Append the upload string + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0, $options); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[1])); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append upload of local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, 0, $options); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, $position, $options); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__)) * 2); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testWithInvalidBucketName() + { + try { + $this->ossClient->createBucket("abcefc/", "test-key"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('"abcefc/"bucket name is invalid', $e->getMessage()); + } + } + + public function testGetSimplifiedObjectMeta() + { + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + + try { + $objectMeta = $this->ossClient->getSimplifiedObjectMeta($this->bucket, $object); + $this->assertEquals(false, array_key_exists(strtolower('Content-Disposition'), $objectMeta)); + $this->assertEquals(strlen(file_get_contents(__FILE__)), $objectMeta[strtolower('Content-Length')]); + $this->assertEquals(true, array_key_exists(strtolower('ETag'), $objectMeta)); + $this->assertEquals(true, array_key_exists(strtolower('Last-Modified'), $objectMeta)); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testUploadStream() + { + $object = "oss-php-sdk-test/put-from-stream.txt"; + $options = array(OssClient::OSS_CHECK_MD5 => true); + $handle = fopen(__FILE__, 'rb'); + /** + * Upload data to start MD5 + */ + try { + $this->ossClient->uploadStream($this->bucket, $object, $handle, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $object = "oss-php-sdk-test/put-from-stream-without-md5.txt"; + $handle = fopen(__FILE__, 'rb'); + try { + $this->ossClient->uploadStream($this->bucket, $object, $handle); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + } + + public function testObjectKeyWithQuestionMark() + { + /** + * Upload the local variable to bucket + */ + $object = "oss-php-sdk-test/??/upload-test-object-name???123??123??.txt"; + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject to the local variable and check for match + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject first five bytes + */ + try { + $options = array(OssClient::OSS_RANGE => '0-4'); + $content = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals($content, 'assertFalse(true); + } + + + /** + * Upload the local file to object + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local variable and check for match. + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Copy object + */ + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $options = array(); + try { + $result = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object, $options); + $this->assertFalse(empty($result)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($result[0])); + $this->assertEquals(strlen("\"5B3C1A2E053D763E1B002CC607C5A0FE\""), strlen($result[1])); + } catch (OssException $e) { + $this->assertFalse(true); + var_dump($e->getMessage()); + + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $to_object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $this->ossClient->deleteObject($this->bucket, $object); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testObjectKeyWithNonUTF8Name() + { + $object = "中文测试.txt"; + $hexObject = bin2hex($object); + $gbkObject = iconv('UTF-8', 'GBK', $object); + $hexGbkObject = bin2hex($gbkObject); + $content = "hello world"; + + $this->assertEquals("e4b8ade69687e6b58be8af952e747874", $hexObject); + $this->assertEquals("d6d0cec4b2e2cad42e747874", $hexGbkObject); + + try { + $this->ossClient->putObject($this->bucket, $gbkObject, $content); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('InvalidArgument', $e->getErrorCode()); + $this->assertEquals('The characters encoding must be utf-8.', $e->getErrorMessage()); + } catch (\Exception $e) { + $this->assertTrue(false); + } + + //enable object encoding check + $config = array( + 'checkObjectEncoding' => true, + ); + $ossClient = Common::getOssClient($config); + try { + $ossClient->putObject($this->bucket, $gbkObject, $content); + $content1 = $this->ossClient->getObject($this->bucket, $object); + $content2 = $ossClient->getObject($this->bucket, $gbkObject); + $this->assertEquals($content, $content1); + $this->assertEquals($content, $content2); + } catch (\Exception $e) { + $this->assertTrue(false); + } + + // ascii + try { + $ossClient->putObject($this->bucket, '1234', 'ascii'); + $content1 = $this->ossClient->getObject($this->bucket, '1234'); + $content2 = $ossClient->getObject($this->bucket, '1234'); + $this->assertEquals('ascii', $content1); + $this->assertEquals('ascii', $content2); + } catch (\Exception $e) { + $this->assertTrue(false); + } + } + + public function testEncodeFilePath() + { + if (!OssUtil::isWin()) { + $this->assertTrue(true); + return; + } + + $fileFolder = __DIR__ . DIRECTORY_SEPARATOR . "中文目录"; + $filePath1 = $fileFolder . DIRECTORY_SEPARATOR . "中文文件名1.txt"; + $filePath2 = $fileFolder . DIRECTORY_SEPARATOR . "中文文件名2.txt"; + + $gbkfileFolder = iconv('UTF-8', 'GBK', $fileFolder); + $gbkfilePath1 = iconv('UTF-8', 'GBK', $filePath1); + $gbkfilePath2 = iconv('UTF-8', 'GBK', $filePath2); + + $hexfilePath1 = bin2hex($filePath1); + $hexGbkfilePath2 = bin2hex($gbkfilePath2); + + $content1 = ''; + $content2 = ''; + if (version_compare(phpversion(), '7.0.0', '<')) { + try { + mkdir($gbkfileFolder); + } catch (\Exception $e) { + } + OssUtil::generateFile($gbkfilePath1, 200 * 1024); + OssUtil::generateFile($gbkfilePath2, 202 * 1024); + $content1 = file_get_contents($gbkfilePath1); + $content2 = file_get_contents($gbkfilePath2); + } else { + try { + mkdir($fileFolder); + } catch (\Exception $e) { + } + OssUtil::generateFile($filePath1, 200 * 1024); + OssUtil::generateFile($filePath2, 202 * 1024); + $content1 = file_get_contents($filePath1); + $content2 = file_get_contents($filePath2); + } + + try { + + // upload file + $this->ossClient->uploadFile($this->bucket, '123', $filePath1); + $this->ossClient->uploadFile($this->bucket, '234', $gbkfilePath2); + + $res = $this->ossClient->getObject($this->bucket, '123'); + $this->assertEquals($content1, $res); + + $res = $this->ossClient->getObject($this->bucket, '234'); + $this->assertEquals($content2, $res); + + // append file + $position = $this->ossClient->appendFile($this->bucket, 'append-file', $filePath1, 0); + $position = $this->ossClient->appendFile($this->bucket, 'append-file', $gbkfilePath2, $position); + + $res = $this->ossClient->getObject($this->bucket, 'append-file'); + $this->assertEquals($content1.$content2, $res); + + // multi paet + $this->ossClient->multiuploadFile($this->bucket, 'multi-file-123', $filePath1, array(OssClient::OSS_PART_SIZE => 1)); + $this->ossClient->multiuploadFile($this->bucket, 'multi-file-234', $gbkfilePath2, array(OssClient::OSS_PART_SIZE => 1)); + $res = $this->ossClient->getObject($this->bucket, 'multi-file-123'); + $this->assertEquals($content1, $res); + + $res = $this->ossClient->getObject($this->bucket, 'multi-file-234'); + $this->assertEquals($content2, $res); + + // uploadDir + $this->ossClient->uploadDir($this->bucket, "dir", $fileFolder); + $options = array( + 'delimiter' => '', + 'prefix' => "dir", + ); + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $this->assertEquals(2, count($objectList)); + $this->assertEquals('dir/中文文件名1.txt', $objectList[0]->getKey()); + $this->assertEquals('dir/中文文件名2.txt', $objectList[1]->getKey()); + + // uploadDir + if (version_compare(phpversion(), '7.0.0', '<')) { + $this->ossClient->uploadDir($this->bucket, "gbkdir", $gbkfileFolder); + $options = array( + 'delimiter' => '', + 'prefix' => "gbkdir", + ); + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $this->assertEquals(2, count($objectList)); + $this->assertEquals('gbkdir/中文文件名1.txt', $objectList[0]->getKey()); + $this->assertEquals('gbkdir/中文文件名2.txt', $objectList[1]->getKey()); + } + + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + if (phpversion() < "7.0.0") { + unlink($gbkfilePath1); + unlink($gbkfilePath2); + rmdir($gbkfileFolder); + } else { + unlink($filePath1); + unlink($filePath2); + rmdir($fileFolder); + } + } catch (\Exception $e) { + } + } + + protected function setUp(): void + { + parent::setUp(); + $this->ossClient->putObject($this->bucket, 'oss-php-sdk-test/upload-test-object-name.txt', file_get_contents(__FILE__)); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectVersioningTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectVersioningTest.php new file mode 100644 index 0000000..66f204a --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientObjectVersioningTest.php @@ -0,0 +1,610 @@ +ossClient->putObject($this->bucket, $object, $content1, array(OssClient::OSS_HEADERS => array('x-oss-object-acl' => 'public-read', 'x-oss-tagging' => 'key1=value1'))); + $ret2 = $this->ossClient->putObject($this->bucket, $object, $content2, array(OssClient::OSS_HEADERS => array('x-oss-object-acl' => 'private', 'x-oss-tagging' => 'key2=value2'))); + + $this->assertTrue(isset($ret1[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($ret2[OssClient::OSS_HEADER_VERSION_ID])); + + $versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID]; + $versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID]; + + //get object + $res = $this->ossClient->getObject($this->bucket, $object); + $res1 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $res2 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2)); + $this->assertEquals($content1, $res1); + $this->assertEquals($content2, $res2); + $this->assertEquals($content2, $res); + + //meta + $headers = $this->ossClient->getObjectMeta($this->bucket, $object); + $headers1 = $this->ossClient->getObjectMeta($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $headers2 = $this->ossClient->getObjectMeta($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2)); + + $this->assertTrue(isset($headers[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($headers1[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($headers2[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertEquals($versionId1, $headers1[OssClient::OSS_HEADER_VERSION_ID]); + $this->assertEquals($versionId2, $headers2[OssClient::OSS_HEADER_VERSION_ID]); + $this->assertEquals($versionId2, $headers[OssClient::OSS_HEADER_VERSION_ID]); + + + $sheaders = $this->ossClient->getSimplifiedObjectMeta($this->bucket, $object); + $sheaders1 = $this->ossClient->getSimplifiedObjectMeta($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $sheaders2 = $this->ossClient->getSimplifiedObjectMeta($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2)); + + $this->assertTrue(isset($sheaders[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($sheaders1[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($sheaders2[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertEquals($versionId1, $sheaders1[OssClient::OSS_HEADER_VERSION_ID]); + $this->assertEquals($versionId2, $sheaders2[OssClient::OSS_HEADER_VERSION_ID]); + $this->assertEquals($versionId2, $sheaders[OssClient::OSS_HEADER_VERSION_ID]); + + //acl + $acl = $this->ossClient->getObjectAcl($this->bucket, $object); + $acl1 = $this->ossClient->getObjectAcl($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $acl2 = $this->ossClient->getObjectAcl($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2)); + + $this->assertEquals('public-read', $acl1); + $this->assertEquals('private', $acl2); + $this->assertEquals('private', $acl); + + $this->ossClient->putObjectAcl($this->bucket, $object, 'public-read-write', array(OssClient::OSS_VERSION_ID => $versionId1)); + $acl = $this->ossClient->getObjectAcl($this->bucket, $object); + $acl1 = $this->ossClient->getObjectAcl($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $this->assertEquals('public-read-write', $acl1); + $this->assertEquals('private', $acl); + + //tagging + $tag = $this->ossClient->getObjectTagging($this->bucket, $object); + $tag1 = $this->ossClient->getObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $tag2 = $this->ossClient->getObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2)); + $this->assertEquals(1, count($tag1->getTags())); + $this->assertEquals("key1", $tag1->getTags()[0]->getKey()); + $this->assertEquals("value1", $tag1->getTags()[0]->getValue()); + $this->assertEquals(1, count($tag2->getTags())); + $this->assertEquals("key2", $tag2->getTags()[0]->getKey()); + $this->assertEquals("value2", $tag2->getTags()[0]->getValue()); + $this->assertEquals(1, count($tag->getTags())); + $this->assertEquals("key2", $tag->getTags()[0]->getKey()); + $this->assertEquals("value2", $tag->getTags()[0]->getValue()); + + $config = new TaggingConfig(); + $config->addTag(new Tag("key11", "value11")); + $this->ossClient->putObjectTagging($this->bucket, $object, $config, array(OssClient::OSS_VERSION_ID => $versionId1)); + $tag = $this->ossClient->getObjectTagging($this->bucket, $object); + $tag1 = $this->ossClient->getObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $this->assertEquals(1, count($tag1->getTags())); + $this->assertEquals("key11", $tag1->getTags()[0]->getKey()); + $this->assertEquals("value11", $tag1->getTags()[0]->getValue()); + $this->assertEquals(1, count($tag->getTags())); + $this->assertEquals("key2", $tag->getTags()[0]->getKey()); + $this->assertEquals("value2", $tag->getTags()[0]->getValue()); + + $this->ossClient->deleteObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $tag = $this->ossClient->getObjectTagging($this->bucket, $object); + $tag1 = $this->ossClient->getObjectTagging($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $this->assertEquals(0, count($tag1->getTags())); + $this->assertEquals(1, count($tag->getTags())); + $this->assertEquals("key2", $tag->getTags()[0]->getKey()); + $this->assertEquals("value2", $tag->getTags()[0]->getValue()); + + //delete + $dret = $this->ossClient->deleteObject($this->bucket, $object); + $this->assertTrue(isset($dret['x-oss-delete-marker'])); + $this->assertTrue(isset($dret['x-oss-version-id'])); + $this->assertEquals("true", $dret['x-oss-delete-marker']); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1))); + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId2))); + + $dret1 = $this->ossClient->deleteObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $this->assertFalse(isset($dret1['x-oss-delete-marker'])); + $this->assertTrue(isset($dret1['x-oss-version-id'])); + $this->assertEquals($versionId1, $dret1['x-oss-version-id']); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1))); + + + $dret_ = $this->ossClient->deleteObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $dret['x-oss-version-id'])); + $this->assertTrue(isset($dret_['x-oss-delete-marker'])); + $this->assertTrue(isset($dret_['x-oss-version-id'])); + $this->assertEquals($dret['x-oss-version-id'], $dret_['x-oss-version-id']); + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + + } + + public function testObjectSymlink() + { + $object1 = 'object-target-1'; + $object2 = 'object-target-2'; + $symlink = 'object-symlink'; + $content1 = 'hello'; + $content2 = 'hello world'; + + + $ret1 = $this->ossClient->putObject($this->bucket, $object1, $content1); + $sym1 = $this->ossClient->putSymlink($this->bucket, $symlink, $object1); + + $ret2 = $this->ossClient->putObject($this->bucket, $object2, $content2); + $sym2 = $this->ossClient->putSymlink($this->bucket, $symlink, $object2); + + $this->assertTrue(isset($ret1[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($ret2[OssClient::OSS_HEADER_VERSION_ID])); + + $this->assertTrue(isset($sym1[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($sym2[OssClient::OSS_HEADER_VERSION_ID])); + + $versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID]; + $versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID]; + + $sym_versionId1 = $sym1[OssClient::OSS_HEADER_VERSION_ID]; + $sym_versionId2 = $sym2[OssClient::OSS_HEADER_VERSION_ID]; + + + $sym_ret = $this->ossClient->getSymlink($this->bucket, $symlink); + $sym_ret1 = $this->ossClient->getSymlink($this->bucket, $symlink, array(OssClient::OSS_VERSION_ID => $sym_versionId1)); + $sym_ret2 = $this->ossClient->getSymlink($this->bucket, $symlink, array(OssClient::OSS_VERSION_ID => $sym_versionId2)); + + $this->assertTrue(isset($sym_ret['x-oss-version-id'])); + $this->assertTrue(isset($sym_ret1['x-oss-version-id'])); + $this->assertTrue(isset($sym_ret2['x-oss-version-id'])); + + $this->assertEquals($sym_versionId1, $sym_ret1['x-oss-version-id']); + $this->assertEquals($sym_versionId2, $sym_ret2['x-oss-version-id']); + $this->assertEquals($sym_versionId2, $sym_ret['x-oss-version-id']); + + + $res = $this->ossClient->getObject($this->bucket, $symlink); + $res1 = $this->ossClient->getObject($this->bucket, $symlink, array(OssClient::OSS_VERSION_ID => $sym_versionId1)); + $res2 = $this->ossClient->getObject($this->bucket, $symlink, array(OssClient::OSS_VERSION_ID => $sym_versionId2)); + $this->assertEquals($content1, $res1); + $this->assertEquals($content2, $res2); + $this->assertEquals($content2, $res); + } + + public function testObjectCopy() + { + $object = 'copy-= +object'; + $content1 = 'hello'; + $content2 = 'hello world'; + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $to_object1 = $object . '.copy1'; + $to_object2 = $object . '.copy2'; + + $ret1 = $this->ossClient->putObject($this->bucket, $object, $content1); + $ret2 = $this->ossClient->putObject($this->bucket, $object, $content2); + + $versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID]; + $versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID]; + + $cret = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object); + $cret1 = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object1, array(OssClient::OSS_VERSION_ID => $versionId1)); + $cret2 = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object2, array(OssClient::OSS_VERSION_ID => $versionId2)); + $this->assertFalse(empty($cret1)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($cret1[0])); + $this->assertEquals(trim($ret1['etag'], '"'), trim($cret1[1], '"')); + $this->assertTrue(isset($cret1['x-oss-version-id'])); + $this->assertEquals($versionId1, $cret1['x-oss-copy-source-version-id']); + + $this->assertFalse(empty($cret2)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($cret2[0])); + $this->assertEquals(trim($ret2['etag'], '"'), trim($cret2[1], '"')); + $this->assertTrue(isset($cret2['x-oss-version-id'])); + $this->assertEquals($versionId2, $cret2['x-oss-copy-source-version-id']); + + $this->assertFalse(empty($cret)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($cret[0])); + $this->assertEquals(trim($ret2['etag'], '"'), trim($cret[1], '"')); + $this->assertTrue(isset($cret2['x-oss-version-id'])); + $this->assertEquals($versionId2, $cret['x-oss-copy-source-version-id']); + + $res = $this->ossClient->getObject($this->bucket, $to_object); + $res1 = $this->ossClient->getObject($this->bucket, $to_object1); + $res2 = $this->ossClient->getObject($this->bucket, $to_object2); + $this->assertEquals($content1, $res1); + $this->assertEquals($content2, $res2); + $this->assertEquals($content2, $res); + } + + public function testObjectRestore() + { + $object = 'retore-object'; + $content1 = 'hello'; + $content2 = 'hello world'; + $ret1 = $this->ossClient->putObject($this->bucket, $object, $content1, array(OssClient::OSS_HEADERS => array('x-oss-storage-class' => 'Archive'))); + $ret2 = $this->ossClient->putObject($this->bucket, $object, $content2); + + $versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID]; + $versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID]; + + try{ + $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('403', $e->getHTTPStatus()); + $this->assertEquals('InvalidObjectState', $e->getErrorCode()); + } + + try{ + $this->ossClient->restoreObject($this->bucket, $object); + $this->assertTrue(false); + }catch(OssException $e){ + $this->assertEquals('400', $e->getHTTPStatus()); + $this->assertEquals('OperationNotSupported', $e->getErrorCode()); + } + + $result = $this->ossClient->restoreObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + common::waitMetaSync(); + $this->assertEquals('202', $result['info']['http_code']); + + try{ + $this->ossClient->restoreObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $versionId1)); + }catch(OssException $e){ + $this->assertEquals('409', $e->getHTTPStatus()); + $this->assertEquals('RestoreAlreadyInProgress', $e->getErrorCode()); + } + } + + public function testObjectMultiPart() + { + $object_src = 'multi-= +object.src'; + $content1 = 'hello'; + $content2 = 'hello world'; + $ret1 = $this->ossClient->putObject($this->bucket, $object_src, $content1); + $ret2 = $this->ossClient->putObject($this->bucket, $object_src, $content2); + + $this->assertTrue(isset($ret1[OssClient::OSS_HEADER_VERSION_ID])); + $this->assertTrue(isset($ret2[OssClient::OSS_HEADER_VERSION_ID])); + + $versionId1 = $ret1[OssClient::OSS_HEADER_VERSION_ID]; + $versionId2 = $ret2[OssClient::OSS_HEADER_VERSION_ID]; + + //object + $object = "multi-object"; + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object); + $copyId = 1; + $eTag = $this->ossClient->uploadPartCopy($this->bucket, $object_src, $this->bucket, $object, $copyId, $upload_id); + $upload_parts[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); + $ret = $this->ossClient->completeMultipartUpload($this->bucket, $object, $upload_id, $upload_parts); + + //object-1 + $object1 = "multi-object-1"; + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object1); + $copyId = 1; + $eTag = $this->ossClient->uploadPartCopy($this->bucket, $object_src, $this->bucket, $object1, $copyId, $upload_id, array(OssClient::OSS_VERSION_ID => $versionId1)); + $upload_parts1[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); + $ret1 = $this->ossClient->completeMultipartUpload($this->bucket, $object1, $upload_id, $upload_parts1); + + //object-2 + $object2 = "multi-object-2"; + $upload_id = $this->ossClient->initiateMultipartUpload($this->bucket, $object2); + $copyId = 1; + $eTag = $this->ossClient->uploadPartCopy($this->bucket, $object_src, $this->bucket, $object2, $copyId, $upload_id, array(OssClient::OSS_VERSION_ID => $versionId2)); + $upload_parts2[] = array( + 'PartNumber' => $copyId, + 'ETag' => $eTag, + ); + $ret2 = $this->ossClient->completeMultipartUpload($this->bucket, $object2, $upload_id, $upload_parts2); + + $res = $this->ossClient->getObject($this->bucket, $object); + $res1 = $this->ossClient->getObject($this->bucket, $object1); + $res2 = $this->ossClient->getObject($this->bucket, $object2); + + $this->assertEquals($content1, $res1); + $this->assertEquals($content2, $res2); + $this->assertEquals($content2, $res); + } + + public function testObjectMisc() + { + //use multipart + $options = array( + OssClient::OSS_PART_SIZE => 1, + ); + + $object = 'misc-object'; + + $smallFile1 = __DIR__ . DIRECTORY_SEPARATOR . "/smallfile1.tmp"; + $smallFile2 = __DIR__ . DIRECTORY_SEPARATOR . "/smallfile2.tmp"; + $bigFile1 = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile1.tmp"; + $bigFile2 = __DIR__ . DIRECTORY_SEPARATOR . "/bigfile2.tmp"; + + OssUtil::generateFile($smallFile1, 5); + OssUtil::generateFile($smallFile2, 10); + OssUtil::generateFile($bigFile1, 128 * 1024); + OssUtil::generateFile($bigFile2, 256 * 1024); + + $sret1 = $this->ossClient->multiuploadFile($this->bucket, $object, $smallFile1, $options); + $sret2 = $this->ossClient->multiuploadFile($this->bucket, $object, $smallFile2, $options); + $bret1 = $this->ossClient->multiuploadFile($this->bucket, $object, $bigFile1, $options); + $bret2 = $this->ossClient->multiuploadFile($this->bucket, $object, $bigFile2, $options); + + + $res = $this->ossClient->getObject($this->bucket, $object); + $sres1 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $sret1['x-oss-version-id'])); + $sres2 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $sret2['x-oss-version-id'])); + $bres1 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $bret1['x-oss-version-id'])); + $bres2 = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_VERSION_ID => $bret2['x-oss-version-id'])); + + + $this->assertEquals(file_get_contents($smallFile1), $sres1); + $this->assertEquals(file_get_contents($smallFile2), $sres2); + $this->assertEquals(file_get_contents($bigFile1), $bres1); + $this->assertEquals(file_get_contents($bigFile2), $bres2); + $this->assertEquals(file_get_contents($bigFile2), $res); + + + unlink($smallFile1); + unlink($smallFile2); + unlink($bigFile1); + unlink($bigFile2); + } + + public function testListObjects() + { + //folder + for ($i = 0; $i < 12; $i++) { + $key = 'folder/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + $this->ossClient->putObject($this->bucket, $key, "content"); + $this->ossClient->deleteObject($this->bucket, $key); + } + + //test + for ($i = 0; $i < 8; $i++) { + $key = 'test/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + $this->ossClient->deleteObject($this->bucket, $key); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //work + for ($i = 0; $i < 5; $i++) { + $key = 'work/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //sub++ + for ($i = 0; $i < 3; $i++) { + $key = 'sub++/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + $this->ossClient->putObject($this->bucket, $key, "content"); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + //file++ + for ($i = 0; $i < 2; $i++) { + $key = 'file++'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + $this->ossClient->deleteObject($this->bucket, $key); + } + + //list default + $result = $this->ossClient->listObjectVersions($this->bucket); + $versionList = $result->getObjectVersionList(); + $deleteMarkerList = $result->getDeleteMarkerList(); + $prefixList = $result->getPrefixList(); + + $this->assertNotNull($versionList); + $this->assertNotNull($deleteMarkerList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($versionList)); + $this->assertTrue(is_array($deleteMarkerList)); + $this->assertTrue(is_array($prefixList)); + $this->assertEquals(2, count($versionList)); + $this->assertEquals(2, count($deleteMarkerList)); + $this->assertEquals(4, count($prefixList)); + + $this->assertEquals('file++00', $versionList[0]->getKey()); + $this->assertEquals('false', $versionList[0]->getIsLatest()); + $this->assertEquals('file++01', $versionList[1]->getKey()); + $this->assertEquals('false', $versionList[1]->getIsLatest()); + + $this->assertEquals('file++00', $deleteMarkerList[0]->getKey()); + $this->assertEquals('true', $deleteMarkerList[0]->getIsLatest()); + $this->assertEquals('file++01', $deleteMarkerList[1]->getKey()); + $this->assertEquals('true', $deleteMarkerList[1]->getIsLatest()); + + + $this->assertEquals('folder/', $prefixList[0]->getPrefix()); + $this->assertEquals('sub++/', $prefixList[1]->getPrefix()); + $this->assertEquals('test/', $prefixList[2]->getPrefix()); + $this->assertEquals('work/', $prefixList[3]->getPrefix()); + + //list by prefix + $prefix = 'folder/'; + $delimiter = ''; + $next_marker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'key-marker' => $next_marker, + ); + + $result = $this->ossClient->listObjectVersions($this->bucket, $options); + $versionList = $result->getObjectVersionList(); + $deleteMarkerList = $result->getDeleteMarkerList(); + $prefixList = $result->getPrefixList(); + + $this->assertEquals(24, count($versionList)); + $this->assertEquals(12, count($deleteMarkerList)); + $this->assertEquals(0, count($prefixList)); + + $this->assertEquals('folder/00', $versionList[0]->getKey()); + $this->assertEquals('folder/00', $versionList[1]->getKey()); + $this->assertEquals('folder/00', $deleteMarkerList[0]->getKey()); + $this->assertEquals('folder/01', $deleteMarkerList[1]->getKey()); + + + //max-key & key-marker & version-id-marker + $count = 0; + $markerCount = 0; + $nextMarker = ''; + $nextVersionIdMarker = ''; + + while (true) { + $options = array( + 'delimiter' => '', + 'key-marker' => $nextMarker, + 'max-keys' => 1, + 'version-id-marker' => $nextVersionIdMarker, + ); + $result = $this->ossClient->listObjectVersions($this->bucket, $options); + + $nextMarker = $result->getNextKeyMarker(); + $nextVersionIdMarker = $result->getNextVersionIdMarker(); + $count += count($result->getObjectVersionList()); + $markerCount += count($result->getDeleteMarkerList()); + $this->assertEquals(1, count($result->getObjectVersionList()) + count($result->getDeleteMarkerList())); + if ($result->getIsTruncated() !== "true") { + break; + } + } + $this->assertEquals(12*3 + 8*3 + 5 + 3*3 + 2*2, $count + $markerCount); + } + + public function testDeleteObjects() + { + //deletes + for ($i = 0; $i < 5; $i++) { + $key = 'deletes/'. sprintf("%02d",$i); + $this->ossClient->putObject($this->bucket, $key, "content"); + $this->ossClient->putObject($this->bucket, $key, "content"); + } + + $options = array( + 'delimiter' => '', + 'prefix' => 'deletes/', + 'max-keys' => 1000, + ); + $result = $this->ossClient->listObjects($this->bucket, $options); + $this->assertEquals(5, count($result->getObjectList())); + + //delete without version-id + $objects = array(); + for ($i = 0; $i < 5; $i++) { + $key = 'deletes/'. sprintf("%02d",$i); + $objects[] = new DeleteObjectInfo($key); + } + $dresult = $this->ossClient->deleteObjectVersions($this->bucket, $objects); + $this->assertEquals(5, count($dresult)); + $this->assertEquals('deletes/00', $dresult[0]->getKey()); + $this->assertEquals('true', $dresult[0]->getDeleteMarker()); + $this->assertEquals('', $dresult[0]->getVersionId()); + $this->assertFalse(empty($dresult[0]->getDeleteMarkerVersionId())); + + $result = $this->ossClient->listObjects($this->bucket, $options); + $this->assertEquals(0, count($result->getObjectList())); + + //delete by version-id + $vresult = $this->ossClient->listObjectVersions($this->bucket, $options); + $versions = $vresult->getObjectVersionList(); + $deleteMarkerList = $vresult->getDeleteMarkerList(); + $this->assertEquals(10, count($versions)); + $this->assertEquals(5, count($deleteMarkerList)); + + $objects = array(); + foreach ($versions as $obj) { + $objects[] = new DeleteObjectInfo($obj->getKey(), $obj->getVersionId()); + } + $dresult = $this->ossClient->deleteObjectVersions($this->bucket, $objects); + $this->assertEquals(10, count($dresult)); + $this->assertEquals('deletes/00', $dresult[0]->getKey()); + $this->assertEquals('', $dresult[0]->getDeleteMarker()); + $this->assertFalse(empty($dresult[0]->getVersionId())); + $this->assertTrue(empty($dresult[0]->getDeleteMarkerVersionId())); + $this->assertEquals('deletes/00', $dresult[1]->getKey()); + $this->assertEquals('', $dresult[1]->getDeleteMarker()); + $this->assertFalse(empty($dresult[1]->getVersionId())); + $this->assertTrue(empty($dresult[1]->getDeleteMarkerVersionId())); + + + $vresult = $this->ossClient->listObjectVersions($this->bucket, $options); + $versions = $vresult->getObjectVersionList(); + $deleteMarkerList = $vresult->getDeleteMarkerList(); + $this->assertEquals(0, count($versions)); + $this->assertEquals(5, count($deleteMarkerList)); + + $objects = array(); + foreach ($deleteMarkerList as $obj) { + $objects[] = new DeleteObjectInfo($obj->getKey(), $obj->getVersionId()); + } + $dresult = $this->ossClient->deleteObjectVersions($this->bucket, $objects); + $this->assertEquals(5, count($dresult)); + $this->assertEquals('deletes/00', $dresult[0]->getKey()); + $this->assertEquals('true', $dresult[0]->getDeleteMarker()); + $this->assertFalse(empty($dresult[1]->getVersionId())); + $this->assertFalse(empty($dresult[1]->getDeleteMarkerVersionId())); + + $vresult = $this->ossClient->listObjectVersions($this->bucket, $options); + $versions = $vresult->getObjectVersionList(); + $deleteMarkerList = $vresult->getDeleteMarkerList(); + $this->assertEquals(0, count($versions)); + $this->assertEquals(0, count($deleteMarkerList)); + } + + protected function setUp(): void + { + parent::setUp(); + + $this->ossClient->putBucketVersioning($this->bucket, "Enabled"); + + } + + protected function tearDown(): void + { + if (!$this->ossClient->doesBucketExist($this->bucket)) { + return; + } + + $this->ossClient->putBucketVersioning($this->bucket, "Suspended"); + + $result = $this->ossClient->listObjectVersions( + $this->bucket, array('max-keys' => 1000, 'delimiter' => '')); + + $versions = $result->getObjectVersionList(); + $deleteMarkers = $result->getDeleteMarkerList(); + + foreach ($versions as $obj) { + $options = array( + OssClient::OSS_VERSION_ID => $obj->getVersionId(), + ); + $this->ossClient->deleteObject($this->bucket, $obj->getKey(), $options); + } + + foreach ($deleteMarkers as $del) { + $options = array( + OssClient::OSS_VERSION_ID => $del->getVersionId(), + ); + $this->ossClient->deleteObject($this->bucket, $del->getKey(), $options); + } + + parent::tearDown(); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignTest.php new file mode 100644 index 0000000..14dc047 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignTest.php @@ -0,0 +1,70 @@ + OssClient::OSS_SIGNATURE_VERSION_V1 + ); + $this->bucket = Common::getBucketName() . '-' . time(); + $this->ossClient = Common::getOssClient($config); + $this->ossClient->createBucket($this->bucket); + Common::waitMetaSync(); + + $object = "a.file"; + $this->ossClient->putObject($this->bucket, $object, "hi oss"); + $timeout = 3600; + $options = array( + "response-content-disposition" => "inline" + ); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, OssClient::OSS_HTTP_GET, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertStringContainsString("response-content-disposition=inline", $signedUrl); + $options = array( + "response-content-disposition" => "attachment", + ); + + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, OssClient::OSS_HTTP_GET, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertStringContainsString("response-content-disposition=attachment", $signedUrl); + + $httpCore = new RequestCore($signedUrl); + $httpCore->set_body(""); + $httpCore->set_method("GET"); + $httpCore->connect_timeout = 10; + $httpCore->timeout = 10; + $httpCore->add_header("Content-Type", ""); + $httpCore->send_request(); + $this->assertEquals(200, $httpCore->response_code); + } + + protected function tearDown(): void + { + $this->ossClient->deleteObject($this->bucket, "a.file"); + parent::tearDown(); + } + + protected function setUp(): void + { + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignV4Test.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignV4Test.php new file mode 100644 index 0000000..28296bc --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientPresignV4Test.php @@ -0,0 +1,369 @@ +ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $timeout = 3600; + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + + //testGetSignedUrlForPuttingObject + $object = "a.file"; + $timeout = 3600; + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT"); + $content = file_get_contents(__FILE__); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + sleep(1); + + // test Get SignedUrl For Putting Object From File + $file = __FILE__; + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', 'txt'); + $request->set_read_file($file); + $request->set_read_stream_size(sprintf('%u', filesize($file))); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + sleep(1); + // test SignedUrl With Exception + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "POST", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "method is invalid") == false) { + $this->assertTrue(false); + } + } + + // test GetgenPreSignedUrl For GettingObject + $object = "a.file"; + $this->ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $expires = time() + 3600; + try { + $signedUrl = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expires); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + // test Get genPreSignedUrl Vs SignedUrl + + $object = "object-vs.file"; + $signedUrl1 = '245'; + $signedUrl2 = '123'; + $expiration = 0; + + do { + usleep(500000); + $begin = time(); + $expiration = time() + 3600; + $signedUrl1 = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expiration); + $signedUrl2 = $this->ossClient->signUrl($this->bucket, $object, 3600); + $end = time(); + } while ($begin != $end); + $this->assertEquals($signedUrl1, $signedUrl2); + $this->assertTrue(strpos($signedUrl1, 'x-oss-expires=') !== false); + + $object = "a.file"; + $options = array( + OssClient::OSS_HEADERS => array( + 'name' => 'aliyun', + 'email' => 'aliyun@aliyun.com', + 'book' => 'english', + ), + OssClient::OSS_ADDITIONAL_HEADERS => array("name", "email") + ); + $this->ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__), $options); + $expires = time() + 3600; + try { + $signedUrl = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expires, "GET", $options); + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->add_header('name', 'aliyun'); + $request->add_header('email', 'aliyun@aliyun.com'); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + + + try { + $signedUrl = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expires); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + + + } + + public function testObjectWithStsClientSignV4() + { + $object = "a.file"; + $this->stsOssClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $timeout = 3600; + try { + $signedUrl = $this->stsOssClient->signUrl($this->bucket, $object, $timeout); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + + //testGetSignedUrlForPuttingObject + $object = "a.file"; + $timeout = 3600; + try { + $signedUrl = $this->stsOssClient->signUrl($this->bucket, $object, $timeout, "PUT"); + $content = file_get_contents(__FILE__); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + sleep(1); + + // test Get SignedUrl For Putting Object From File + $file = __FILE__; + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->stsOssClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', 'txt'); + $request->set_read_file($file); + $request->set_read_stream_size(sprintf('%u', filesize($file))); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + sleep(1); + // test SignedUrl With Exception + $file = __FILE__; + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->stsOssClient->signUrl($this->bucket, $object, $timeout, "POST", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "method is invalid") == false) { + $this->assertTrue(false); + } + } + + // test GetgenPreSignedUrl For GettingObject + $object = "a.file"; + $this->stsOssClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $expires = time() + 3600; + try { + $signedUrl = $this->stsOssClient->generatePresignedUrl($this->bucket, $object, $expires); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + } catch (OssException $e) { + $this->assertFalse(true); + } + + // test Get genPreSignedUrl Vs SignedUrl + + $object = "object-vs.file"; + + do { + usleep(500000); + $begin = time(); + $expiration = time() + 3600; + $signedUrl1 = $this->stsOssClient->generatePresignedUrl($this->bucket, $object, $expiration); + $signedUrl2 = $this->stsOssClient->signUrl($this->bucket, $object, 3600); + $end = time(); + } while ($begin != $end); + $this->assertEquals($signedUrl1, $signedUrl2); + $this->assertTrue(strpos($signedUrl1, 'x-oss-expires=') !== false); + + $object = "a.file"; + $options = array( + OssClient::OSS_HEADERS => array( + 'name' => 'aliyun', + 'email' => 'aliyun@aliyun.com', + 'book' => 'english', + ), + OssClient::OSS_ADDITIONAL_HEADERS => array("name", "email") + ); + $this->stsOssClient->putObject($this->bucket, $object, file_get_contents(__FILE__), $options); + $expires = time() + 3600; + try { + $signedUrl = $this->stsOssClient->generatePresignedUrl($this->bucket, $object, $expires, "GET", $options); + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->add_header('name', 'aliyun'); + $request->add_header('email', 'aliyun@aliyun.com'); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + sleep(1); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + } + + public function testObjectWithSignV4AndResponseQuery() + { + $config = array( + 'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4 + ); + $this->bucket = Common::getBucketName() . '-' . time(); + $this->ossClient = Common::getOssClient($config); + $this->ossClient->createBucket($this->bucket); + Common::waitMetaSync(); + + $object = "a.file"; + $this->ossClient->putObject($this->bucket, $object, "hi oss"); + $timeout = 3600; + $options = array( + "response-content-disposition" => "inline" + ); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, OssClient::OSS_HTTP_GET, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertStringContainsString("response-content-disposition=inline", $signedUrl); + $options = array( + "response-content-disposition" => "attachment" + ); + + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, OssClient::OSS_HTTP_GET, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertStringContainsString("response-content-disposition=attachment", $signedUrl); + + $httpCore = new RequestCore($signedUrl); + $httpCore->set_body(""); + $httpCore->set_method("GET"); + $httpCore->connect_timeout = 10; + $httpCore->timeout = 10; + $httpCore->add_header("Content-Type", ""); + $httpCore->send_request(); + $this->assertEquals(200, $httpCore->response_code); + } + + protected function tearDown(): void + { + $this->ossClient->deleteObject($this->bucket, "a.file"); + parent::tearDown(); + } + + protected function setUp(): void + { + $config = array( + 'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4 + ); + $this->bucket = Common::getBucketName() . '-' . time(); + $this->ossClient = Common::getOssClient($config); + $this->ossClient->createBucket($this->bucket); + Common::waitMetaSync(); + $this->stsOssClient = Common::getStsOssClient($config); + Common::waitMetaSync(); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientRestoreObjectTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientRestoreObjectTest.php new file mode 100644 index 0000000..9aa0b9b --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientRestoreObjectTest.php @@ -0,0 +1,174 @@ +ossClient->putObject($this->iaBucket, $object,'testcontent'); + try{ + $this->ossClient->restoreObject($this->iaBucket, $object); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('400', $e->getHTTPStatus()); + $this->assertEquals('OperationNotSupported', $e->getErrorCode()); + } + } + + public function testNullObjectRestoreObject() + { + $object = 'null-object'; + + try{ + $this->ossClient->restoreObject($this->bucket, $object); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('404', $e->getHTTPStatus()); + } + } + + public function testArchiveRestoreObject() + { + $object = 'storage-object'; + + $this->ossClient->putObject($this->archiveBucket, $object,'testcontent'); + try{ + $this->ossClient->getObject($this->archiveBucket, $object); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('403', $e->getHTTPStatus()); + $this->assertEquals('InvalidObjectState', $e->getErrorCode()); + } + $result = $this->ossClient->restoreObject($this->archiveBucket, $object); + common::waitMetaSync(); + $this->assertEquals('202', $result['info']['http_code']); + + try{ + $this->ossClient->restoreObject($this->archiveBucket, $object); + }catch(OssException $e){ + $this->assertEquals('409', $e->getHTTPStatus()); + $this->assertEquals('RestoreAlreadyInProgress', $e->getErrorCode()); + } + } + + public function testColdArchiveRestoreObject() + { + $client = new OssClient( + getenv('OSS_ACCESS_KEY_ID'), + getenv('OSS_ACCESS_KEY_SECRET'), + 'oss-ap-southeast-1.aliyuncs.com', false); + + $bucket = $this->bucket . 'cold-archive'; + $object = 'storage-object'; + + //create bucket + $options = array( + OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_COLDARCHIVE + ); + $client->createBucket($bucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options); + + //test with days + $client->putObject($bucket, $object,'testcontent'); + + try{ + $client->getObject($bucket, $object); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('403', $e->getHTTPStatus()); + $this->assertEquals('InvalidObjectState', $e->getErrorCode()); + } + + $config = new RestoreConfig(5); + $resoptions = array( + OssClient::OSS_RESTORE_CONFIG => $config + ); + try{ + $client->restoreObject($bucket, $object, $resoptions); + }catch(OssException $e){ + $this->assertTrue(false); + } + + try{ + $client->restoreObject($bucket, $object, $resoptions); + }catch(OssException $e){ + $this->assertEquals('409', $e->getHTTPStatus()); + $this->assertEquals('RestoreAlreadyInProgress', $e->getErrorCode()); + } + + //test with days & tier + $client->putObject($bucket, $object,'testcontent'); + + try{ + $client->getObject($bucket, $object); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('403', $e->getHTTPStatus()); + $this->assertEquals('InvalidObjectState', $e->getErrorCode()); + } + + $config = new RestoreConfig(5, "Expedited"); + $resoptions = array( + OssClient::OSS_RESTORE_CONFIG => $config + ); + try{ + $client->restoreObject($bucket, $object, $resoptions); + }catch(OssException $e){ + $this->assertTrue(false); + } + + try{ + $client->restoreObject($bucket, $object, $resoptions); + }catch(OssException $e){ + $this->assertEquals('409', $e->getHTTPStatus()); + $this->assertEquals('RestoreAlreadyInProgress', $e->getErrorCode()); + } + + $client->deleteObject($bucket, $object); + $client->deleteBucket($bucket); + } + + + protected function setUp(): void + { + parent::setUp(); + + $this->iaBucket = 'ia-' . $this->bucket; + $this->archiveBucket = 'archive-' . $this->bucket; + $options = array( + OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_IA + ); + + $this->ossClient->createBucket($this->iaBucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options); + + $options = array( + OssClient::OSS_STORAGE => OssClient::OSS_STORAGE_ARCHIVE + ); + + $this->ossClient->createBucket($this->archiveBucket, OssClient::OSS_ACL_TYPE_PRIVATE, $options); + } + + protected function tearDown(): void + { + parent::tearDown(); + + $object = 'storage-object'; + + $this->ossClient->deleteObject($this->iaBucket, $object); + $this->ossClient->deleteObject($this->archiveBucket, $object); + $this->ossClient->deleteBucket($this->iaBucket); + $this->ossClient->deleteBucket($this->archiveBucket); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureTest.php new file mode 100644 index 0000000..63e8bf3 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureTest.php @@ -0,0 +1,267 @@ +ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $timeout = 3600; + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + } + + public function testGetSignedUrlForPuttingObject() + { + $object = "a.file"; + $timeout = 3600; + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT"); + $content = file_get_contents(__FILE__); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testGetSignedUrlForPuttingObjectFromFile() + { + $file = __FILE__; + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', 'txt'); + $request->set_read_file($file); + $request->set_read_stream_size(sprintf('%u',filesize($file))); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + + } + + public function testSignedUrlWithException() + { + $file = __FILE__; + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "POST", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "method is invalid") == false) + { + $this->assertTrue(false); + } + } + + $object = "?a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "object name cannot start with `?`") == false) + { + $this->assertTrue(false); + } + } + + // Set StrictObjectName false + $object = "?a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + $config = array( + 'strictObjectName' => false + ); + $ossClient = Common::getOssClient($config); + try { + $signedUrl = $ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $this->assertTrue(true); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + + // V4 + $object = "?a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + $config = array( + 'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4 + ); + $ossClient = Common::getOssClient($config); + try { + $signedUrl = $ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $this->assertTrue(true); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + } + + function testGetgenPreSignedUrlForGettingObject() + { + $object = "a.file"; + $this->ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + $expires = time() + 3600; + try { + $signedUrl = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expires); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals(file_get_contents(__FILE__), $res->body); + } + + function testGetgenPreSignedUrlVsSignedUrl() + { + $object = "object-vs.file"; + $signedUrl1 = '245'; + $signedUrl2 = '123'; + $expiration = 0; + + do { + usleep(500000); + $begin = time(); + $expiration = time() + 3600; + $signedUrl1 = $this->ossClient->generatePresignedUrl($this->bucket, $object, $expiration); + $signedUrl2 = $this->ossClient->signUrl($this->bucket, $object, 3600); + $end = time(); + } while ($begin != $end); + $this->assertEquals($signedUrl1, $signedUrl2); + $this->assertTrue(strpos($signedUrl1, 'Expires='.$expiration) !== false); + } + + public function testPutObjectWithQueryCallback() + { + $object = "a.file"; + $timeout = 3600; + $url = '{"callbackUrl":"http://aliyun.com", "callbackBody":"bucket=${bucket}&object=${object}"}'; + $var = + '{ + "x:var1":"value1", + "x:var2":"value2" + }'; + try { + $options[OssClient::OSS_QUERY_STRING] = array( + 'callback'=>base64_encode($url), + 'callback-var'=>base64_encode($var) + ); + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $content = file_get_contents(__FILE__); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertEquals($res->status, 203); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $options = array(OssClient::OSS_CALLBACK => $url, + OssClient::OSS_CALLBACK_VAR => $var + ); + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $content = file_get_contents(__FILE__); + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header(OssClient::OSS_CALLBACK, base64_encode($url)); + $request->add_header(OssClient::OSS_CALLBACK_VAR , base64_encode($var)); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertEquals($res->status, 203); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + + protected function tearDown(): void + { + $this->ossClient->deleteObject($this->bucket, "a.file"); + parent::tearDown(); + } + + protected function setUp(): void + { + parent::setUp(); + /** + * 上传本地变量到bucket + */ + $object = "a.file"; + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Encoding' => 'utf-8', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureV4Test.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureV4Test.php new file mode 100644 index 0000000..ed26374 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientSignatureV4Test.php @@ -0,0 +1,1409 @@ +ossClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertTrue(false); + } + + // test GetObjectMeta + try { + $res = $this->ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertFalse(isset($res['Content-Encoding'])); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + try { + $res = $this->ossClient->getObjectMeta($this->bucket, $object, $options); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertFalse(isset($res['content-length'])); + $this->assertEquals('gzip', $res['content-encoding']); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + try { + $res = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + $res = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_LAST_MODIFIED => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + + try { + $res = $this->ossClient->getObject($this->bucket, $object, array(OssClient::OSS_ETAG => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $result = $this->ossClient->deleteObjects($this->bucket, "stringtype", $options); + $this->assertEquals('stringtype', $result[0]); + } catch (OssException $e) { + $this->assertEquals('objects must be array', $e->getMessage()); + } + + try { + $this->ossClient->uploadFile($this->bucket, $object, "notexist.txt", $options); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('notexist.txt file does not exist', $e->getMessage()); + } + + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject to the local variable and check for match + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject first five bytes + */ + try { + $options = array(OssClient::OSS_RANGE => '0-4'); + $content = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals($content, 'assertFalse(true); + } + + /** + * Upload the local file to object + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local variable and check for match. + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local file + */ + $localfile = "upload-test-object-name.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->ossClient->getObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertTrue(file_get_contents($localfile) === file_get_contents(__FILE__)); + if (file_exists($localfile)) { + unlink($localfile); + } + + /** + * Download the file to the local file. no such key + */ + $localfile = "upload-test-object-name-no-such-key.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->ossClient->getObject($this->bucket, $object . "no-such-key", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + $this->assertFalse(file_exists($localfile)); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Download the file to the content. no such key + */ + try { + $result = $this->ossClient->getObject($this->bucket, $object . "no-such-key"); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Copy object + */ + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $options = array(); + try { + $result = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object, $options); + $this->assertFalse(empty($result)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($result[0])); + $this->assertEquals(strlen("\"5B3C1A2E053D763E1B002CC607C5A0FE\""), strlen($result[1])); + } catch (OssException $e) { + $this->assertFalse(true); + var_dump($e->getMessage()); + + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $to_object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * List the files in your bucket. + */ + $prefix = ''; + $delimiter = '/'; + $next_marker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $next_marker, + ); + + try { + $listObjectInfo = $this->ossClient->listObjects($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * Set the meta information for the file + */ + $from_bucket = $this->bucket; + $from_object = "oss-php-sdk-test/upload-test-object-name.txt"; + $to_bucket = $from_bucket; + $to_object = $from_object; + $copy_options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + try { + $this->ossClient->copyObject($from_bucket, $from_object, $to_bucket, $to_object, $copy_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $objectMeta = $this->ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete single file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $this->ossClient->deleteObject($this->bucket, $object); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete multiple files + */ + $object1 = "oss-php-sdk-test/upload-test-object-name.txt"; + $object2 = "oss-php-sdk-test/upload-test-object-name.txt.copy"; + $list = array($object1, $object2); + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object2)); + + $result = $this->ossClient->deleteObjects($this->bucket, $list); + $this->assertEquals($list[0], $result[0]); + $this->assertEquals($list[1], $result[1]); + + $result = $this->ossClient->deleteObjects($this->bucket, $list, array('quiet' => 'true')); + $this->assertEquals(array(), $result); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object2)); + + $this->ossClient->putObject($this->bucket, $object, $content); + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $result = $this->ossClient->deleteObjects($this->bucket, $list, array('quiet' => true)); + $this->assertEquals(array(), $result); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + + $this->assertFalse(true); + } + + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + + /** + * Append the upload string + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position, array(OssClient::OSS_LENGTH => strlen($content_array[2]))); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[2])); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append the upload of invalid local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, "invalid-file-path", 0); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + /** + * Append the upload of local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, 0); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, $position); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__)) * 2); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + $options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + + /** + * Append upload with option + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, "Hello OSS, ", 0, $options); + $position = $this->ossClient->appendObject($this->bucket, $object, "Hi OSS.", $position); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + try { + $objectMeta = $this->ossClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $options = array(OssClient::OSS_CHECK_MD5 => true); + + $content = file_get_contents(__FILE__); + /** + * Upload data to start MD5 + */ + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Upload file to start MD5 + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $object = "oss-php-sdk-test/append-test-object-name.txt"; + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + $options = array(OssClient::OSS_CHECK_MD5 => true); + + /** + * Append the upload string + */ + try { + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[0], 0, $options); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[1], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->ossClient->appendObject($this->bucket, $object, $content_array[2], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[1])); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append upload of local files + */ + try { + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, 0, $options); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->ossClient->appendFile($this->bucket, $object, __FILE__, $position, $options); + $this->assertEquals($position, (sprintf('%u', filesize(__FILE__)) * 2)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $options = array( + OssClient::OSS_HEADERS => array( + "Content-Type" => "application/octet-stream", + "name" => "aliyun", + "email" => "aliyun@aliyun.com", + ), + OssClient::OSS_ADDITIONAL_HEADERS => array('name', 'email') + ); + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__, $options); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + + try { + $content = $this->ossClient->getObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * delete test object + */ + try { + $this->ossClient->deleteObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + } + + public function testObjectKeyWithQuestionMark() + { + /** + * Upload the local variable to bucket + */ + $object = "oss-php-sdk-test/??/upload-test-object-name???123??123??.txt"; + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->ossClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject to the local variable and check for match + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject first five bytes + */ + try { + $options = array(OssClient::OSS_RANGE => '0-4'); + $content = $this->ossClient->getObject($this->bucket, $object, $options); + $this->assertEquals($content, 'assertFalse(true); + } + + + /** + * Upload the local file to object + */ + try { + $this->ossClient->uploadFile($this->bucket, $object, __FILE__); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local variable and check for match. + */ + try { + $content = $this->ossClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Copy object + */ + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $options = array(); + try { + $result = $this->ossClient->copyObject($this->bucket, $object, $to_bucket, $to_object, $options); + $this->assertFalse(empty($result)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($result[0])); + $this->assertEquals(strlen("\"5B3C1A2E053D763E1B002CC607C5A0FE\""), strlen($result[1])); + } catch (OssException $e) { + $this->assertFalse(true); + var_dump($e->getMessage()); + + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->ossClient->getObject($this->bucket, $to_object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + try { + $this->assertTrue($this->ossClient->doesObjectExist($this->bucket, $object)); + $this->ossClient->deleteObject($this->bucket, $object); + $this->assertFalse($this->ossClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testBaseInterfaceForBucekt() + { + $this->ossClient->createBucket($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + + $bucketListInfo = $this->ossClient->listBuckets(); + $this->assertNotNull($bucketListInfo); + + $bucketList = $bucketListInfo->getBucketList(); + $this->assertTrue(is_array($bucketList)); + $this->assertGreaterThan(0, count($bucketList)); + + $this->ossClient->putBucketAcl($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + Common::waitMetaSync(); + $this->assertEquals($this->ossClient->getBucketAcl($this->bucket), OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + + $this->assertTrue($this->ossClient->doesBucketExist($this->bucket)); + $this->assertFalse($this->ossClient->doesBucketExist($this->bucket . '-notexist')); + + $this->assertNotNull($this->ossClient->getBucketLocation($this->bucket)); + + $res = $this->ossClient->getBucketMeta($this->bucket); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertNotNull($res['x-oss-bucket-region']); + } + + public function testBaseInterfaceForObjectWithSts() + { + + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $this->stsOssClient->putObject($this->bucket, $object, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertTrue(false); + } + + // test GetObjectMeta + try { + $res = $this->stsOssClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertTrue(isset($res['content-encoding'])); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + try { + $res = $this->stsOssClient->getObjectMeta($this->bucket, $object, $options); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertEquals('text/plain', $res['content-type']); + $this->assertEquals('Accept-Encoding', $res['vary']); + $this->assertEquals('gzip', $res['content-encoding']); + } catch (OssException $e) { + $this->assertTrue(false); + } + + $options = array(OssClient::OSS_HEADERS => array(OssClient::OSS_ACCEPT_ENCODING => 'deflate, gzip')); + try { + $res = $this->stsOssClient->getObject($this->bucket, $object, $options); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertTrue(false); + } + try { + $res = $this->stsOssClient->getObject($this->bucket, $object, array(OssClient::OSS_LAST_MODIFIED => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + + try { + $res = $this->stsOssClient->getObject($this->bucket, $object, array(OssClient::OSS_ETAG => "xx")); + $this->assertEquals(file_get_contents(__FILE__), $res); + } catch (OssException $e) { + $this->assertEquals('"/ilegal.txt" object name is invalid', $e->getMessage()); + } + + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $result = $this->stsOssClient->deleteObjects($this->bucket, "stringtype", $options); + $this->assertEquals('stringtype', $result[0]); + } catch (OssException $e) { + $this->assertEquals('objects must be array', $e->getMessage()); + } + + try { + $result = $this->stsOssClient->deleteObjects($this->bucket, "stringtype", $options); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('objects must be array', $e->getMessage()); + } + + try { + $this->stsOssClient->uploadFile($this->bucket, $object, "notexist.txt", $options); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('notexist.txt file does not exist', $e->getMessage()); + } + + $content = file_get_contents(__FILE__); + $options = array( + OssClient::OSS_LENGTH => strlen($content), + OssClient::OSS_HEADERS => array( + 'Expires' => 'Fri, 28 Feb 2020 05:38:42 GMT', + 'Cache-Control' => 'no-cache', + 'Content-Disposition' => 'attachment;filename=oss_download.log', + 'Content-Language' => 'zh-CN', + 'x-oss-server-side-encryption' => 'AES256', + 'x-oss-meta-self-define-title' => 'user define meta info', + ), + ); + + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + /** + * GetObject to the local variable and check for match + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * GetObject first five bytes + */ + try { + $options = array(OssClient::OSS_RANGE => '0-4'); + $content = $this->stsOssClient->getObject($this->bucket, $object, $options); + $this->assertEquals($content, 'assertFalse(true); + } + + + /** + * Upload the local file to object + */ + try { + $this->stsOssClient->uploadFile($this->bucket, $object, __FILE__); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local variable and check for match. + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Download the file to the local file + */ + $localfile = "upload-test-object-name.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->stsOssClient->getObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + $this->assertTrue(file_get_contents($localfile) === file_get_contents(__FILE__)); + if (file_exists($localfile)) { + unlink($localfile); + } + + /** + * Download the file to the local file. no such key + */ + $localfile = "upload-test-object-name-no-such-key.txt"; + $options = array( + OssClient::OSS_FILE_DOWNLOAD => $localfile, + ); + + try { + $this->stsOssClient->getObject($this->bucket, $object . "no-such-key", $options); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + $this->assertFalse(file_exists($localfile)); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Download the file to the content. no such key + */ + try { + $result = $this->stsOssClient->getObject($this->bucket, $object . "no-such-key"); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "The specified key does not exist") == false) { + $this->assertTrue(true); + } + } + + /** + * Copy object + */ + $to_bucket = $this->bucket; + $to_object = $object . '.copy'; + $options = array(); + try { + $result = $this->stsOssClient->copyObject($this->bucket, $object, $to_bucket, $to_object, $options); + $this->assertFalse(empty($result)); + $this->assertEquals(strlen("2016-11-21T03:46:58.000Z"), strlen($result[0])); + $this->assertEquals(strlen("\"5B3C1A2E053D763E1B002CC607C5A0FE\""), strlen($result[1])); + } catch (OssException $e) { + $this->assertFalse(true); + var_dump($e->getMessage()); + + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $to_object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * List the files in your bucket. + */ + $prefix = ''; + $delimiter = '/'; + $next_marker = ''; + $maxkeys = 1000; + $options = array( + 'delimiter' => $delimiter, + 'prefix' => $prefix, + 'max-keys' => $maxkeys, + 'marker' => $next_marker, + ); + + try { + $listObjectInfo = $this->stsOssClient->listObjects($this->bucket, $options); + $objectList = $listObjectInfo->getObjectList(); + $prefixList = $listObjectInfo->getPrefixList(); + $this->assertNotNull($objectList); + $this->assertNotNull($prefixList); + $this->assertTrue(is_array($objectList)); + $this->assertTrue(is_array($prefixList)); + + } catch (OssException $e) { + $this->assertTrue(false); + } + + /** + * Set the meta information for the file + */ + $from_bucket = $this->bucket; + $from_object = "oss-php-sdk-test/upload-test-object-name.txt"; + $to_bucket = $from_bucket; + $to_object = $from_object; + $copy_options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + try { + $this->stsOssClient->copyObject($from_bucket, $from_object, $to_bucket, $to_object, $copy_options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + try { + $objectMeta = $this->stsOssClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete single file + */ + $object = "oss-php-sdk-test/upload-test-object-name.txt"; + + try { + $this->assertTrue($this->stsOssClient->doesObjectExist($this->bucket, $object)); + $this->stsOssClient->deleteObject($this->bucket, $object); + $this->assertFalse($this->stsOssClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete multiple files + */ + $object1 = "oss-php-sdk-test/upload-test-object-name.txt"; + $object2 = "oss-php-sdk-test/upload-test-object-name.txt.copy"; + $list = array($object1, $object2); + try { + $this->assertTrue($this->stsOssClient->doesObjectExist($this->bucket, $object2)); + + $result = $this->stsOssClient->deleteObjects($this->bucket, $list); + $this->assertEquals($list[0], $result[0]); + $this->assertEquals($list[1], $result[1]); + + $result = $this->stsOssClient->deleteObjects($this->bucket, $list, array('quiet' => 'true')); + $this->assertEquals(array(), $result); + $this->assertFalse($this->stsOssClient->doesObjectExist($this->bucket, $object2)); + + $this->stsOssClient->putObject($this->bucket, $object, $content); + $this->assertTrue($this->stsOssClient->doesObjectExist($this->bucket, $object)); + $result = $this->stsOssClient->deleteObjects($this->bucket, $list, array('quiet' => true)); + $this->assertEquals(array(), $result); + $this->assertFalse($this->stsOssClient->doesObjectExist($this->bucket, $object)); + } catch (OssException $e) { + + $this->assertFalse(true); + } + + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + + /** + * Append the upload string + */ + try { + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[0], 0); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[1], $position); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[2], $position, array(OssClient::OSS_LENGTH => strlen($content_array[2]))); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[2])); + } catch (OssException $e) { + print_r($e->getMessage()); + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append the upload of invalid local files + */ + try { + $position = $this->stsOssClient->appendFile($this->bucket, $object, "invalid-file-path", 0); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + /** + * Append the upload of local files + */ + try { + $position = $this->stsOssClient->appendFile($this->bucket, $object, __FILE__, 0); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->stsOssClient->appendFile($this->bucket, $object, __FILE__, $position); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__)) * 2); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + + $options = array( + OssClient::OSS_HEADERS => array( + 'Expires' => '2012-10-01 08:00:00', + 'Content-Disposition' => 'attachment; filename="xxxxxx"', + ), + ); + + /** + * Append upload with option + */ + try { + $position = $this->stsOssClient->appendObject($this->bucket, $object, "Hello OSS, ", 0, $options); + $position = $this->stsOssClient->appendObject($this->bucket, $object, "Hi OSS.", $position); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Get the meta information for the file + */ + try { + $objectMeta = $this->stsOssClient->getObjectMeta($this->bucket, $object); + $this->assertEquals('attachment; filename="xxxxxx"', $objectMeta[strtolower('Content-Disposition')]); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $options = array(OssClient::OSS_CHECK_MD5 => true); + + $content = file_get_contents(__FILE__); + /** + * Upload data to start MD5 + */ + try { + $this->stsOssClient->putObject($this->bucket, $object, $content, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Upload file to start MD5 + */ + try { + $this->stsOssClient->uploadFile($this->bucket, $object, __FILE__, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $object = "oss-php-sdk-test/append-test-object-name.txt"; + $content_array = array('Hello OSS', 'Hi OSS', 'OSS OK'); + $options = array(OssClient::OSS_CHECK_MD5 => true); + + /** + * Append the upload string + */ + try { + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[0], 0, $options); + $this->assertEquals($position, strlen($content_array[0])); + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[1], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1])); + $position = $this->stsOssClient->appendObject($this->bucket, $object, $content_array[2], $position, $options); + $this->assertEquals($position, strlen($content_array[0]) + strlen($content_array[1]) + strlen($content_array[1])); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the content is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, implode($content_array)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Append upload of local files + */ + try { + $position = $this->stsOssClient->appendFile($this->bucket, $object, __FILE__, 0, $options); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__))); + $position = $this->stsOssClient->appendFile($this->bucket, $object, __FILE__, $position, $options); + $this->assertEquals($position, sprintf('%u', filesize(__FILE__)) * 2); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * Check if the replication is the same + */ + try { + $content = $this->stsOssClient->getObject($this->bucket, $object); + $this->assertEquals($content, file_get_contents(__FILE__) . file_get_contents(__FILE__)); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $options = array( + OssClient::OSS_HEADERS => array( + "Content-Type" => "application/octet-stream", + "name" => "aliyun", + "email" => "aliyun@aliyun.com", + ), + OssClient::OSS_ADDITIONAL_HEADERS => array('name', 'email') + ); + try { + $this->stsOssClient->uploadFile($this->bucket, $object, __FILE__, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $content = $this->stsOssClient->getObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + /** + * delete test object + */ + try { + $this->stsOssClient->deleteObject($this->bucket, $object, $options); + } catch (OssException $e) { + $this->assertFalse(true); + } + + } + + public function testBaseInterfaceForBucektWithSts() + { + $options = array( + OssClient::OSS_HEADERS => array( + "Content-Type" => "application/octet-stream", + "name" => "aliyun", + "email" => "aliyun@aliyun.com", + ), + OssClient::OSS_ADDITIONAL_HEADERS => array('name', 'email') + ); + $this->stsOssClient->createBucket($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE, $options); + + $bucketListInfo = $this->stsOssClient->listBuckets($options); + $this->assertNotNull($bucketListInfo); + + $bucketList = $bucketListInfo->getBucketList(); + $this->assertTrue(is_array($bucketList)); + $this->assertGreaterThan(0, count($bucketList)); + + $this->stsOssClient->putBucketAcl($this->bucket, OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE, $options); + Common::waitMetaSync(); + $this->assertEquals($this->stsOssClient->getBucketAcl($this->bucket), OssClient::OSS_ACL_TYPE_PUBLIC_READ_WRITE); + + $this->assertTrue($this->stsOssClient->doesBucketExist($this->bucket)); + $this->assertFalse($this->stsOssClient->doesBucketExist($this->bucket . '-notexist')); + + $this->assertNotNull($this->stsOssClient->getBucketLocation($this->bucket)); + + $res = $this->stsOssClient->getBucketMeta($this->bucket, $options); + $this->assertEquals('200', $res['info']['http_code']); + $this->assertNotNull($res['x-oss-bucket-region']); + } + + protected function setUp(): void + { + $config = array( + 'signatureVersion' => OssClient::OSS_SIGNATURE_VERSION_V4 + ); + $this->bucket = Common::getBucketName() . '-' . time(); + $this->ossClient = Common::getOssClient($config); + $this->ossClient->createBucket($this->bucket); + Common::waitMetaSync(); + $this->stsOssClient = Common::getStsOssClient($config); + Common::waitMetaSync(); + } + + protected function tearDown(): void + { + if (!$this->ossClient->doesBucketExist($this->bucket)) { + return; + } + + $objects = $this->ossClient->listObjects( + $this->bucket, array('max-keys' => 1000, 'delimiter' => ''))->getObjectList(); + $keys = array(); + foreach ($objects as $obj) { + $keys[] = $obj->getKey(); + } + if (count($keys) > 0) { + $this->ossClient->deleteObjects($this->bucket, $keys); + } + $uploads = $this->ossClient->listMultipartUploads($this->bucket)->getUploads(); + foreach ($uploads as $up) { + $this->ossClient->abortMultipartUpload($this->bucket, $up->getKey(), $up->getUploadId()); + } + + $this->ossClient->deleteBucket($this->bucket); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientTest.php new file mode 100644 index 0000000..58b864d --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssClientTest.php @@ -0,0 +1,521 @@ +credentials = new TestEmptyIdCredentials(); + } else if ($flag == 1) { + $this->credentials = new TestEmptySecretCredentials(); + } else { + $this->credentials = null; + } + } + + /** + * @return Credentials + */ + public function getCredentials() + { + return $this->credentials; + } +} + +class OssClientTest extends TestOssClientBase +{ + public function testConstrunct() + { + try { + $ossClient = new OssClient('id', 'key', 'http://oss-cn-hangzhou.aliyuncs.com'); + $this->assertFalse($ossClient->isUseSSL()); + $ossClient->setUseSSL(true); + $this->assertTrue($ossClient->isUseSSL()); + $this->assertTrue(true); + $this->assertEquals(3, $ossClient->getMaxRetries()); + $ossClient->setMaxTries(4); + $this->assertEquals(4, $ossClient->getMaxRetries()); + $ossClient->setTimeout(10); + $ossClient->setConnectTimeout(20); + } catch (OssException $e) { + assertFalse(true); + } + } + + public function testConstrunct2() + { + try { + $ossClient = new OssClient('id', "", 'http://oss-cn-hangzhou.aliyuncs.com'); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals("access key secret is empty", $e->getMessage()); + } + } + + public function testConstrunct3() + { + try { + $ossClient = new OssClient("", 'key', 'http://oss-cn-hangzhou.aliyuncs.com'); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals("access key id is empty", $e->getMessage()); + } + } + + public function testConstrunct4() + { + try { + $ossClient = new OssClient('id', 'key', ""); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('endpoint is empty', $e->getMessage()); + } + } + + public function testConstrunct5() + { + try { + $ossClient = new OssClient('id', 'key', "123.123.123.1"); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testConstrunct6() + { + try { + $ossClient = new OssClient('id', 'key', "https://123.123.123.1"); + $this->assertTrue($ossClient->isUseSSL()); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $ossClient = new OssClient('id', 'key', "https://123.123.123.1:3128"); + $this->assertTrue($ossClient->isUseSSL()); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testConstrunct7() + { + try { + $ossClient = new OssClient('id', 'key', "http://123.123.123.1"); + $this->assertFalse($ossClient->isUseSSL()); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $ossClient = new OssClient('id', 'key', "http://123.123.123.1:3128"); + $this->assertFalse($ossClient->isUseSSL()); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testConstrunct8() + { + try { + $ossClient = new OssClient('id', 'key', "http://123.123.123.1", true); + $ossClient->listBuckets(); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertFalse(false); + } + } + + public function testConstrunct9() + { + try { + $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint() . '/ '; + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); + $ossClient->listBuckets(); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testConstrunct10() + { + try { + $ossClient = new OssClient('id', 'key', "http://ABC-COM.TEST.123.cn", true); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + public function testConstrunct11() + { + try { + $ossClient = new OssClient('id', 'key', "oss-test.com\\aliyuncs.com"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('endpoint is invalid:' . "oss-test.com\\aliyuncs.com", $e->getMessage()); + } + } + + public function testConstrunct12() + { + try { + $ossClient = new OssClient('id', 'key', "192.168.1.0:abc123"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('endpoint is invalid:' . "192.168.1.0:abc123", $e->getMessage()); + } + } + + public function testSupportPutEmptyObject() + { + try { + $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint() . '/ '; + $bucket = $this->bucket; + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); + $ossClient->putObject($bucket, 'test_emptybody', ''); + } catch (OssException $e) { + $this->assertFalse(true); + } + + //use invalid sts-token, should fail. + try { + $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint() . '/ '; + $bucket = $this->bucket; + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, "invalid-sts-token"); + $ossClient->putObject($bucket, 'test_emptybody', ''); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('InvalidAccessKeyId', $e->getErrorCode()); + } + } + + public function testCreateObjectDir() + { + $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint() . '/ '; + $bucket = $this->bucket; + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); + + try { + $object = 'test-dir'; + $ossClient->createObjectDir($bucket, $object); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertFalse(true); + } + + try { + $object = '0'; + $ossClient->createObjectDir($bucket, $object); + $ossClient->putObject($bucket, $object, ''); + $this->assertTrue(true); + } catch (OssException $e) { + var_dump($e); + $this->assertFalse(true); + } + } + + public function testGetBucketCors() + { + try { + $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint(). '/ '; + $bucket = Common::getBucketName(); + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); + $ossClient->getBucketCors($bucket); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testGetBucketCname() + { + try { + $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint() . '/ '; + $bucket = $this->bucket; + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); + $ossClient->getBucketCname($bucket); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testProxySupport() + { + $accessKeyId = ' ' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint() . '/ '; + $bucket = Common::getBucketName() . '-proxy'; + $requestProxy = getenv('OSS_PROXY'); + $key = 'test-proxy-srv-object'; + $content = 'test-content'; + $proxys = parse_url($requestProxy); + + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, null, $requestProxy); + + $result = $ossClient->createBucket($bucket); + $this->checkProxy($result, $proxys); + + $result = $ossClient->putObject($bucket, $key, $content); + $this->checkProxy($result, $proxys); + $result = $ossClient->getObject($bucket, $key); + $this->assertEquals($content, $result); + + // list object + $objectListInfo = $ossClient->listObjects($bucket); + $objectList = $objectListInfo->getObjectList(); + $this->assertNotNull($objectList); + $this->assertTrue(is_array($objectList)); + $objects = array(); + foreach ($objectList as $value) { + $objects[] = $value->getKey(); + } + $this->assertEquals(1, count($objects)); + $this->assertTrue(in_array($key, $objects)); + + $result = $ossClient->deleteObject($bucket, $key); + $this->checkProxy($result, $proxys); + + $result = $ossClient->deleteBucket($bucket); + $this->checkProxy($result, $proxys); + } + + private function checkProxy($result, $proxys) + { + $this->assertEquals($result['info']['primary_ip'], $proxys['host']); + $this->assertEquals($result['info']['primary_port'], $proxys['port']); + $this->assertTrue(array_key_exists('via', $result)); + } + + public function testIpEndpoint() + { + try { + $accessKeyId = 'sk' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = '192.168.1.1'; + $bucket = Common::getBucketName(); + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false); + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options); + $this->assertTrue(strpos($signedUrl, '192.168.1.1/' . $bucket . '/a.file?') != false); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testCnameEndpoint() + { + try { + $accessKeyId = 'sk' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = 'cname.endpoint'; + $bucket = Common::getBucketName(); + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, true); + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options); + $this->assertTrue(strpos($signedUrl, 'cname.endpoint/a.file?') != false); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testStsToken() + { + try { + $accessKeyId = 'sk' . getenv('OSS_ACCESS_KEY_ID') . ' '; + $accessKeySecret = ' ' . getenv('OSS_ACCESS_KEY_SECRET') . ' '; + $endpoint = ' ' . Common::getEndpoint() . '/ '; + $bucket = Common::getBucketName(); + $ossClient = new OssClient($accessKeyId, $accessKeySecret, $endpoint, false, "test-token"); + $object = "a.file"; + $timeout = 3600; + $options = array('Content-Type' => 'txt'); + $signedUrl = $ossClient->signUrl($bucket, $object, $timeout, "PUT", $options); + $this->assertTrue(strpos($signedUrl, 'security-token=test-token') != false); + } catch (OssException $e) { + $this->assertFalse(true); + } + } + + public function testEmptyCredentials() + { + // empty case, should throw exception + try { + $id = ''; + $secret = 'accessKey_secret'; + $provider = new StaticCredentialsProvider($id, $secret); + $config = array( + 'provider' => $provider, + 'endpoint' => 'http://oss-cn-hangzhou.aliyuncs.com' + ); + $ossClient = new OssClient($config); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('access key id is empty', $e->getMessage()); + } + + // empty case, should throw exception + try { + $id = 'id'; + $secret = ''; + $provider = new StaticCredentialsProvider($id, $secret); + $config = array( + 'provider' => $provider, + 'endpoint' => 'http://oss-cn-hangzhou.aliyuncs.com' + ); + $ossClient = new OssClient($config); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('access key secret is empty', $e->getMessage()); + } + + // empty case, should throw exception + try { + $provider = new TestCredentialsProvider(0); + $config = array( + 'provider' => $provider, + 'endpoint' => 'http://oss-cn-hangzhou.aliyuncs.com' + ); + $ossClient = new OssClient($config); + $ossClient->getBucketAcl("bucket"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('credentials is empty.', $e->getMessage()); + } + + // empty case, should throw exception + try { + $provider = new TestCredentialsProvider(1); + $config = array( + 'provider' => $provider, + 'endpoint' => 'http://oss-cn-hangzhou.aliyuncs.com' + ); + $ossClient = new OssClient($config); + $ossClient->getBucketAcl("bucket"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('access key secret is empty', $e->getMessage()); + } + + // empty case, should throw exception + try { + $provider = new TestCredentialsProvider(2); + $config = array( + 'provider' => $provider, + 'endpoint' => 'http://oss-cn-hangzhou.aliyuncs.com' + ); + $ossClient = new OssClient($config); + $ossClient->getBucketAcl("bucket"); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('access key id is empty', $e->getMessage()); + } + } + + public function testEnvironmentVariableCredentialsProvider() + { + try { + $provider = new EnvironmentVariableCredentialsProvider(); + $config = array( + 'provider' => $provider, + 'endpoint' => Common::getEndpoint(), + ); + $ossClient = new OssClient($config); + $ossClient->putObject($this->bucket, 'test_emptybody', ''); + $this->assertTrue(true); + } catch (OssException $e) { + printf($e->getMessage()); + $this->assertFalse(true); + } + + + try { + $ossClient->getObject($this->bucket, 'test_emptybody'); + $this->assertTrue(true); + } catch (OssException $e) { + printf($e->getMessage()); + $this->assertFalse(true); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssExceptionTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssExceptionTest.php new file mode 100644 index 0000000..91de9bb --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssExceptionTest.php @@ -0,0 +1,19 @@ +assertTrue(false); + } catch (OssException $e) { + $this->assertNotNull($e); + $this->assertEquals($e->getMessage(), "ERR"); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssTrafficLimitTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssTrafficLimitTest.php new file mode 100644 index 0000000..5aeb0ea --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssTrafficLimitTest.php @@ -0,0 +1,96 @@ + array( + OssClient::OSS_TRAFFIC_LIMIT => 819200, + )); + + try { + $result = $this->ossClient->putObject($this->bucket, 'default-object', 'content', $options); + $this->assertTrue(true); + $this->assertTrue(isset($result["x-oss-qos-delay-time"])); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $result = $this->ossClient->appendObject($this->bucket, 'append-object', 'content', 0, $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $result = $this->ossClient->copyObject($this->bucket, 'default-object', $this->bucket, 'copy-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + + try { + $result = $this->ossClient->getObject($this->bucket, 'default-object', $options); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + function testTrafficLimitInQuery() + { + $options = array( + OssClient::OSS_TRAFFIC_LIMIT => 819200, + ); + + $object = "get.file"; + $content = 'hello world'; + $this->ossClient->putObject($this->bucket, $object, $content); + $timeout = 3600; + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "GET", $options); + $this->assertTrue(stripos($signedUrl, 'x-oss-traffic-limit=819200') > 0); + } catch (OssException $e) { + $this->assertFalse(true); + } + + $request = new RequestCore($signedUrl); + $request->set_method('GET'); + $request->add_header('Content-Type', ''); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), $request->get_response_body(), $request->get_response_code()); + $this->assertEquals($content, $res->body); + + + $object = "put.file"; + $timeout = 3600; + try { + $signedUrl = $this->ossClient->signUrl($this->bucket, $object, $timeout, "PUT", $options); + $this->assertTrue(stripos($signedUrl, 'x-oss-traffic-limit=819200') > 0); + + $request = new RequestCore($signedUrl); + $request->set_method('PUT'); + $request->add_header('Content-Type', ''); + $request->add_header('Content-Length', strlen($content)); + $request->set_body($content); + $request->send_request(); + $res = new ResponseCore($request->get_response_header(), + $request->get_response_body(), $request->get_response_code()); + $this->assertTrue($res->isOK()); + } catch (OssException $e) { + $this->assertFalse(true); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssUtilTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssUtilTest.php new file mode 100644 index 0000000..6d6196c --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/OssUtilTest.php @@ -0,0 +1,300 @@ +assertEquals(OssUtil::chkChinese("hello,world"), 0); + $str = '你好,这里是卖咖啡!'; + $strGBK = OssUtil::encodePath($str); + $this->assertEquals(OssUtil::chkChinese($str), 1); + $this->assertEquals(OssUtil::chkChinese($strGBK), 1); + } + + public function testIsGB2312() + { + $str = '你好,这里是卖咖啡!'; + $this->assertFalse(OssUtil::isGb2312($str)); + } + + public function testCheckChar() + { + $str = '你好,这里是卖咖啡!'; + $this->assertFalse(OssUtil::checkChar($str)); + $this->assertTrue(OssUtil::checkChar(iconv("UTF-8", "GB2312//IGNORE", $str))); + } + + public function testIsIpFormat() + { + $this->assertTrue(OssUtil::isIPFormat("10.101.160.147")); + $this->assertTrue(OssUtil::isIPFormat("12.12.12.34")); + $this->assertTrue(OssUtil::isIPFormat("12.12.12.12")); + $this->assertTrue(OssUtil::isIPFormat("255.255.255.255")); + $this->assertTrue(OssUtil::isIPFormat("0.1.1.1")); + $this->assertFalse(OssUtil::isIPFormat("0.1.1.x")); + $this->assertFalse(OssUtil::isIPFormat("0.1.1.256")); + $this->assertFalse(OssUtil::isIPFormat("256.1.1.1")); + $this->assertFalse(OssUtil::isIPFormat("0.1.1.0.1")); + $this->assertTrue(OssUtil::isIPFormat("10.10.10.10:123")); + } + + public function testToQueryString() + { + $option = array("a" => "b"); + $this->assertEquals('a=b', OssUtil::toQueryString($option)); + } + + public function testSReplace() + { + $str = "<>&'\""; + $this->assertEquals("&lt;&gt;&'"", OssUtil::sReplace($str)); + } + + public function testCheckChinese() + { + $str = '你好,这里是卖咖啡!'; + $this->assertEquals(OssUtil::chkChinese($str), 1); + if (OssUtil::isWin()) { + $strGB = OssUtil::encodePath($str); + $this->assertEquals($str, iconv("GB2312", "UTF-8", $strGB)); + } + } + + public function testValidateOption() + { + $option = 'string'; + + try { + OssUtil::validateOptions($option); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertEquals("string:option must be array", $e->getMessage()); + } + + $option = null; + + try { + OssUtil::validateOptions($option); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertFalse(true); + } + + } + + public function testCreateDeleteObjectsXmlBody() + { + $xml = <<trueobj1 +BBBB; + $a = array('obj1'); + $this->assertEquals($xml, $this->cleanXml(OssUtil::createDeleteObjectsXmlBody($a, 'true'))); + } + + public function testCreateCompleteMultipartUploadXmlBody() + { + $xml = <<2xx +BBBB; + $a = array(array("PartNumber" => 2, "ETag" => "xx")); + $this->assertEquals($this->cleanXml(OssUtil::createCompleteMultipartUploadXmlBody($a)), $xml); + } + + public function testCreateBucketXmlBody() + { + $xml = <<Standard +BBBB; + $storageClass ="Standard"; + $this->assertEquals($this->cleanXml(OssUtil::createBucketXmlBody($storageClass)), $xml); + } + + public function testValidateBucket() + { + $this->assertTrue(OssUtil::validateBucket("xxx")); + $this->assertFalse(OssUtil::validateBucket("XXXqwe123")); + $this->assertFalse(OssUtil::validateBucket("XX")); + $this->assertFalse(OssUtil::validateBucket("/X")); + $this->assertFalse(OssUtil::validateBucket("")); + } + + public function testValidateObject() + { + $this->assertTrue(OssUtil::validateObject("xxx")); + $this->assertTrue(OssUtil::validateObject("xxx23")); + $this->assertTrue(OssUtil::validateObject("12321-xxx")); + $this->assertTrue(OssUtil::validateObject("x")); + $this->assertFalse(OssUtil::validateObject("/aa")); + $this->assertFalse(OssUtil::validateObject("\\aa")); + $this->assertFalse(OssUtil::validateObject("")); + } + + public function testStartWith() + { + $this->assertTrue(OssUtil::startsWith("xxab", "xx"), true); + } + + public function testReadDir() + { + $list = OssUtil::readDir(__DIR__, ".|..|.svn|.git", true); + $this->assertNotNull($list); + } + + //public function testIsWin() + //{ + // //$this->assertTrue(OssUtil::isWin()); + //} + + public function testGetMd5SumForFile() + { + $this->assertEquals(OssUtil::getMd5SumForFile(__FILE__, 0, sprintf('%u',filesize(__FILE__)) - 1), base64_encode(md5(file_get_contents(__FILE__), true))); + // false case + $this->assertEquals(OssUtil::getMd5SumForFile(__FILE__, 0, OssClient::OSS_MAX_PART_SIZE + 1), ""); + $this->assertEquals(OssUtil::getMd5SumForFile(__FILE__, 0, sprintf('%u',filesize(__FILE__)) + 1), ""); + + } + + public function testGenerateFile() + { + $path = __DIR__ . DIRECTORY_SEPARATOR . "generatedFile.txt"; + OssUtil::generateFile($path, 1024 * 1024); + $this->assertEquals(sprintf('%u',filesize($path)), 1024 * 1024); + unlink($path); + } + + public function testThrowOssExceptionWithMessageIfEmpty() + { + $null = null; + try { + OssUtil::throwOssExceptionWithMessageIfEmpty($null, "xx"); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('xx', $e->getMessage()); + } + } + + public function testThrowOssExceptionWithMessageIfEmpty2() + { + $null = ""; + try { + OssUtil::throwOssExceptionWithMessageIfEmpty($null, "xx"); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('xx', $e->getMessage()); + } + } + + public function testValidContent() + { + $null = ""; + try { + OssUtil::validateContent($null); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('http body content is invalid', $e->getMessage()); + } + + $notnull = "x"; + try { + OssUtil::validateContent($notnull); + $this->assertTrue(true); + } catch (OssException $e) { + $this->assertEquals('http body content is invalid', $e->getMessage()); + } + } + + public function testThrowOssExceptionWithMessageIfEmpty3() + { + $null = "xx"; + try { + OssUtil::throwOssExceptionWithMessageIfEmpty($null, "xx"); + $this->assertTrue(True); + } catch (OssException $e) { + $this->assertTrue(false); + } + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } + + public function testGetHostPortFromEndpoint() + { + $str = OssUtil::getHostPortFromEndpoint('http://username:password@hostname:80/path?arg=value#anchor'); + $this->assertEquals('hostname:80', $str); + + $str = OssUtil::getHostPortFromEndpoint('hostname:80'); + $this->assertEquals('hostname:80', $str); + + $str = OssUtil::getHostPortFromEndpoint('www.hostname.com'); + $this->assertEquals('www.hostname.com', $str); + + $str = OssUtil::getHostPortFromEndpoint('http://www.hostname.com'); + $this->assertEquals('www.hostname.com', $str); + + $str = OssUtil::getHostPortFromEndpoint('https://www.hostname.com'); + $this->assertEquals('www.hostname.com', $str); + + $str = OssUtil::getHostPortFromEndpoint('192.168.1.10:8080'); + $this->assertEquals('192.168.1.10:8080', $str); + + $str = OssUtil::getHostPortFromEndpoint('file://username:password@hostname:80/path?arg=value#anchor'); + $this->assertEquals('hostname:80', $str); + + $str = OssUtil::getHostPortFromEndpoint('https://WWW.hostname.com-_www.test.com'); + $this->assertEquals('WWW.hostname.com-_www.test.com', $str); + + try { + $str = OssUtil::getHostPortFromEndpoint('http:///path?arg=value#anchor'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + try { + $str = OssUtil::getHostPortFromEndpoint('https://www.hostname.com\www.test.com'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + try { + $str = OssUtil::getHostPortFromEndpoint('www.hostname.com-_*www.test.com'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + try { + $str = OssUtil::getHostPortFromEndpoint('www.hostname.com:ab123'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + + try { + $str = OssUtil::getHostPortFromEndpoint('www.hostname.com:'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } + + public function testDecodeKey() + { + try { + OssUtil::decodeKey("key", "unknown"); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/PutSetDeleteResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/PutSetDeleteResultTest.php new file mode 100644 index 0000000..c87955e --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/PutSetDeleteResultTest.php @@ -0,0 +1,66 @@ +assertFalse(true); + } catch (OssException $e) { + $this->assertEquals('raw response is null', $e->getMessage()); + } + } + + public function testOkResponse() + { + $header= array( + 'x-oss-request-id' => '582AA51E004C4550BD27E0E4', + 'etag' => '595FA1EA77945233921DF12427F9C7CE', + 'content-md5' => 'WV+h6neUUjOSHfEkJ/nHzg==', + 'info' => array( + 'http_code' => '200', + 'method' => 'PUT' + ), + ); + $response = new ResponseCore($header, "this is a mock body, just for test", 200); + $result = new PutSetDeleteResult($response); + $data = $result->getData(); + $this->assertTrue($result->isOK()); + $this->assertEquals("this is a mock body, just for test", $data['body']); + $this->assertEquals('582AA51E004C4550BD27E0E4', $data['x-oss-request-id']); + $this->assertEquals('595FA1EA77945233921DF12427F9C7CE', $data['etag']); + $this->assertEquals('WV+h6neUUjOSHfEkJ/nHzg==', $data['content-md5']); + $this->assertEquals('200', $data['info']['http_code']); + $this->assertEquals('PUT', $data['info']['method']); + } + + public function testFailResponse() + { + $response = new ResponseCore(array(), "", 301); + try { + new PutSetDeleteResult($response); + $this->assertFalse(true); + } catch (OssException $e) { + $this->assertFalse(false); + } + } + + protected function setUp(): void + { + + } + + protected function tearDown(): void + { + + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/RefererConfigTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/RefererConfigTest.php new file mode 100644 index 0000000..5112da8 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/RefererConfigTest.php @@ -0,0 +1,54 @@ + + +true + +http://www.aliyun.com +https://www.aliyun.com +http://www.*.com +https://www.?.aliyuncs.com + + +BBBB; + + private $validXml2 = << + +true + +http://www.aliyun.com + + +BBBB; + + public function testParseValidXml() + { + $refererConfig = new RefererConfig(); + $refererConfig->parseFromXml($this->validXml); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($refererConfig->serializeToXml())); + } + + public function testParseValidXml2() + { + $refererConfig = new RefererConfig(); + $refererConfig->parseFromXml($this->validXml2); + $this->assertEquals(true, $refererConfig->isAllowEmptyReferer()); + $this->assertEquals(1, count($refererConfig->getRefererList())); + $this->assertEquals($this->cleanXml($this->validXml2), $this->cleanXml(strval($refererConfig))); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SignerTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SignerTest.php new file mode 100644 index 0000000..f92bbd2 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SignerTest.php @@ -0,0 +1,558 @@ +set_method("PUT"); + $bucket = "examplebucket"; + $object = "nelson"; + + $request->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request->add_header("Content-Type", "text/html"); + $request->add_header("x-oss-meta-author", "alice"); + $request->add_header("x-oss-meta-magic", "abracadabra"); + $request->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signer = new SignerV1(); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request, $credentials, $signingOpt); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\n/examplebucket/nelson"; + + $this->assertEquals($signToString, $signingOpt['string_to_sign']); + $this->assertEquals('OSS ak:kSHKmLxlyEAKtZPkJhG9bZb5k7M=', $request->request_headers['Authorization']); + + // case 2 + $request2 = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com?acl"); + $request2->set_method("PUT"); + + $request2->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request2->add_header("Content-Type", "text/html"); + $request2->add_header("x-oss-meta-author", "alice"); + $request2->add_header("x-oss-meta-magic", "abracadabra"); + $request2->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request2->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signer = new SignerV1(); + + $signingOpt2 = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request2, $credentials, $signingOpt2); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\n/examplebucket/nelson?acl"; + + $this->assertEquals($signToString, $signingOpt2['string_to_sign']); + $this->assertEquals('OSS ak:/afkugFbmWDQ967j1vr6zygBLQk=', $request2->request_headers['Authorization']); + + // case 3 with non-signed query + $request3 = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com?acl&non-signed-key=value"); + $request3->set_method("PUT"); + + $request3->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request3->add_header("Content-Type", "text/html"); + $request3->add_header("x-oss-meta-author", "alice"); + $request3->add_header("x-oss-meta-magic", "abracadabra"); + $request3->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request3->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signingOpt3 = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request3, $credentials, $signingOpt3); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\n/examplebucket/nelson?acl"; + + $this->assertEquals($signToString, $signingOpt3['string_to_sign']); + $this->assertEquals('OSS ak:/afkugFbmWDQ967j1vr6zygBLQk=', $request3->request_headers['Authorization']); + } + + public function testSignerV1HeaderWithToken() + { + // case 1 + $credentials = new Credentials("ak", "sk", "token"); + $request = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com"); + $request->set_method("PUT"); + $bucket = "examplebucket"; + $object = "nelson"; + + $request->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request->add_header("Content-Type", "text/html"); + $request->add_header("x-oss-meta-author", "alice"); + $request->add_header("x-oss-meta-magic", "abracadabra"); + $request->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signer = new SignerV1(); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request, $credentials, $signingOpt); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\nx-oss-security-token:token\n/examplebucket/nelson"; + + $this->assertEquals($signToString, $signingOpt['string_to_sign']); + $this->assertEquals('OSS ak:H3PAlN3Vucn74tPVEqaQC4AnLwQ=', $request->request_headers['Authorization']); + $this->assertEquals('token', $request->request_headers['x-oss-security-token']); + + // case 2 + $request2 = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com?acl"); + $request2->set_method("PUT"); + + $request2->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request2->add_header("Content-Type", "text/html"); + $request2->add_header("x-oss-meta-author", "alice"); + $request2->add_header("x-oss-meta-magic", "abracadabra"); + $request2->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request2->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signer = new SignerV1(); + + $signingOpt2 = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request2, $credentials, $signingOpt2); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\nx-oss-security-token:token\n/examplebucket/nelson?acl"; + + $this->assertEquals($signToString, $signingOpt2['string_to_sign']); + $this->assertEquals("OSS ak:yeceHMAsgusDPCR979RJcLtd7RI=", $request2->request_headers['Authorization']); + + // case 3 with non-signed query + $request3 = new RequestCore("http://examplebucket.oss-cn-hangzhou.aliyuncs.com?acl&non-signed-key=value"); + $request3->set_method("PUT"); + + $request3->add_header("Content-MD5", "eB5eJF1ptWaXm4bijSPyxw=="); + $request3->add_header("Content-Type", "text/html"); + $request3->add_header("x-oss-meta-author", "alice"); + $request3->add_header("x-oss-meta-magic", "abracadabra"); + $request3->add_header("x-oss-date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $request3->add_header("Date", "Wed, 28 Dec 2022 10:27:41 GMT"); + + $signingOpt3 = array( + 'bucket' => $bucket, + 'key' => $object, + ); + $signer->sign($request3, $credentials, $signingOpt3); + + $signToString = "PUT\neB5eJF1ptWaXm4bijSPyxw==\ntext/html\nWed, 28 Dec 2022 10:27:41 GMT\nx-oss-date:Wed, 28 Dec 2022 10:27:41 GMT\nx-oss-meta-author:alice\nx-oss-meta-magic:abracadabra\nx-oss-security-token:token\n/examplebucket/nelson?acl"; + + $this->assertEquals($signToString, $signingOpt3['string_to_sign']); + $this->assertEquals('OSS ak:yeceHMAsgusDPCR979RJcLtd7RI=', $request2->request_headers['Authorization']); + } + + public function testSignerV1Presign() + { + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/key?versionId=versionId"); + $request->set_method("GET"); + $bucket = "bucket"; + $object = "key"; + + $signer = new SignerV1(); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'expiration' => 1699807420, + ); + $signer->presign($request, $credentials, $signingOpt); + + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + + $this->assertEquals('1699807420', $query['Expires']); + $this->assertEquals('ak', $query['OSSAccessKeyId']); + $this->assertEquals('dcLTea+Yh9ApirQ8o8dOPqtvJXQ=', $query['Signature']); + $this->assertEquals('versionId', $query['versionId']); + $this->assertEquals('/key', $parsed_url['path']); + } + + public function testSignerV1PresignWithToken() + { + $credentials = new Credentials("ak", "sk", "token"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/key%2B123?versionId=versionId"); + $request->set_method("GET"); + $bucket = "bucket"; + $object = "key+123"; + + $signer = new SignerV1(); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'expiration' => 1699808204, + ); + $signer->presign($request, $credentials, $signingOpt); + + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + + $this->assertEquals('1699808204', $query['Expires']); + $this->assertEquals('ak', $query['OSSAccessKeyId']); + $this->assertEquals('jzKYRrM5y6Br0dRFPaTGOsbrDhY=', $query['Signature']); + $this->assertEquals('versionId', $query['versionId']); + $this->assertEquals('token', $query['security-token']); + $this->assertEquals('/key%2B123', $parsed_url['path']); + } + + public function testSignerV4Header() + { + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "text/plain"); + $request->add_header("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702743657)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + ); + $signer->sign($request, $credentials, $signingOpt); + + $authPat = "OSS4-HMAC-SHA256 Credential=ak/20231216/cn-hangzhou/oss/aliyun_v4_request,Signature=e21d18daa82167720f9b1047ae7e7f1ce7cb77a31e8203a7d5f4624fa0284afe"; + $this->assertEquals($authPat, $request->request_headers['Authorization']); + } + + public function testSignerV4HeaderWithToken() + { + // case 1 + $credentials = new Credentials("ak", "sk", "token"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "text/plain"); + $request->add_header("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702784856)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + ); + $signer->sign($request, $credentials, $signingOpt); + + $authPat = "OSS4-HMAC-SHA256 Credential=ak/20231217/cn-hangzhou/oss/aliyun_v4_request,Signature=b94a3f999cf85bcdc00d332fbd3734ba03e48382c36fa4d5af5df817395bd9ea"; + $this->assertEquals($authPat, $request->request_headers['Authorization']); + } + + public function testSignerV4AdditionalHeaders() + { + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "text/plain"); + $request->add_header("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702747512)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'additionalHeaders' => array("ZAbc", "abc") + ); + $signer->sign($request, $credentials, $signingOpt); + + $authPat = "OSS4-HMAC-SHA256 Credential=ak/20231216/cn-hangzhou/oss/aliyun_v4_request,AdditionalHeaders=abc;zabc,Signature=4a4183c187c07c8947db7620deb0a6b38d9fbdd34187b6dbaccb316fa251212f"; + $this->assertEquals($authPat, $request->request_headers['Authorization']); + + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "text/plain"); + $request->add_header("x-oss-content-sha256", "UNSIGNED-PAYLOAD"); + + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702747512)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'additionalHeaders' => array("x-oss-no-exist", "ZAbc", "x-oss-head1", "abc") + ); + $signer->sign($request, $credentials, $signingOpt); + + $authPat = "OSS4-HMAC-SHA256 Credential=ak/20231216/cn-hangzhou/oss/aliyun_v4_request,AdditionalHeaders=abc;zabc,Signature=4a4183c187c07c8947db7620deb0a6b38d9fbdd34187b6dbaccb316fa251212f"; + $this->assertEquals($authPat, $request->request_headers['Authorization']); + } + + public function testSignerV4Presign() + { + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "application/octet-stream"); + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702781677)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'expiration' => 1702782276, + ); + $signer->presign($request, $credentials, $signingOpt); + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + $this->assertEquals('OSS4-HMAC-SHA256', $query['x-oss-signature-version']); + $this->assertEquals('OSS4-HMAC-SHA256', $query['x-oss-signature-version']); + $this->assertEquals('599', $query['x-oss-expires']); + $this->assertEquals('ak/20231217/cn-hangzhou/oss/aliyun_v4_request', $query['x-oss-credential']); + $this->assertEquals('a39966c61718be0d5b14e668088b3fa07601033f6518ac7b523100014269c0fe', $query['x-oss-signature']); + $this->assertFalse(isset($query['x-oss-additional-headers'])); + } + + public function testSignerV4PresignWithToken() + { + // case 1 + $credentials = new Credentials("ak", "sk", "token"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "application/octet-stream"); + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702785388)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'expiration' => 1702785987, + ); + $signer->presign($request, $credentials, $signingOpt); + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + $this->assertEquals('OSS4-HMAC-SHA256', $query['x-oss-signature-version']); + $this->assertEquals('599', $query['x-oss-expires']); + $this->assertEquals('ak/20231217/cn-hangzhou/oss/aliyun_v4_request', $query['x-oss-credential']); + $this->assertEquals('3817ac9d206cd6dfc90f1c09c00be45005602e55898f26f5ddb06d7892e1f8b5', $query['x-oss-signature']); + $this->assertFalse(isset($query['x-oss-additional-headers'])); + //print($request->request_url); + } + + public function testSignerV4PresignWithAdditionalHeaders() + { + // case 1 + $credentials = new Credentials("ak", "sk"); + $request = new RequestCore("http://bucket.oss-cn-hangzhou.aliyuncs.com/1234%2B-/123/1.txt"); + $request->set_method("PUT"); + $bucket = "bucket"; + $object = "1234+-/123/1.txt"; + + $request->add_header("x-oss-head1", "value"); + $request->add_header("abc", "value"); + $request->add_header("ZAbc", "value"); + $request->add_header("XYZ", "value"); + $request->add_header("content-type", "application/octet-stream"); + $request->add_header("Date", gmdate('D, d M Y H:i:s \G\M\T', 1702783809)); + + $signer = new SignerV4(); + + $query = array(); + $query["param1"] = "value1"; + $query["+param1"] = "value3"; + $query["|param1"] = "value4"; + $query["+param2"] = ""; + $query["|param2"] = ""; + $query["param2"] = ""; + + $parsed_url = parse_url($request->request_url); + $parsed_url['query'] = OssUtil::toQueryString($query);; + $request->request_url = OssUtil::unparseUrl($parsed_url); + + $signingOpt = array( + 'bucket' => $bucket, + 'key' => $object, + 'region' => 'cn-hangzhou', + 'product' => 'oss', + 'expiration' => 1702784408, + 'additionalHeaders' => array("ZAbc", "abc") + ); + $signer->presign($request, $credentials, $signingOpt); + $parsed_url = parse_url($request->request_url); + $queryString = isset($parsed_url['query']) ? $parsed_url['query'] : ''; + $query = array(); + parse_str($queryString, $query); + $this->assertEquals('OSS4-HMAC-SHA256', $query['x-oss-signature-version']); + $this->assertEquals('20231217T033009Z', $query['x-oss-date']); + $this->assertEquals('599', $query['x-oss-expires']); + $this->assertEquals('ak/20231217/cn-hangzhou/oss/aliyun_v4_request', $query['x-oss-credential']); + $this->assertEquals('6bd984bfe531afb6db1f7550983a741b103a8c58e5e14f83ea474c2322dfa2b7', $query['x-oss-signature']); + $this->assertEquals('abc;zabc', $query['x-oss-additional-headers']); + } +} + + diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StorageCapacityConfigTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StorageCapacityConfigTest.php new file mode 100644 index 0000000..58aa791 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StorageCapacityConfigTest.php @@ -0,0 +1,58 @@ + + +10 + +BBBB; + +private $validXml_20 = << + +20 + +BBBB; + + public function testConstruct() + { + $config = new StorageCapacityConfig(10); + $this->assertEquals($config->getStorageCapacity(), 10); + $this->assertEquals($this->cleanXml($this->validXml_10), $this->cleanXml($config->serializeToXml())); + } + + public function testSetStorageCapacity() + { + $config = new StorageCapacityConfig(2); + $config->setStorageCapacity(20); + $this->assertEquals($this->cleanXml($this->validXml_20), $this->cleanXml($config->serializeToXml())); + $this->assertEquals($this->cleanXml($this->validXml_20), $this->cleanXml($config->__toString())); + } + + public function testParseFromXml() + { + try { + $config = new StorageCapacityConfig(10); + $config->parseFromXml('invaide xml'); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + if (strpos($e, "Not implemented.") == false) + { + $this->assertTrue(false); + } + } + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StorageCapacityTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StorageCapacityTest.php new file mode 100644 index 0000000..8d2a9df --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StorageCapacityTest.php @@ -0,0 +1,63 @@ + + + 1 + +BBBB; + + private $validXml = << + + 1 + +BBBB; + + public function testParseInValidXml() + { + $response = new ResponseCore(array(), $this->inValidXml, 300); + try { + new GetStorageCapacityResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } + + public function testParseEmptyXml() + { + $response = new ResponseCore(array(), "", 300); + try { + new GetStorageCapacityResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertTrue(true); + } + } + + public function testParseValidXml() + { + $response = new ResponseCore(array(), $this->validXml, 200); + $result = new GetStorageCapacityResult($response); + $this->assertEquals($result->getData(), 1); + } + + public function testSerializeToXml() + { + $xml = "\n1\n"; + + $storageCapacityConfig = new StorageCapacityConfig(1); + $content = $storageCapacityConfig->serializeToXml(); + $this->assertEquals($content, $xml); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsBase.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsBase.php new file mode 100644 index 0000000..5b1f1d2 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsBase.php @@ -0,0 +1,33 @@ +$name = $value; + } + + public function __construct() + { + $this->Timestamp = gmdate('Y-m-d\TH:i:s\Z'); + $this->SignatureNonce = time().rand(10000,99999); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsClient.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsClient.php new file mode 100644 index 0000000..0aae601 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/StsClient.php @@ -0,0 +1,108 @@ +generateSignedURL($params); + + $response = $this->sendRequest($request_url, $format); + + $result= $this->parseResponse($response, $format); + + return $result; + } + + private function sendRequest($url, $format) + { + $curl_handle = curl_init(); + + curl_setopt($curl_handle, CURLOPT_URL, $url); + curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, "GET"); + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false); + curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST,false); + curl_setopt($curl_handle, CURLOPT_HEADER, true); + + $response = curl_exec($curl_handle); + $headerSize = curl_getinfo($curl_handle, CURLINFO_HEADER_SIZE); + $response = substr($response, $headerSize); + + if (curl_getinfo($curl_handle, CURLINFO_HTTP_CODE) != '200') { + $errors = $this->parseResponse($response, $format); + throw new OssException($errors->Code); + } + + curl_close($curl_handle); + + return $response; + } + + private function parseResponse($body, $format) + { + if ("JSON" == $format) { + $respObject = json_decode($body); + } elseif ("XML" == $format) { + $respObject = @simplexml_load_string($body); + } elseif ("RAW" == $format) { + $respObject = $body; + } + return $respObject; + } + + private function generateSignedURL($arr) + { + $request_url = 'https://sts.aliyuncs.com/?'; + + foreach ($arr as $key=>$item) { + if (is_null($item)) unset($arr[$key]); + } + + $Signature = $this->computeSignature($arr, $this->AccessSecret); + ksort($arr); + foreach ($arr as $key => $value) { + $request_url .= $key."=".urlencode($value)."&"; + } + $request_url .="Signature=".urlencode($Signature); + + return $request_url; + } + + private function computeSignature($parameters, $accessKeySecret) + { + ksort($parameters); + $canonicalizedQueryString = ''; + foreach ($parameters as $key => $value) { + $canonicalizedQueryString .= '&' . $this->percentEncode($key). '=' . $this->percentEncode($value); + } + $stringToSign = 'GET&%2F&' . $this->percentencode(substr($canonicalizedQueryString, 1)); + $signature = $this->signString($stringToSign, $accessKeySecret."&"); + + return $signature; + } + + private function signString($source, $accessSecret) + { + return base64_encode(hash_hmac('sha1', $source, $accessSecret, true)); + } + + private function percentEncode($str) + { + $res = urlencode($str); + $res = preg_replace('/\+/', '%20', $res); + $res = preg_replace('/\*/', '%2A', $res); + $res = preg_replace('/%7E/', '~', $res); + return $res; + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SymlinkTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SymlinkTest.php new file mode 100644 index 0000000..c436391 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/SymlinkTest.php @@ -0,0 +1,77 @@ +bucket; + $symlink = 'test-link'; + $special_object = 'exist_object^$#!~'; + $object = 'exist_object'; + + $this->ossClient ->putObject($bucket, $object, 'test_content'); + $this->ossClient->putSymlink($bucket, $symlink, $object); + $result = $this->ossClient->getObject($bucket, $symlink); + $this->assertEquals('test_content', $result); + + $this->ossClient ->putObject($bucket, $special_object, 'test_content'); + $this->ossClient->putSymlink($bucket, $symlink, $special_object); + $result = $this->ossClient->getObject($bucket, $symlink); + $this->assertEquals('test_content', $result); + } + + public function testGetSymlink() + { + $bucket = $this->bucket; + $symlink = 'test-link'; + $object = 'exist_object^$#!~'; + + $this->ossClient ->putObject($bucket, $object, 'test_content'); + $this->ossClient->putSymlink($bucket, $symlink, $object); + + $result = $this->ossClient->getSymlink($bucket, $symlink); + $this->assertEquals($result[OssClient::OSS_SYMLINK_TARGET], $object); + $this->assertEquals('200', $result[OssClient::OSS_INFO][OssClient::OSS_HTTP_CODE]); + $this->assertTrue(isset($result[OssClient::OSS_ETAG])); + $this->assertTrue(isset($result[OssClient::OSS_REQUEST_ID])); + } + + public function testPutNullSymlink() + { + $bucket = $this->bucket; + $symlink = 'null-link'; + $object_not_exist = 'not_exist_object+$#!b不'; + $this->ossClient->putSymlink($bucket, $symlink, $object_not_exist); + + try{ + $this->ossClient->getObject($bucket, $symlink); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('The symlink target object does not exist', $e->getErrorMessage()); + } + } + + public function testGetNullSymlink() + { + $bucket = $this->bucket; + $symlink = 'null-link-new'; + + try{ + $result = $this->ossClient->getSymlink($bucket, $symlink); + $this->assertTrue(false); + }catch (OssException $e){ + $this->assertEquals('The specified key does not exist.', $e->getErrorMessage()); + } + } +} + + diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/TestOssClientBase.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/TestOssClientBase.php new file mode 100644 index 0000000..b204871 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/TestOssClientBase.php @@ -0,0 +1,51 @@ +bucket = Common::getBucketName() .'-'. time(); + $this->ossClient = Common::getOssClient(); + $this->ossClient->createBucket($this->bucket); + Common::waitMetaSync(); + } + + protected function tearDown(): void + { + if (!$this->ossClient->doesBucketExist($this->bucket)) { + return; + } + + $objects = $this->ossClient->listObjects( + $this->bucket, array('max-keys' => 1000, 'delimiter' => ''))->getObjectList(); + $keys = array(); + foreach ($objects as $obj) { + $keys[] = $obj->getKey(); + } + if (count($keys) > 0) { + $this->ossClient->deleteObjects($this->bucket, $keys); + } + $uploads = $this->ossClient->listMultipartUploads($this->bucket)->getUploads(); + foreach ($uploads as $up) { + $this->ossClient->abortMultipartUpload($this->bucket, $up->getKey(), $up->getUploadId()); + } + + $this->ossClient->deleteBucket($this->bucket); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/TransferAccelerationConfigTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/TransferAccelerationConfigTest.php new file mode 100644 index 0000000..19f9805 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/TransferAccelerationConfigTest.php @@ -0,0 +1,56 @@ + + +true + +BBBB; + private $validXml1 = << + +false + +BBBB; + + private $invalidXml1 = << + + +BBBB; + + public function testParseValidXml() + { + $transferConfig = new TransferAccelerationConfig(); + $transferConfig->parseFromXml($this->validXml); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml(strval($transferConfig))); + $this->assertEquals(true,$transferConfig->getEnabled()); + } + + public function testValidXml1() + { + $transferConfig = new TransferAccelerationConfig(); + $transferConfig->parseFromXml($this->validXml1); + $this->assertEquals($this->cleanXml($this->validXml1), $this->cleanXml(strval($transferConfig))); + $this->assertEquals(false,$transferConfig->getEnabled()); + } + + public function testInvalidXml1() + { + $transferConfig = new TransferAccelerationConfig(); + $transferConfig->parseFromXml($this->invalidXml1); + $this->assertEquals(false,$transferConfig->getEnabled()); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/UploadPartResultTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/UploadPartResultTest.php new file mode 100644 index 0000000..df4ad94 --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/UploadPartResultTest.php @@ -0,0 +1,33 @@ + '7265F4D211B56873A381D321F586E4A9'); + private $invalidHeader = array(); + + public function testParseValidHeader() + { + $response = new ResponseCore($this->validHeader, "", 200); + $result = new UploadPartResult($response); + $eTag = $result->getData(); + $this->assertEquals('7265F4D211B56873A381D321F586E4A9', $eTag); + } + + public function testParseInvalidHeader() + { + $response = new ResponseCore($this->invalidHeader, "", 200); + try { + new UploadPartResult($response); + $this->assertTrue(false); + } catch (OssException $e) { + $this->assertEquals('cannot get ETag', $e->getMessage()); + } + } +} diff --git a/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/WebsiteConfigTest.php b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/WebsiteConfigTest.php new file mode 100644 index 0000000..d04b42c --- /dev/null +++ b/vendor/aliyuncs/oss-sdk-php/tests/OSS/Tests/WebsiteConfigTest.php @@ -0,0 +1,56 @@ + + + +index.html + + +errorDocument.html + + +BBBB; + + private $nullXml = << +BBBB; + private $nullXml2 = << +BBBB; + + public function testParseValidXml() + { + $websiteConfig = new WebsiteConfig("index"); + $websiteConfig->parseFromXml($this->validXml); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($websiteConfig->serializeToXml())); + } + + public function testParsenullXml() + { + $websiteConfig = new WebsiteConfig(); + $websiteConfig->parseFromXml($this->nullXml); + $this->assertTrue($this->cleanXml($this->nullXml) === $this->cleanXml($websiteConfig->serializeToXml()) || + $this->cleanXml($this->nullXml2) === $this->cleanXml($websiteConfig->serializeToXml())); + } + + public function testWebsiteConstruct() + { + $websiteConfig = new WebsiteConfig("index.html", "errorDocument.html"); + $this->assertEquals('index.html', $websiteConfig->getIndexDocument()); + $this->assertEquals('errorDocument.html', $websiteConfig->getErrorDocument()); + $this->assertEquals($this->cleanXml($this->validXml), $this->cleanXml($websiteConfig->serializeToXml())); + } + + private function cleanXml($xml) + { + return str_replace("\n", "", str_replace("\r", "", $xml)); + } +} diff --git a/vendor/autoload.php b/vendor/autoload.php new file mode 100644 index 0000000..6f3cc6f --- /dev/null +++ b/vendor/autoload.php @@ -0,0 +1,22 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Autoload; + +/** + * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. + * + * $loader = new \Composer\Autoload\ClassLoader(); + * + * // register classes with namespaces + * $loader->add('Symfony\Component', __DIR__.'/component'); + * $loader->add('Symfony', __DIR__.'/framework'); + * + * // activate the autoloader + * $loader->register(); + * + * // to enable searching the include path (eg. for PEAR packages) + * $loader->setUseIncludePath(true); + * + * In this example, if you try to use a class in the Symfony\Component + * namespace or one of its children (Symfony\Component\Console for instance), + * the autoloader will first look for the class under the component/ + * directory, and it will then fallback to the framework/ directory if not + * found before giving up. + * + * This class is loosely based on the Symfony UniversalClassLoader. + * + * @author Fabien Potencier + * @author Jordi Boggiano + * @see https://www.php-fig.org/psr/psr-0/ + * @see https://www.php-fig.org/psr/psr-4/ + */ +class ClassLoader +{ + /** @var \Closure(string):void */ + private static $includeFile; + + /** @var string|null */ + private $vendorDir; + + // PSR-4 + /** + * @var array> + */ + private $prefixLengthsPsr4 = array(); + /** + * @var array> + */ + private $prefixDirsPsr4 = array(); + /** + * @var list + */ + private $fallbackDirsPsr4 = array(); + + // PSR-0 + /** + * List of PSR-0 prefixes + * + * Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2'))) + * + * @var array>> + */ + private $prefixesPsr0 = array(); + /** + * @var list + */ + private $fallbackDirsPsr0 = array(); + + /** @var bool */ + private $useIncludePath = false; + + /** + * @var array + */ + private $classMap = array(); + + /** @var bool */ + private $classMapAuthoritative = false; + + /** + * @var array + */ + private $missingClasses = array(); + + /** @var string|null */ + private $apcuPrefix; + + /** + * @var array + */ + private static $registeredLoaders = array(); + + /** + * @param string|null $vendorDir + */ + public function __construct($vendorDir = null) + { + $this->vendorDir = $vendorDir; + self::initializeIncludeClosure(); + } + + /** + * @return array> + */ + public function getPrefixes() + { + if (!empty($this->prefixesPsr0)) { + return call_user_func_array('array_merge', array_values($this->prefixesPsr0)); + } + + return array(); + } + + /** + * @return array> + */ + public function getPrefixesPsr4() + { + return $this->prefixDirsPsr4; + } + + /** + * @return list + */ + public function getFallbackDirs() + { + return $this->fallbackDirsPsr0; + } + + /** + * @return list + */ + public function getFallbackDirsPsr4() + { + return $this->fallbackDirsPsr4; + } + + /** + * @return array Array of classname => path + */ + public function getClassMap() + { + return $this->classMap; + } + + /** + * @param array $classMap Class to filename map + * + * @return void + */ + public function addClassMap(array $classMap) + { + if ($this->classMap) { + $this->classMap = array_merge($this->classMap, $classMap); + } else { + $this->classMap = $classMap; + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, either + * appending or prepending to the ones previously set for this prefix. + * + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories + * + * @return void + */ + public function add($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + if ($prepend) { + $this->fallbackDirsPsr0 = array_merge( + $paths, + $this->fallbackDirsPsr0 + ); + } else { + $this->fallbackDirsPsr0 = array_merge( + $this->fallbackDirsPsr0, + $paths + ); + } + + return; + } + + $first = $prefix[0]; + if (!isset($this->prefixesPsr0[$first][$prefix])) { + $this->prefixesPsr0[$first][$prefix] = $paths; + + return; + } + if ($prepend) { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $paths, + $this->prefixesPsr0[$first][$prefix] + ); + } else { + $this->prefixesPsr0[$first][$prefix] = array_merge( + $this->prefixesPsr0[$first][$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, either + * appending or prepending to the ones previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function addPsr4($prefix, $paths, $prepend = false) + { + $paths = (array) $paths; + if (!$prefix) { + // Register directories for the root namespace. + if ($prepend) { + $this->fallbackDirsPsr4 = array_merge( + $paths, + $this->fallbackDirsPsr4 + ); + } else { + $this->fallbackDirsPsr4 = array_merge( + $this->fallbackDirsPsr4, + $paths + ); + } + } elseif (!isset($this->prefixDirsPsr4[$prefix])) { + // Register directories for a new namespace. + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = $paths; + } elseif ($prepend) { + // Prepend directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $paths, + $this->prefixDirsPsr4[$prefix] + ); + } else { + // Append directories for an already registered namespace. + $this->prefixDirsPsr4[$prefix] = array_merge( + $this->prefixDirsPsr4[$prefix], + $paths + ); + } + } + + /** + * Registers a set of PSR-0 directories for a given prefix, + * replacing any others previously set for this prefix. + * + * @param string $prefix The prefix + * @param list|string $paths The PSR-0 base directories + * + * @return void + */ + public function set($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr0 = (array) $paths; + } else { + $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; + } + } + + /** + * Registers a set of PSR-4 directories for a given namespace, + * replacing any others previously set for this namespace. + * + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param list|string $paths The PSR-4 base directories + * + * @throws \InvalidArgumentException + * + * @return void + */ + public function setPsr4($prefix, $paths) + { + if (!$prefix) { + $this->fallbackDirsPsr4 = (array) $paths; + } else { + $length = strlen($prefix); + if ('\\' !== $prefix[$length - 1]) { + throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); + } + $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; + $this->prefixDirsPsr4[$prefix] = (array) $paths; + } + } + + /** + * Turns on searching the include path for class files. + * + * @param bool $useIncludePath + * + * @return void + */ + public function setUseIncludePath($useIncludePath) + { + $this->useIncludePath = $useIncludePath; + } + + /** + * Can be used to check if the autoloader uses the include path to check + * for classes. + * + * @return bool + */ + public function getUseIncludePath() + { + return $this->useIncludePath; + } + + /** + * Turns off searching the prefix and fallback directories for classes + * that have not been registered with the class map. + * + * @param bool $classMapAuthoritative + * + * @return void + */ + public function setClassMapAuthoritative($classMapAuthoritative) + { + $this->classMapAuthoritative = $classMapAuthoritative; + } + + /** + * Should class lookup fail if not found in the current class map? + * + * @return bool + */ + public function isClassMapAuthoritative() + { + return $this->classMapAuthoritative; + } + + /** + * APCu prefix to use to cache found/not-found classes, if the extension is enabled. + * + * @param string|null $apcuPrefix + * + * @return void + */ + public function setApcuPrefix($apcuPrefix) + { + $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; + } + + /** + * The APCu prefix in use, or null if APCu caching is not enabled. + * + * @return string|null + */ + public function getApcuPrefix() + { + return $this->apcuPrefix; + } + + /** + * Registers this instance as an autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not + * + * @return void + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + + if (null === $this->vendorDir) { + return; + } + + if ($prepend) { + self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; + } else { + unset(self::$registeredLoaders[$this->vendorDir]); + self::$registeredLoaders[$this->vendorDir] = $this; + } + } + + /** + * Unregisters this instance as an autoloader. + * + * @return void + */ + public function unregister() + { + spl_autoload_unregister(array($this, 'loadClass')); + + if (null !== $this->vendorDir) { + unset(self::$registeredLoaders[$this->vendorDir]); + } + } + + /** + * Loads the given class or interface. + * + * @param string $class The name of the class + * @return true|null True if loaded, null otherwise + */ + public function loadClass($class) + { + if ($file = $this->findFile($class)) { + $includeFile = self::$includeFile; + $includeFile($file); + + return true; + } + + return null; + } + + /** + * Finds the path to the file where the class is defined. + * + * @param string $class The name of the class + * + * @return string|false The path if found, false otherwise + */ + public function findFile($class) + { + // class map lookup + if (isset($this->classMap[$class])) { + return $this->classMap[$class]; + } + if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { + return false; + } + if (null !== $this->apcuPrefix) { + $file = apcu_fetch($this->apcuPrefix.$class, $hit); + if ($hit) { + return $file; + } + } + + $file = $this->findFileWithExtension($class, '.php'); + + // Search for Hack files if we are running on HHVM + if (false === $file && defined('HHVM_VERSION')) { + $file = $this->findFileWithExtension($class, '.hh'); + } + + if (null !== $this->apcuPrefix) { + apcu_add($this->apcuPrefix.$class, $file); + } + + if (false === $file) { + // Remember that this class does not exist. + $this->missingClasses[$class] = true; + } + + return $file; + } + + /** + * Returns the currently registered loaders keyed by their corresponding vendor directories. + * + * @return array + */ + public static function getRegisteredLoaders() + { + return self::$registeredLoaders; + } + + /** + * @param string $class + * @param string $ext + * @return string|false + */ + private function findFileWithExtension($class, $ext) + { + // PSR-4 lookup + $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; + + $first = $class[0]; + if (isset($this->prefixLengthsPsr4[$first])) { + $subPath = $class; + while (false !== $lastPos = strrpos($subPath, '\\')) { + $subPath = substr($subPath, 0, $lastPos); + $search = $subPath . '\\'; + if (isset($this->prefixDirsPsr4[$search])) { + $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); + foreach ($this->prefixDirsPsr4[$search] as $dir) { + if (file_exists($file = $dir . $pathEnd)) { + return $file; + } + } + } + } + } + + // PSR-4 fallback dirs + foreach ($this->fallbackDirsPsr4 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { + return $file; + } + } + + // PSR-0 lookup + if (false !== $pos = strrpos($class, '\\')) { + // namespaced class name + $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) + . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); + } else { + // PEAR-like class name + $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; + } + + if (isset($this->prefixesPsr0[$first])) { + foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { + if (0 === strpos($class, $prefix)) { + foreach ($dirs as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + } + } + } + + // PSR-0 fallback dirs + foreach ($this->fallbackDirsPsr0 as $dir) { + if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { + return $file; + } + } + + // PSR-0 include paths. + if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { + return $file; + } + + return false; + } + + /** + * @return void + */ + private static function initializeIncludeClosure() + { + if (self::$includeFile !== null) { + return; + } + + /** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + * + * @param string $file + * @return void + */ + self::$includeFile = \Closure::bind(static function($file) { + include $file; + }, null, null); + } +} diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php new file mode 100644 index 0000000..2052022 --- /dev/null +++ b/vendor/composer/InstalledVersions.php @@ -0,0 +1,396 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer; + +use Composer\Autoload\ClassLoader; +use Composer\Semver\VersionParser; + +/** + * This class is copied in every Composer installed project and available to all + * + * See also https://getcomposer.org/doc/07-runtime.md#installed-versions + * + * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final + */ +class InstalledVersions +{ + /** + * @var string|null if set (by reflection by Composer), this should be set to the path where this class is being copied to + * @internal + */ + private static $selfDir = null; + + /** + * @var mixed[]|null + * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null + */ + private static $installed; + + /** + * @var bool + */ + private static $installedIsLocalDir; + + /** + * @var bool|null + */ + private static $canGetVendors; + + /** + * @var array[] + * @psalm-var array}> + */ + private static $installedByVendor = array(); + + /** + * Returns a list of all package names which are present, either by being installed, replaced or provided + * + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackages() + { + $packages = array(); + foreach (self::getInstalled() as $installed) { + $packages[] = array_keys($installed['versions']); + } + + if (1 === \count($packages)) { + return $packages[0]; + } + + return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); + } + + /** + * Returns a list of all package names with a specific type e.g. 'library' + * + * @param string $type + * @return string[] + * @psalm-return list + */ + public static function getInstalledPackagesByType($type) + { + $packagesByType = array(); + + foreach (self::getInstalled() as $installed) { + foreach ($installed['versions'] as $name => $package) { + if (isset($package['type']) && $package['type'] === $type) { + $packagesByType[] = $name; + } + } + } + + return $packagesByType; + } + + /** + * Checks whether the given package is installed + * + * This also returns true if the package name is provided or replaced by another package + * + * @param string $packageName + * @param bool $includeDevRequirements + * @return bool + */ + public static function isInstalled($packageName, $includeDevRequirements = true) + { + foreach (self::getInstalled() as $installed) { + if (isset($installed['versions'][$packageName])) { + return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false; + } + } + + return false; + } + + /** + * Checks whether the given package satisfies a version constraint + * + * e.g. If you want to know whether version 2.3+ of package foo/bar is installed, you would call: + * + * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') + * + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @return bool + */ + public static function satisfies(VersionParser $parser, $packageName, $constraint) + { + $constraint = $parser->parseConstraints((string) $constraint); + $provided = $parser->parseConstraints(self::getVersionRanges($packageName)); + + return $provided->matches($constraint); + } + + /** + * Returns a version constraint representing all the range(s) which are installed for a given package + * + * It is easier to use this via isInstalled() with the $constraint argument if you need to check + * whether a given version of a package is installed, and not just whether it exists + * + * @param string $packageName + * @return string Version constraint usable with composer/semver + */ + public static function getVersionRanges($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + $ranges = array(); + if (isset($installed['versions'][$packageName]['pretty_version'])) { + $ranges[] = $installed['versions'][$packageName]['pretty_version']; + } + if (array_key_exists('aliases', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['aliases']); + } + if (array_key_exists('replaced', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['replaced']); + } + if (array_key_exists('provided', $installed['versions'][$packageName])) { + $ranges = array_merge($ranges, $installed['versions'][$packageName]['provided']); + } + + return implode(' || ', $ranges); + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['version'])) { + return null; + } + + return $installed['versions'][$packageName]['version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as version, use satisfies or getVersionRanges if you need to know if a given version is present + */ + public static function getPrettyVersion($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['pretty_version'])) { + return null; + } + + return $installed['versions'][$packageName]['pretty_version']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as reference + */ + public static function getReference($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + if (!isset($installed['versions'][$packageName]['reference'])) { + return null; + } + + return $installed['versions'][$packageName]['reference']; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @param string $packageName + * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. + */ + public static function getInstallPath($packageName) + { + foreach (self::getInstalled() as $installed) { + if (!isset($installed['versions'][$packageName])) { + continue; + } + + return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; + } + + throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); + } + + /** + * @return array + * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} + */ + public static function getRootPackage() + { + $installed = self::getInstalled(); + + return $installed[0]['root']; + } + + /** + * Returns the raw installed.php data for custom implementations + * + * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. + * @return array[] + * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} + */ + public static function getRawData() + { + @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + self::$installed = include __DIR__ . '/installed.php'; + } else { + self::$installed = array(); + } + } + + return self::$installed; + } + + /** + * Returns the raw data of all installed.php which are currently loaded for custom implementations + * + * @return array[] + * @psalm-return list}> + */ + public static function getAllRawData() + { + return self::getInstalled(); + } + + /** + * Lets you reload the static array from another file + * + * This is only useful for complex integrations in which a project needs to use + * this class but then also needs to execute another project's autoloader in process, + * and wants to ensure both projects have access to their version of installed.php. + * + * A typical case would be PHPUnit, where it would need to make sure it reads all + * the data it needs from this class, then call reload() with + * `require $CWD/vendor/composer/installed.php` (or similar) as input to make sure + * the project in which it runs can then also use this class safely, without + * interference between PHPUnit's dependencies and the project's dependencies. + * + * @param array[] $data A vendor/composer/installed.php data set + * @return void + * + * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data + */ + public static function reload($data) + { + self::$installed = $data; + self::$installedByVendor = array(); + + // when using reload, we disable the duplicate protection to ensure that self::$installed data is + // always returned, but we cannot know whether it comes from the installed.php in __DIR__ or not, + // so we have to assume it does not, and that may result in duplicate data being returned when listing + // all installed packages for example + self::$installedIsLocalDir = false; + } + + /** + * @return string + */ + private static function getSelfDir() + { + if (self::$selfDir === null) { + self::$selfDir = strtr(__DIR__, '\\', '/'); + } + + return self::$selfDir; + } + + /** + * @return array[] + * @psalm-return list}> + */ + private static function getInstalled() + { + if (null === self::$canGetVendors) { + self::$canGetVendors = method_exists('Composer\Autoload\ClassLoader', 'getRegisteredLoaders'); + } + + $installed = array(); + $copiedLocalDir = false; + + if (self::$canGetVendors) { + $selfDir = self::getSelfDir(); + foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { + $vendorDir = strtr($vendorDir, '\\', '/'); + if (isset(self::$installedByVendor[$vendorDir])) { + $installed[] = self::$installedByVendor[$vendorDir]; + } elseif (is_file($vendorDir.'/composer/installed.php')) { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require $vendorDir.'/composer/installed.php'; + self::$installedByVendor[$vendorDir] = $required; + $installed[] = $required; + if (self::$installed === null && $vendorDir.'/composer' === $selfDir) { + self::$installed = $required; + self::$installedIsLocalDir = true; + } + } + if (self::$installedIsLocalDir && $vendorDir.'/composer' === $selfDir) { + $copiedLocalDir = true; + } + } + } + + if (null === self::$installed) { + // only require the installed.php file if this file is loaded from its dumped location, + // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 + if (substr(__DIR__, -8, 1) !== 'C') { + /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $required */ + $required = require __DIR__ . '/installed.php'; + self::$installed = $required; + } else { + self::$installed = array(); + } + } + + if (self::$installed !== array() && !$copiedLocalDir) { + $installed[] = self::$installed; + } + + return $installed; + } +} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE new file mode 100644 index 0000000..f27399a --- /dev/null +++ b/vendor/composer/LICENSE @@ -0,0 +1,21 @@ + +Copyright (c) Nils Adermann, Jordi Boggiano + +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. + diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php new file mode 100644 index 0000000..016c54b --- /dev/null +++ b/vendor/composer/autoload_classmap.php @@ -0,0 +1,16 @@ + $vendorDir . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', + 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', + 'JsonException' => $vendorDir . '/symfony/polyfill-php73/Resources/stubs/JsonException.php', + 'PhpToken' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', + 'Stringable' => $vendorDir . '/myclabs/php-enum/stubs/Stringable.php', + 'UnhandledMatchError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', + 'ValueError' => $vendorDir . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', +); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php new file mode 100644 index 0000000..2617134 --- /dev/null +++ b/vendor/composer/autoload_files.php @@ -0,0 +1,23 @@ + $vendorDir . '/symfony/deprecation-contracts/function.php', + '7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php', + '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', + 'd767e4fc2dc52fe66584ab8c6684783e' => $vendorDir . '/adbario/php-dot-notation/src/helpers.php', + 'a4a119a56e50fbb293281d9a48007e0e' => $vendorDir . '/symfony/polyfill-php80/bootstrap.php', + '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php', + '0d59ee240a4cd96ddbb4ff164fccea4d' => $vendorDir . '/symfony/polyfill-php73/bootstrap.php', + '2cffec82183ee1cea088009cef9a6fc3' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php', + '9b552a3cc426e3287cc811caefa3cf53' => $vendorDir . '/topthink/think-helper/src/helper.php', + 'f7e3d8cd19cf23ce3883a6a51d791b77' => $vendorDir . '/fastadminnet/fastadmin-addons/src/common.php', + 'f0e7e63bbb278a92db02393536748c5f' => $vendorDir . '/overtrue/wechat/src/Kernel/Support/Helpers.php', + '6747f579ad6817f318cc3a7e7a0abb93' => $vendorDir . '/overtrue/wechat/src/Kernel/Helpers.php', + '1cfd2761b63b0a29ed23657ea394cb2d' => $vendorDir . '/topthink/think-captcha/src/helper.php', + 'cc56288302d9df745d97c934d6a6e5f0' => $vendorDir . '/topthink/think-queue/src/common.php', +); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php new file mode 100644 index 0000000..be11dd8 --- /dev/null +++ b/vendor/composer/autoload_namespaces.php @@ -0,0 +1,11 @@ + array($vendorDir . '/pimple/pimple/src'), + 'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'), +); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php new file mode 100644 index 0000000..8872fc3 --- /dev/null +++ b/vendor/composer/autoload_psr4.php @@ -0,0 +1,61 @@ + array($vendorDir . '/topthink/think-helper/src'), + 'think\\composer\\' => array($vendorDir . '/topthink/think-installer/src'), + 'think\\captcha\\' => array($vendorDir . '/topthink/think-captcha/src'), + 'think\\' => array($vendorDir . '/topthink/think-queue/src', $vendorDir . '/fastadminnet/fastadmin-addons/src', $baseDir . '/thinkphp/library/think'), + 'addons\\' => array($baseDir . '/addons'), + 'ZipStream\\' => array($vendorDir . '/maennchen/zipstream-php/src'), + 'Tx\\' => array($vendorDir . '/fastadminnet/fastadmin-mailer/src'), + 'Symfony\\Polyfill\\Php80\\' => array($vendorDir . '/symfony/polyfill-php80'), + 'Symfony\\Polyfill\\Php73\\' => array($vendorDir . '/symfony/polyfill-php73'), + 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), + 'Symfony\\Contracts\\Service\\' => array($vendorDir . '/symfony/service-contracts'), + 'Symfony\\Contracts\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher-contracts'), + 'Symfony\\Contracts\\Cache\\' => array($vendorDir . '/symfony/cache-contracts'), + 'Symfony\\Component\\VarExporter\\' => array($vendorDir . '/symfony/var-exporter'), + 'Symfony\\Component\\HttpFoundation\\' => array($vendorDir . '/symfony/http-foundation'), + 'Symfony\\Component\\Finder\\' => array($vendorDir . '/symfony/finder'), + 'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'), + 'Symfony\\Component\\Cache\\' => array($vendorDir . '/symfony/cache'), + 'Symfony\\Bridge\\PsrHttpMessage\\' => array($vendorDir . '/symfony/psr-http-message-bridge'), + 'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'), + 'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'), + 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'), + 'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'), + 'Psr\\EventDispatcher\\' => array($vendorDir . '/psr/event-dispatcher/src'), + 'Psr\\Container\\' => array($vendorDir . '/psr/container/src'), + 'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'), + 'PhpZip\\' => array($vendorDir . '/nelexa/zip/src'), + 'PhpOffice\\PhpSpreadsheet\\' => array($vendorDir . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet'), + 'Overtrue\\Socialite\\' => array($vendorDir . '/overtrue/socialite/src'), + 'Overtrue\\Pinyin\\' => array($vendorDir . '/overtrue/pinyin/src'), + 'OneSm\\' => array($vendorDir . '/lizhichao/one-sm/src'), + 'OSS\\' => array($vendorDir . '/aliyuncs/oss-sdk-php/src/OSS'), + 'MyCLabs\\Enum\\' => array($vendorDir . '/myclabs/php-enum/src'), + 'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'), + 'Matrix\\' => array($vendorDir . '/markbaker/matrix/classes/src'), + 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), + 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'), + 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'), + 'EasyWeChat\\' => array($vendorDir . '/overtrue/wechat/src'), + 'EasyWeChatComposer\\' => array($vendorDir . '/easywechat-composer/easywechat-composer/src'), + 'Darabonba\\OpenApi\\' => array($vendorDir . '/alibabacloud/darabonba-openapi/src'), + 'Darabonba\\GatewaySpi\\' => array($vendorDir . '/alibabacloud/gateway-spi/src'), + 'Composer\\Pcre\\' => array($vendorDir . '/composer/pcre/src'), + 'Complex\\' => array($vendorDir . '/markbaker/complex/classes/src'), + 'AlibabaCloud\\Tea\\XML\\' => array($vendorDir . '/alibabacloud/tea-xml/src'), + 'AlibabaCloud\\Tea\\Utils\\' => array($vendorDir . '/alibabacloud/tea-utils/src'), + 'AlibabaCloud\\Tea\\' => array($vendorDir . '/alibabacloud/tea/src'), + 'AlibabaCloud\\SDK\\Dypnsapi\\V20170525\\' => array($vendorDir . '/alibabacloud/dypnsapi-20170525/src'), + 'AlibabaCloud\\OpenApiUtil\\' => array($vendorDir . '/alibabacloud/openapi-util/src'), + 'AlibabaCloud\\Endpoint\\' => array($vendorDir . '/alibabacloud/endpoint-util/src'), + 'AlibabaCloud\\Credentials\\' => array($vendorDir . '/alibabacloud/credentials/src'), + 'Adbar\\' => array($vendorDir . '/adbario/php-dot-notation/src'), +); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php new file mode 100644 index 0000000..6d7f80e --- /dev/null +++ b/vendor/composer/autoload_real.php @@ -0,0 +1,50 @@ +register(true); + + $filesToLoad = \Composer\Autoload\ComposerStaticInitf3106b6ef3260b6914241eab0bed11c1::$files; + $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + + require $file; + } + }, null, null); + foreach ($filesToLoad as $fileIdentifier => $file) { + $requireFile($fileIdentifier, $file); + } + + return $loader; + } +} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php new file mode 100644 index 0000000..a1bbc67 --- /dev/null +++ b/vendor/composer/autoload_static.php @@ -0,0 +1,371 @@ + __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php', + '7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php', + '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', + 'd767e4fc2dc52fe66584ab8c6684783e' => __DIR__ . '/..' . '/adbario/php-dot-notation/src/helpers.php', + 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', + '0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php', + '0d59ee240a4cd96ddbb4ff164fccea4d' => __DIR__ . '/..' . '/symfony/polyfill-php73/bootstrap.php', + '2cffec82183ee1cea088009cef9a6fc3' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php', + '9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php', + 'f7e3d8cd19cf23ce3883a6a51d791b77' => __DIR__ . '/..' . '/fastadminnet/fastadmin-addons/src/common.php', + 'f0e7e63bbb278a92db02393536748c5f' => __DIR__ . '/..' . '/overtrue/wechat/src/Kernel/Support/Helpers.php', + '6747f579ad6817f318cc3a7e7a0abb93' => __DIR__ . '/..' . '/overtrue/wechat/src/Kernel/Helpers.php', + '1cfd2761b63b0a29ed23657ea394cb2d' => __DIR__ . '/..' . '/topthink/think-captcha/src/helper.php', + 'cc56288302d9df745d97c934d6a6e5f0' => __DIR__ . '/..' . '/topthink/think-queue/src/common.php', + ); + + public static $prefixLengthsPsr4 = array ( + 't' => + array ( + 'think\\helper\\' => 13, + 'think\\composer\\' => 15, + 'think\\captcha\\' => 14, + 'think\\' => 6, + ), + 'a' => + array ( + 'addons\\' => 7, + ), + 'Z' => + array ( + 'ZipStream\\' => 10, + ), + 'T' => + array ( + 'Tx\\' => 3, + ), + 'S' => + array ( + 'Symfony\\Polyfill\\Php80\\' => 23, + 'Symfony\\Polyfill\\Php73\\' => 23, + 'Symfony\\Polyfill\\Mbstring\\' => 26, + 'Symfony\\Contracts\\Service\\' => 26, + 'Symfony\\Contracts\\EventDispatcher\\' => 34, + 'Symfony\\Contracts\\Cache\\' => 24, + 'Symfony\\Component\\VarExporter\\' => 30, + 'Symfony\\Component\\HttpFoundation\\' => 33, + 'Symfony\\Component\\Finder\\' => 25, + 'Symfony\\Component\\EventDispatcher\\' => 34, + 'Symfony\\Component\\Cache\\' => 24, + 'Symfony\\Bridge\\PsrHttpMessage\\' => 30, + ), + 'P' => + array ( + 'Psr\\SimpleCache\\' => 16, + 'Psr\\Log\\' => 8, + 'Psr\\Http\\Message\\' => 17, + 'Psr\\Http\\Client\\' => 16, + 'Psr\\EventDispatcher\\' => 20, + 'Psr\\Container\\' => 14, + 'Psr\\Cache\\' => 10, + 'PhpZip\\' => 7, + 'PhpOffice\\PhpSpreadsheet\\' => 25, + ), + 'O' => + array ( + 'Overtrue\\Socialite\\' => 19, + 'Overtrue\\Pinyin\\' => 16, + 'OneSm\\' => 6, + 'OSS\\' => 4, + ), + 'M' => + array ( + 'MyCLabs\\Enum\\' => 13, + 'Monolog\\' => 8, + 'Matrix\\' => 7, + ), + 'G' => + array ( + 'GuzzleHttp\\Psr7\\' => 16, + 'GuzzleHttp\\Promise\\' => 19, + 'GuzzleHttp\\' => 11, + ), + 'E' => + array ( + 'EasyWeChat\\' => 11, + 'EasyWeChatComposer\\' => 19, + ), + 'D' => + array ( + 'Darabonba\\OpenApi\\' => 18, + 'Darabonba\\GatewaySpi\\' => 21, + ), + 'C' => + array ( + 'Composer\\Pcre\\' => 14, + 'Complex\\' => 8, + ), + 'A' => + array ( + 'AlibabaCloud\\Tea\\XML\\' => 21, + 'AlibabaCloud\\Tea\\Utils\\' => 23, + 'AlibabaCloud\\Tea\\' => 17, + 'AlibabaCloud\\SDK\\Dypnsapi\\V20170525\\' => 36, + 'AlibabaCloud\\OpenApiUtil\\' => 25, + 'AlibabaCloud\\Endpoint\\' => 22, + 'AlibabaCloud\\Credentials\\' => 25, + 'Adbar\\' => 6, + ), + ); + + public static $prefixDirsPsr4 = array ( + 'think\\helper\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/think-helper/src', + ), + 'think\\composer\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/think-installer/src', + ), + 'think\\captcha\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/think-captcha/src', + ), + 'think\\' => + array ( + 0 => __DIR__ . '/..' . '/topthink/think-queue/src', + 1 => __DIR__ . '/..' . '/fastadminnet/fastadmin-addons/src', + 2 => __DIR__ . '/../..' . '/thinkphp/library/think', + ), + 'addons\\' => + array ( + 0 => __DIR__ . '/../..' . '/addons', + ), + 'ZipStream\\' => + array ( + 0 => __DIR__ . '/..' . '/maennchen/zipstream-php/src', + ), + 'Tx\\' => + array ( + 0 => __DIR__ . '/..' . '/fastadminnet/fastadmin-mailer/src', + ), + 'Symfony\\Polyfill\\Php80\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-php80', + ), + 'Symfony\\Polyfill\\Php73\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-php73', + ), + 'Symfony\\Polyfill\\Mbstring\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring', + ), + 'Symfony\\Contracts\\Service\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/service-contracts', + ), + 'Symfony\\Contracts\\EventDispatcher\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/event-dispatcher-contracts', + ), + 'Symfony\\Contracts\\Cache\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/cache-contracts', + ), + 'Symfony\\Component\\VarExporter\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/var-exporter', + ), + 'Symfony\\Component\\HttpFoundation\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/http-foundation', + ), + 'Symfony\\Component\\Finder\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/finder', + ), + 'Symfony\\Component\\EventDispatcher\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/event-dispatcher', + ), + 'Symfony\\Component\\Cache\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/cache', + ), + 'Symfony\\Bridge\\PsrHttpMessage\\' => + array ( + 0 => __DIR__ . '/..' . '/symfony/psr-http-message-bridge', + ), + 'Psr\\SimpleCache\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/simple-cache/src', + ), + 'Psr\\Log\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/log/Psr/Log', + ), + 'Psr\\Http\\Message\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/http-factory/src', + 1 => __DIR__ . '/..' . '/psr/http-message/src', + ), + 'Psr\\Http\\Client\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/http-client/src', + ), + 'Psr\\EventDispatcher\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/event-dispatcher/src', + ), + 'Psr\\Container\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/container/src', + ), + 'Psr\\Cache\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/cache/src', + ), + 'PhpZip\\' => + array ( + 0 => __DIR__ . '/..' . '/nelexa/zip/src', + ), + 'PhpOffice\\PhpSpreadsheet\\' => + array ( + 0 => __DIR__ . '/..' . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet', + ), + 'Overtrue\\Socialite\\' => + array ( + 0 => __DIR__ . '/..' . '/overtrue/socialite/src', + ), + 'Overtrue\\Pinyin\\' => + array ( + 0 => __DIR__ . '/..' . '/overtrue/pinyin/src', + ), + 'OneSm\\' => + array ( + 0 => __DIR__ . '/..' . '/lizhichao/one-sm/src', + ), + 'OSS\\' => + array ( + 0 => __DIR__ . '/..' . '/aliyuncs/oss-sdk-php/src/OSS', + ), + 'MyCLabs\\Enum\\' => + array ( + 0 => __DIR__ . '/..' . '/myclabs/php-enum/src', + ), + 'Monolog\\' => + array ( + 0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog', + ), + 'Matrix\\' => + array ( + 0 => __DIR__ . '/..' . '/markbaker/matrix/classes/src', + ), + 'GuzzleHttp\\Psr7\\' => + array ( + 0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src', + ), + 'GuzzleHttp\\Promise\\' => + array ( + 0 => __DIR__ . '/..' . '/guzzlehttp/promises/src', + ), + 'GuzzleHttp\\' => + array ( + 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src', + ), + 'EasyWeChat\\' => + array ( + 0 => __DIR__ . '/..' . '/overtrue/wechat/src', + ), + 'EasyWeChatComposer\\' => + array ( + 0 => __DIR__ . '/..' . '/easywechat-composer/easywechat-composer/src', + ), + 'Darabonba\\OpenApi\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/darabonba-openapi/src', + ), + 'Darabonba\\GatewaySpi\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/gateway-spi/src', + ), + 'Composer\\Pcre\\' => + array ( + 0 => __DIR__ . '/..' . '/composer/pcre/src', + ), + 'Complex\\' => + array ( + 0 => __DIR__ . '/..' . '/markbaker/complex/classes/src', + ), + 'AlibabaCloud\\Tea\\XML\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/tea-xml/src', + ), + 'AlibabaCloud\\Tea\\Utils\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/tea-utils/src', + ), + 'AlibabaCloud\\Tea\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/tea/src', + ), + 'AlibabaCloud\\SDK\\Dypnsapi\\V20170525\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/dypnsapi-20170525/src', + ), + 'AlibabaCloud\\OpenApiUtil\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/openapi-util/src', + ), + 'AlibabaCloud\\Endpoint\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/endpoint-util/src', + ), + 'AlibabaCloud\\Credentials\\' => + array ( + 0 => __DIR__ . '/..' . '/alibabacloud/credentials/src', + ), + 'Adbar\\' => + array ( + 0 => __DIR__ . '/..' . '/adbario/php-dot-notation/src', + ), + ); + + public static $prefixesPsr0 = array ( + 'P' => + array ( + 'Pimple' => + array ( + 0 => __DIR__ . '/..' . '/pimple/pimple/src', + ), + ), + 'H' => + array ( + 'HTMLPurifier' => + array ( + 0 => __DIR__ . '/..' . '/ezyang/htmlpurifier/library', + ), + ), + ); + + public static $classMap = array ( + 'Attribute' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/Attribute.php', + 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', + 'JsonException' => __DIR__ . '/..' . '/symfony/polyfill-php73/Resources/stubs/JsonException.php', + 'PhpToken' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/PhpToken.php', + 'Stringable' => __DIR__ . '/..' . '/myclabs/php-enum/stubs/Stringable.php', + 'UnhandledMatchError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/UnhandledMatchError.php', + 'ValueError' => __DIR__ . '/..' . '/symfony/polyfill-php80/Resources/stubs/ValueError.php', + ); + + public static function getInitializer(ClassLoader $loader) + { + return \Closure::bind(function () use ($loader) { + $loader->prefixLengthsPsr4 = ComposerStaticInitf3106b6ef3260b6914241eab0bed11c1::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInitf3106b6ef3260b6914241eab0bed11c1::$prefixDirsPsr4; + $loader->prefixesPsr0 = ComposerStaticInitf3106b6ef3260b6914241eab0bed11c1::$prefixesPsr0; + $loader->classMap = ComposerStaticInitf3106b6ef3260b6914241eab0bed11c1::$classMap; + + }, null, ClassLoader::class); + } +} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json new file mode 100644 index 0000000..67b80c2 --- /dev/null +++ b/vendor/composer/installed.json @@ -0,0 +1,3924 @@ +{ + "packages": [ + { + "name": "adbario/php-dot-notation", + "version": "2.5.0", + "version_normalized": "2.5.0.0", + "source": { + "type": "git", + "url": "https://github.com/adbario/php-dot-notation.git", + "reference": "081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/adbario/php-dot-notation/zipball/081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae", + "reference": "081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^5.5 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8|^5.7|^6.6|^7.5|^8.5|^9.5", + "squizlabs/php_codesniffer": "^3.6" + }, + "time": "2022-10-14T20:31:46+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "Adbar\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Riku Särkinen", + "email": "riku@adbar.io" + } + ], + "description": "PHP dot notation access to arrays", + "homepage": "https://github.com/adbario/php-dot-notation", + "keywords": [ + "ArrayAccess", + "dotnotation" + ], + "support": { + "issues": "https://github.com/adbario/php-dot-notation/issues", + "source": "https://github.com/adbario/php-dot-notation/tree/2.5.0" + }, + "install-path": "../adbario/php-dot-notation" + }, + { + "name": "alibabacloud/credentials", + "version": "1.2.3", + "version_normalized": "1.2.3.0", + "source": { + "type": "git", + "url": "https://github.com/aliyun/credentials-php.git", + "reference": "f6d1986e7b7be8da781d0b99f24c92d9860ba0c1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aliyun/credentials-php/zipball/f6d1986e7b7be8da781d0b99f24c92d9860ba0c1", + "reference": "f6d1986e7b7be8da781d0b99f24c92d9860ba0c1", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "adbario/php-dot-notation": "^2.2", + "alibabacloud/tea": "^3.0", + "ext-curl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "ext-simplexml": "*", + "ext-xmlwriter": "*", + "guzzlehttp/guzzle": "^6.3|^7.0", + "php": ">=5.6" + }, + "require-dev": { + "composer/composer": "^1.8", + "drupal/coder": "^8.3", + "ext-dom": "*", + "ext-pcre": "*", + "ext-sockets": "*", + "ext-spl": "*", + "mikey179/vfsstream": "^1.6", + "monolog/monolog": "^1.24", + "phpunit/phpunit": "^5.7|^6.6|^9.3", + "psr/cache": "^1.0", + "symfony/dotenv": "^3.4", + "symfony/var-dumper": "^3.4" + }, + "suggest": { + "ext-sockets": "To use client-side monitoring" + }, + "time": "2025-04-18T09:09:46+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\Credentials\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com", + "homepage": "http://www.alibabacloud.com" + } + ], + "description": "Alibaba Cloud Credentials for PHP", + "homepage": "https://www.alibabacloud.com/", + "keywords": [ + "alibaba", + "alibabacloud", + "aliyun", + "client", + "cloud", + "credentials", + "library", + "sdk", + "tool" + ], + "support": { + "issues": "https://github.com/aliyun/credentials-php/issues", + "source": "https://github.com/aliyun/credentials-php" + }, + "install-path": "../alibabacloud/credentials" + }, + { + "name": "alibabacloud/darabonba-openapi", + "version": "0.2.15", + "version_normalized": "0.2.15.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/darabonba-openapi.git", + "reference": "de1a60831d74b0ddf78c16f6d31be57d95b7d49e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/darabonba-openapi/zipball/de1a60831d74b0ddf78c16f6d31be57d95b7d49e", + "reference": "de1a60831d74b0ddf78c16f6d31be57d95b7d49e", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/credentials": "^1.2.2", + "alibabacloud/gateway-spi": "^1", + "alibabacloud/openapi-util": "^0.1.10|^0.2.1", + "alibabacloud/tea-utils": "^0.2.21", + "alibabacloud/tea-xml": "^0.2", + "php": ">5.5" + }, + "time": "2025-04-15T11:59:13+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Darabonba\\OpenApi\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud OpenApi Client", + "support": { + "issues": "https://github.com/alibabacloud-sdk-php/darabonba-openapi/issues", + "source": "https://github.com/alibabacloud-sdk-php/darabonba-openapi/tree/0.2.15" + }, + "install-path": "../alibabacloud/darabonba-openapi" + }, + { + "name": "alibabacloud/dypnsapi-20170525", + "version": "1.1.3", + "version_normalized": "1.1.3.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/dypnsapi-20170525.git", + "reference": "dec5e2a15a4cacfa98f3c26e477d90bf750c0f0e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/dypnsapi-20170525/zipball/dec5e2a15a4cacfa98f3c26e477d90bf750c0f0e", + "reference": "dec5e2a15a4cacfa98f3c26e477d90bf750c0f0e", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/darabonba-openapi": "^0.2.13", + "alibabacloud/endpoint-util": "^0.1.0", + "alibabacloud/openapi-util": "^0.1.10|^0.2.1", + "alibabacloud/tea-utils": "^0.2.21", + "php": ">5.5" + }, + "time": "2024-10-24T09:40:08+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\SDK\\Dypnsapi\\V20170525\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud Dypnsapi (20170525) SDK Library for PHP", + "support": { + "source": "https://github.com/alibabacloud-sdk-php/dypnsapi-20170525/tree/1.1.3" + }, + "install-path": "../alibabacloud/dypnsapi-20170525" + }, + { + "name": "alibabacloud/endpoint-util", + "version": "0.1.1", + "version_normalized": "0.1.1.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/endpoint-util.git", + "reference": "f3fe88a25d8df4faa3b0ae14ff202a9cc094e6c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/endpoint-util/zipball/f3fe88a25d8df4faa3b0ae14ff202a9cc094e6c5", + "reference": "f3fe88a25d8df4faa3b0ae14ff202a9cc094e6c5", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35|^5.4.3" + }, + "time": "2020-06-04T10:57:15+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\Endpoint\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud Endpoint Library for PHP", + "support": { + "source": "https://github.com/alibabacloud-sdk-php/endpoint-util/tree/0.1.1" + }, + "install-path": "../alibabacloud/endpoint-util" + }, + { + "name": "alibabacloud/gateway-spi", + "version": "1.0.0", + "version_normalized": "1.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/alibabacloud-gateway-spi.git", + "reference": "7440f77750c329d8ab252db1d1d967314ccd1fcb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/alibabacloud-gateway-spi/zipball/7440f77750c329d8ab252db1d1d967314ccd1fcb", + "reference": "7440f77750c329d8ab252db1d1d967314ccd1fcb", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/credentials": "^1.1", + "php": ">5.5" + }, + "time": "2022-07-14T05:31:35+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Darabonba\\GatewaySpi\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud Gateway SPI Client", + "support": { + "source": "https://github.com/alibabacloud-sdk-php/alibabacloud-gateway-spi/tree/1.0.0" + }, + "install-path": "../alibabacloud/gateway-spi" + }, + { + "name": "alibabacloud/openapi-util", + "version": "0.2.1", + "version_normalized": "0.2.1.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/openapi-util.git", + "reference": "f31f7bcd835e08ca24b6b8ba33637eb4eceb093a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/openapi-util/zipball/f31f7bcd835e08ca24b6b8ba33637eb4eceb093a", + "reference": "f31f7bcd835e08ca24b6b8ba33637eb4eceb093a", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/tea": "^3.1", + "alibabacloud/tea-utils": "^0.2", + "lizhichao/one-sm": "^1.5", + "php": ">5.5" + }, + "require-dev": { + "phpunit/phpunit": "*" + }, + "time": "2023-01-10T09:10:10+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\OpenApiUtil\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud OpenApi Util", + "support": { + "issues": "https://github.com/alibabacloud-sdk-php/openapi-util/issues", + "source": "https://github.com/alibabacloud-sdk-php/openapi-util/tree/0.2.1" + }, + "install-path": "../alibabacloud/openapi-util" + }, + { + "name": "alibabacloud/tea", + "version": "3.2.1", + "version_normalized": "3.2.1.0", + "source": { + "type": "git", + "url": "https://github.com/aliyun/tea-php.git", + "reference": "1619cb96c158384f72b873e1f85de8b299c9c367" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aliyun/tea-php/zipball/1619cb96c158384f72b873e1f85de8b299c9c367", + "reference": "1619cb96c158384f72b873e1f85de8b299c9c367", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "adbario/php-dot-notation": "^2.4", + "ext-curl": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-openssl": "*", + "ext-simplexml": "*", + "ext-xmlwriter": "*", + "guzzlehttp/guzzle": "^6.3|^7.0", + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "*", + "symfony/dotenv": "^3.4", + "symfony/var-dumper": "^3.4" + }, + "suggest": { + "ext-sockets": "To use client-side monitoring" + }, + "time": "2023-05-16T06:43:41+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com", + "homepage": "http://www.alibabacloud.com" + } + ], + "description": "Client of Tea for PHP", + "homepage": "https://www.alibabacloud.com/", + "keywords": [ + "alibabacloud", + "client", + "cloud", + "tea" + ], + "support": { + "issues": "https://github.com/aliyun/tea-php/issues", + "source": "https://github.com/aliyun/tea-php" + }, + "install-path": "../alibabacloud/tea" + }, + { + "name": "alibabacloud/tea-utils", + "version": "0.2.21", + "version_normalized": "0.2.21.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/tea-utils.git", + "reference": "5039e45714c6456186d267f5d81a4b260a652495" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/tea-utils/zipball/5039e45714c6456186d267f5d81a4b260a652495", + "reference": "5039e45714c6456186d267f5d81a4b260a652495", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/tea": "^3.1", + "php": ">5.5" + }, + "time": "2024-07-05T06:05:54+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\Utils\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud Tea Utils for PHP", + "support": { + "issues": "https://github.com/aliyun/tea-util/issues", + "source": "https://github.com/aliyun/tea-util" + }, + "install-path": "../alibabacloud/tea-utils" + }, + { + "name": "alibabacloud/tea-xml", + "version": "0.2.4", + "version_normalized": "0.2.4.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/tea-xml.git", + "reference": "3e0c000bf536224eebbac913c371bef174c0a16a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/tea-xml/zipball/3e0c000bf536224eebbac913c371bef174c0a16a", + "reference": "3e0c000bf536224eebbac913c371bef174c0a16a", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">5.5" + }, + "require-dev": { + "phpunit/phpunit": "*", + "symfony/var-dumper": "*" + }, + "time": "2022-08-02T04:12:58+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\XML\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud Tea XML Library for PHP", + "support": { + "source": "https://github.com/alibabacloud-sdk-php/tea-xml/tree/0.2.4" + }, + "install-path": "../alibabacloud/tea-xml" + }, + { + "name": "aliyuncs/oss-sdk-php", + "version": "v2.7.2", + "version_normalized": "2.7.2.0", + "source": { + "type": "git", + "url": "https://github.com/aliyun/aliyun-oss-php-sdk.git", + "reference": "483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/aliyun/aliyun-oss-php-sdk/zipball/483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5", + "reference": "483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "php-coveralls/php-coveralls": "*", + "phpunit/phpunit": "*" + }, + "time": "2024-10-28T10:41:12+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "OSS\\": "src/OSS" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Aliyuncs", + "homepage": "http://www.aliyun.com" + } + ], + "description": "Aliyun OSS SDK for PHP", + "homepage": "http://www.aliyun.com/product/oss/", + "support": { + "issues": "https://github.com/aliyun/aliyun-oss-php-sdk/issues", + "source": "https://github.com/aliyun/aliyun-oss-php-sdk/tree/v2.7.2" + }, + "install-path": "../aliyuncs/oss-sdk-php" + }, + { + "name": "composer/pcre", + "version": "3.3.2", + "version_normalized": "3.3.2.0", + "source": { + "type": "git", + "url": "https://github.com/composer/pcre.git", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "reference": "b2bed4734f0cc156ee1fe9c0da2550420d99a21e", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0" + }, + "conflict": { + "phpstan/phpstan": "<1.11.10" + }, + "require-dev": { + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2", + "phpunit/phpunit": "^8 || ^9" + }, + "time": "2024-11-12T16:29:46+00:00", + "type": "library", + "extra": { + "phpstan": { + "includes": [ + "extension.neon" + ] + }, + "branch-alias": { + "dev-main": "3.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "keywords": [ + "PCRE", + "preg", + "regex", + "regular expression" + ], + "support": { + "issues": "https://github.com/composer/pcre/issues", + "source": "https://github.com/composer/pcre/tree/3.3.2" + }, + "funding": [ + { + "url": "https://packagist.com", + "type": "custom" + }, + { + "url": "https://github.com/composer", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/composer/composer", + "type": "tidelift" + } + ], + "install-path": "./pcre" + }, + { + "name": "easywechat-composer/easywechat-composer", + "version": "1.4.1", + "version_normalized": "1.4.1.0", + "source": { + "type": "git", + "url": "https://github.com/mingyoung/easywechat-composer.git", + "reference": "3fc6a7ab6d3853c0f4e2922539b56cc37ef361cd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mingyoung/easywechat-composer/zipball/3fc6a7ab6d3853c0f4e2922539b56cc37ef361cd", + "reference": "3fc6a7ab6d3853c0f4e2922539b56cc37ef361cd", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0 || ^2.0", + "php": ">=7.0" + }, + "require-dev": { + "composer/composer": "^1.0 || ^2.0", + "phpunit/phpunit": "^6.5 || ^7.0" + }, + "time": "2021-07-05T04:03:22+00:00", + "type": "composer-plugin", + "extra": { + "class": "EasyWeChatComposer\\Plugin" + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "EasyWeChatComposer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "张铭阳", + "email": "mingyoungcheung@gmail.com" + } + ], + "description": "The composer plugin for EasyWeChat", + "support": { + "issues": "https://github.com/mingyoung/easywechat-composer/issues", + "source": "https://github.com/mingyoung/easywechat-composer/tree/1.4.1" + }, + "install-path": "../easywechat-composer/easywechat-composer" + }, + { + "name": "ezyang/htmlpurifier", + "version": "v4.18.0", + "version_normalized": "4.18.0.0", + "source": { + "type": "git", + "url": "https://github.com/ezyang/htmlpurifier.git", + "reference": "cb56001e54359df7ae76dc522d08845dc741621b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/cb56001e54359df7ae76dc522d08845dc741621b", + "reference": "cb56001e54359df7ae76dc522d08845dc741621b", + "shasum": "" + }, + "require": { + "php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" + }, + "require-dev": { + "cerdic/css-tidy": "^1.7 || ^2.0", + "simpletest/simpletest": "dev-master" + }, + "suggest": { + "cerdic/css-tidy": "If you want to use the filter 'Filter.ExtractStyleBlocks'.", + "ext-bcmath": "Used for unit conversion and imagecrash protection", + "ext-iconv": "Converts text to and from non-UTF-8 encodings", + "ext-tidy": "Used for pretty-printing HTML" + }, + "time": "2024-11-01T03:51:45+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "library/HTMLPurifier.composer.php" + ], + "psr-0": { + "HTMLPurifier": "library/" + }, + "exclude-from-classmap": [ + "/library/HTMLPurifier/Language/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-or-later" + ], + "authors": [ + { + "name": "Edward Z. Yang", + "email": "admin@htmlpurifier.org", + "homepage": "http://ezyang.com" + } + ], + "description": "Standards compliant HTML filter written in PHP", + "homepage": "http://htmlpurifier.org/", + "keywords": [ + "html" + ], + "support": { + "issues": "https://github.com/ezyang/htmlpurifier/issues", + "source": "https://github.com/ezyang/htmlpurifier/tree/v4.18.0" + }, + "install-path": "../ezyang/htmlpurifier" + }, + { + "name": "fastadminnet/fastadmin-addons", + "version": "1.4.1", + "version_normalized": "1.4.1.0", + "source": { + "type": "git", + "url": "https://github.com/fastadminnet/fastadmin-addons.git", + "reference": "f98418b69fbdd07569ee97d9fd4a83dfd7fdc770" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fastadminnet/fastadmin-addons/zipball/f98418b69fbdd07569ee97d9fd4a83dfd7fdc770", + "reference": "f98418b69fbdd07569ee97d9fd4a83dfd7fdc770", + "shasum": "" + }, + "require": { + "nelexa/zip": "^3.3 || ^4.0", + "php": ">=7.0.0" + }, + "time": "2025-03-29T13:58:15+00:00", + "type": "library", + "extra": { + "think-config": { + "addons": "src/config.php" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "src/common.php" + ], + "psr-4": { + "think\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Karson", + "email": "karson@fastadmin.net" + }, + { + "name": "xiaobo.sun", + "email": "xiaobo.sun@qq.com" + } + ], + "description": "addons package for fastadmin", + "homepage": "https://github.com/fastadminnet/fastadmin-addons", + "support": { + "issues": "https://github.com/fastadminnet/fastadmin-addons/issues", + "source": "https://github.com/fastadminnet/fastadmin-addons/tree/v1.4.1" + }, + "install-path": "../fastadminnet/fastadmin-addons" + }, + { + "name": "fastadminnet/fastadmin-mailer", + "version": "v2.1.0", + "version_normalized": "2.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/fastadminnet/fastadmin-mailer.git", + "reference": "99b7369406d52c35cf4c9c38b0322b6846ca227a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/fastadminnet/fastadmin-mailer/zipball/99b7369406d52c35cf4c9c38b0322b6846ca227a", + "reference": "99b7369406d52c35cf4c9c38b0322b6846ca227a", + "shasum": "" + }, + "require": { + "php": ">=5.3.2", + "psr/log": "~1.0" + }, + "require-dev": { + "monolog/monolog": "~1.13", + "phpunit/phpunit": "~5.0" + }, + "time": "2025-03-30T03:39:53+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Tx\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cloud", + "email": "cloud@txthinking.com", + "homepage": "http://www.txthinking.com", + "role": "Thinker" + }, + { + "name": "Matt Sowers", + "email": "msowers@erblearn.org" + } + ], + "description": "A very lightweight PHP SMTP mail sender", + "homepage": "https://github.com/fastadminnet/fastadmin-mailer", + "keywords": [ + "mail", + "smtp" + ], + "support": { + "source": "https://github.com/fastadminnet/fastadmin-mailer/tree/v2.1.0" + }, + "install-path": "../fastadminnet/fastadmin-mailer" + }, + { + "name": "guzzlehttp/guzzle", + "version": "7.9.2", + "version_normalized": "7.9.2.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "d281ed313b989f213357e3be1a179f02196ac99b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/d281ed313b989f213357e3be1a179f02196ac99b", + "reference": "d281ed313b989f213357e3be1a179f02196ac99b", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "ext-json": "*", + "guzzlehttp/promises": "^1.5.3 || ^2.0.3", + "guzzlehttp/psr7": "^2.7.0", + "php": "^7.2.5 || ^8.0", + "psr/http-client": "^1.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "provide": { + "psr/http-client-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "ext-curl": "*", + "guzzle/client-integration-tests": "3.0.2", + "php-http/message-factory": "^1.1", + "phpunit/phpunit": "^8.5.39 || ^9.6.20", + "psr/log": "^1.1 || ^2.0 || ^3.0" + }, + "suggest": { + "ext-curl": "Required for CURL handler support", + "ext-intl": "Required for Internationalized Domain Name (IDN) support", + "psr/log": "Required for using the Log middleware" + }, + "time": "2024-07-24T11:22:20+00:00", + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Jeremy Lindblom", + "email": "jeremeamia@gmail.com", + "homepage": "https://github.com/jeremeamia" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "psr-18", + "psr-7", + "rest", + "web service" + ], + "support": { + "issues": "https://github.com/guzzle/guzzle/issues", + "source": "https://github.com/guzzle/guzzle/tree/7.9.2" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle", + "type": "tidelift" + } + ], + "install-path": "../guzzlehttp/guzzle" + }, + { + "name": "guzzlehttp/promises", + "version": "2.2.0", + "version_normalized": "2.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/7c69f28996b0a6920945dd20b3857e499d9ca96c", + "reference": "7c69f28996b0a6920945dd20b3857e499d9ca96c", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "time": "2025-03-27T13:27:01+00:00", + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "support": { + "issues": "https://github.com/guzzle/promises/issues", + "source": "https://github.com/guzzle/promises/tree/2.2.0" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises", + "type": "tidelift" + } + ], + "install-path": "../guzzlehttp/promises" + }, + { + "name": "guzzlehttp/psr7", + "version": "2.7.1", + "version_normalized": "2.7.1.0", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "reference": "c2270caaabe631b3b44c85f99e5a04bbb8060d16", + "shasum": "" + }, + "require": { + "php": "^7.2.5 || ^8.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.1 || ^2.0", + "ralouphie/getallheaders": "^3.0" + }, + "provide": { + "psr/http-factory-implementation": "1.0", + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8.2", + "http-interop/http-factory-tests": "0.9.0", + "phpunit/phpunit": "^8.5.39 || ^9.6.20" + }, + "suggest": { + "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" + }, + "time": "2025-03-27T12:30:47+00:00", + "type": "library", + "extra": { + "bamarni-bin": { + "bin-links": true, + "forward-command": false + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" + }, + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "George Mponos", + "email": "gmponos@gmail.com", + "homepage": "https://github.com/gmponos" + }, + { + "name": "Tobias Nyholm", + "email": "tobias.nyholm@gmail.com", + "homepage": "https://github.com/Nyholm" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://github.com/sagikazarmark" + }, + { + "name": "Tobias Schultze", + "email": "webmaster@tubo-world.de", + "homepage": "https://github.com/Tobion" + }, + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" + } + ], + "description": "PSR-7 message implementation that also provides common utility methods", + "keywords": [ + "http", + "message", + "psr-7", + "request", + "response", + "stream", + "uri", + "url" + ], + "support": { + "issues": "https://github.com/guzzle/psr7/issues", + "source": "https://github.com/guzzle/psr7/tree/2.7.1" + }, + "funding": [ + { + "url": "https://github.com/GrahamCampbell", + "type": "github" + }, + { + "url": "https://github.com/Nyholm", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7", + "type": "tidelift" + } + ], + "install-path": "../guzzlehttp/psr7" + }, + { + "name": "lizhichao/one-sm", + "version": "1.10", + "version_normalized": "1.10.0.0", + "source": { + "type": "git", + "url": "https://github.com/lizhichao/sm.git", + "reference": "687a012a44a5bfd4d9143a0234e1060543be455a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/lizhichao/sm/zipball/687a012a44a5bfd4d9143a0234e1060543be455a", + "reference": "687a012a44a5bfd4d9143a0234e1060543be455a", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "time": "2021-05-26T06:19:22+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "OneSm\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "tanszhe", + "email": "1018595261@qq.com" + } + ], + "description": "国密sm3", + "keywords": [ + "php", + "sm3" + ], + "support": { + "issues": "https://github.com/lizhichao/sm/issues", + "source": "https://github.com/lizhichao/sm/tree/1.10" + }, + "funding": [ + { + "url": "https://www.vicsdf.com/img/w.jpg", + "type": "custom" + }, + { + "url": "https://www.vicsdf.com/img/z.jpg", + "type": "custom" + } + ], + "install-path": "../lizhichao/one-sm" + }, + { + "name": "maennchen/zipstream-php", + "version": "2.2.6", + "version_normalized": "2.2.6.0", + "source": { + "type": "git", + "url": "https://github.com/maennchen/ZipStream-PHP.git", + "reference": "30ad6f93cf3efe4192bc7a4c9cad11ff8f4f237f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/maennchen/ZipStream-PHP/zipball/30ad6f93cf3efe4192bc7a4c9cad11ff8f4f237f", + "reference": "30ad6f93cf3efe4192bc7a4c9cad11ff8f4f237f", + "shasum": "" + }, + "require": { + "myclabs/php-enum": "^1.5", + "php": "^7.4 || ^8.0", + "psr/http-message": "^1.0", + "symfony/polyfill-mbstring": "^1.0" + }, + "require-dev": { + "ext-zip": "*", + "friendsofphp/php-cs-fixer": "^3.9", + "guzzlehttp/guzzle": "^6.5.3 || ^7.2.0", + "mikey179/vfsstream": "^1.6", + "php-coveralls/php-coveralls": "^2.4", + "phpunit/phpunit": "^8.5.8 || ^9.4.2", + "vimeo/psalm": "^4.1" + }, + "time": "2022-11-25T18:57:19+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "ZipStream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paul Duncan", + "email": "pabs@pablotron.org" + }, + { + "name": "Jonatan Männchen", + "email": "jonatan@maennchen.ch" + }, + { + "name": "Jesse Donat", + "email": "donatj@gmail.com" + }, + { + "name": "András Kolesár", + "email": "kolesar@kolesar.hu" + } + ], + "description": "ZipStream is a library for dynamically streaming dynamic zip files from PHP without writing to the disk at all on the server.", + "keywords": [ + "stream", + "zip" + ], + "support": { + "issues": "https://github.com/maennchen/ZipStream-PHP/issues", + "source": "https://github.com/maennchen/ZipStream-PHP/tree/2.2.6" + }, + "funding": [ + { + "url": "https://github.com/maennchen", + "type": "github" + }, + { + "url": "https://opencollective.com/zipstream", + "type": "open_collective" + } + ], + "install-path": "../maennchen/zipstream-php" + }, + { + "name": "markbaker/complex", + "version": "3.0.2", + "version_normalized": "3.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPComplex.git", + "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPComplex/zipball/95c56caa1cf5c766ad6d65b6344b807c1e8405b9", + "reference": "95c56caa1cf5c766ad6d65b6344b807c1e8405b9", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "phpcompatibility/php-compatibility": "^9.3", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "squizlabs/php_codesniffer": "^3.7" + }, + "time": "2022-12-06T16:21:08+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Complex\\": "classes/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@lange.demon.co.uk" + } + ], + "description": "PHP Class for working with complex numbers", + "homepage": "https://github.com/MarkBaker/PHPComplex", + "keywords": [ + "complex", + "mathematics" + ], + "support": { + "issues": "https://github.com/MarkBaker/PHPComplex/issues", + "source": "https://github.com/MarkBaker/PHPComplex/tree/3.0.2" + }, + "install-path": "../markbaker/complex" + }, + { + "name": "markbaker/matrix", + "version": "3.0.1", + "version_normalized": "3.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/MarkBaker/PHPMatrix.git", + "reference": "728434227fe21be27ff6d86621a1b13107a2562c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/MarkBaker/PHPMatrix/zipball/728434227fe21be27ff6d86621a1b13107a2562c", + "reference": "728434227fe21be27ff6d86621a1b13107a2562c", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-master", + "phpcompatibility/php-compatibility": "^9.3", + "phpdocumentor/phpdocumentor": "2.*", + "phploc/phploc": "^4.0", + "phpmd/phpmd": "2.*", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "sebastian/phpcpd": "^4.0", + "squizlabs/php_codesniffer": "^3.7" + }, + "time": "2022-12-02T22:17:43+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Matrix\\": "classes/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mark Baker", + "email": "mark@demon-angel.eu" + } + ], + "description": "PHP Class for working with matrices", + "homepage": "https://github.com/MarkBaker/PHPMatrix", + "keywords": [ + "mathematics", + "matrix", + "vector" + ], + "support": { + "issues": "https://github.com/MarkBaker/PHPMatrix/issues", + "source": "https://github.com/MarkBaker/PHPMatrix/tree/3.0.1" + }, + "install-path": "../markbaker/matrix" + }, + { + "name": "monolog/monolog", + "version": "2.10.0", + "version_normalized": "2.10.0.0", + "source": { + "type": "git", + "url": "https://github.com/Seldaek/monolog.git", + "reference": "5cf826f2991858b54d5c3809bee745560a1042a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/5cf826f2991858b54d5c3809bee745560a1042a7", + "reference": "5cf826f2991858b54d5c3809bee745560a1042a7", + "shasum": "" + }, + "require": { + "php": ">=7.2", + "psr/log": "^1.0.1 || ^2.0 || ^3.0" + }, + "provide": { + "psr/log-implementation": "1.0.0 || 2.0.0 || 3.0.0" + }, + "require-dev": { + "aws/aws-sdk-php": "^2.4.9 || ^3.0", + "doctrine/couchdb": "~1.0@dev", + "elasticsearch/elasticsearch": "^7 || ^8", + "ext-json": "*", + "graylog2/gelf-php": "^1.4.2 || ^2@dev", + "guzzlehttp/guzzle": "^7.4", + "guzzlehttp/psr7": "^2.2", + "mongodb/mongodb": "^1.8", + "php-amqplib/php-amqplib": "~2.4 || ^3", + "phpspec/prophecy": "^1.15", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^8.5.38 || ^9.6.19", + "predis/predis": "^1.1 || ^2.0", + "rollbar/rollbar": "^1.3 || ^2 || ^3", + "ruflin/elastica": "^7", + "swiftmailer/swiftmailer": "^5.3|^6.0", + "symfony/mailer": "^5.4 || ^6", + "symfony/mime": "^5.4 || ^6" + }, + "suggest": { + "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", + "doctrine/couchdb": "Allow sending log messages to a CouchDB server", + "elasticsearch/elasticsearch": "Allow sending log messages to an Elasticsearch server via official client", + "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", + "ext-curl": "Required to send log messages using the IFTTTHandler, the LogglyHandler, the SendGridHandler, the SlackWebhookHandler or the TelegramBotHandler", + "ext-mbstring": "Allow to work properly with unicode symbols", + "ext-mongodb": "Allow sending log messages to a MongoDB server (via driver)", + "ext-openssl": "Required to send log messages using SSL", + "ext-sockets": "Allow sending log messages to a Syslog server (via UDP driver)", + "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", + "mongodb/mongodb": "Allow sending log messages to a MongoDB server (via library)", + "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", + "rollbar/rollbar": "Allow sending log messages to Rollbar", + "ruflin/elastica": "Allow sending log messages to an Elastic Search server" + }, + "time": "2024-11-12T12:43:37+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Monolog\\": "src/Monolog" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "https://seld.be" + } + ], + "description": "Sends your logs to files, sockets, inboxes, databases and various web services", + "homepage": "https://github.com/Seldaek/monolog", + "keywords": [ + "log", + "logging", + "psr-3" + ], + "support": { + "issues": "https://github.com/Seldaek/monolog/issues", + "source": "https://github.com/Seldaek/monolog/tree/2.10.0" + }, + "funding": [ + { + "url": "https://github.com/Seldaek", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/monolog/monolog", + "type": "tidelift" + } + ], + "install-path": "../monolog/monolog" + }, + { + "name": "myclabs/php-enum", + "version": "1.8.5", + "version_normalized": "1.8.5.0", + "source": { + "type": "git", + "url": "https://github.com/myclabs/php-enum.git", + "reference": "e7be26966b7398204a234f8673fdad5ac6277802" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/php-enum/zipball/e7be26966b7398204a234f8673fdad5ac6277802", + "reference": "e7be26966b7398204a234f8673fdad5ac6277802", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^7.3 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.5", + "squizlabs/php_codesniffer": "1.*", + "vimeo/psalm": "^4.6.2 || ^5.2" + }, + "time": "2025-01-14T11:49:03+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "MyCLabs\\Enum\\": "src/" + }, + "classmap": [ + "stubs/Stringable.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP Enum contributors", + "homepage": "https://github.com/myclabs/php-enum/graphs/contributors" + } + ], + "description": "PHP Enum implementation", + "homepage": "https://github.com/myclabs/php-enum", + "keywords": [ + "enum" + ], + "support": { + "issues": "https://github.com/myclabs/php-enum/issues", + "source": "https://github.com/myclabs/php-enum/tree/1.8.5" + }, + "funding": [ + { + "url": "https://github.com/mnapoli", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/php-enum", + "type": "tidelift" + } + ], + "install-path": "../myclabs/php-enum" + }, + { + "name": "nelexa/zip", + "version": "4.0.2", + "version_normalized": "4.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/Ne-Lexa/php-zip.git", + "reference": "88a1b6549be813278ff2dd3b6b2ac188827634a7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Ne-Lexa/php-zip/zipball/88a1b6549be813278ff2dd3b6b2ac188827634a7", + "reference": "88a1b6549be813278ff2dd3b6b2ac188827634a7", + "shasum": "" + }, + "require": { + "ext-zlib": "*", + "php": "^7.4 || ^8.0", + "psr/http-message": "*", + "symfony/finder": "*" + }, + "require-dev": { + "ext-bz2": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-iconv": "*", + "ext-openssl": "*", + "ext-xml": "*", + "friendsofphp/php-cs-fixer": "^3.4.0", + "guzzlehttp/psr7": "^1.6", + "phpunit/phpunit": "^9", + "symfony/http-foundation": "*", + "symfony/var-dumper": "*", + "vimeo/psalm": "^4.6" + }, + "suggest": { + "ext-bz2": "Needed to support BZIP2 compression", + "ext-fileinfo": "Needed to get mime-type file", + "ext-iconv": "Needed to support convert zip entry name to requested character encoding", + "ext-openssl": "Needed to support encrypt zip entries or use ext-mcrypt" + }, + "time": "2022-06-17T11:17:46+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "PhpZip\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ne-Lexa", + "email": "alexey@nelexa.ru", + "role": "Developer" + } + ], + "description": "PhpZip is a php-library for extended work with ZIP-archives. Open, create, update, delete, extract and get info tool. Supports appending to existing ZIP files, WinZip AES encryption, Traditional PKWARE Encryption, BZIP2 compression, external file attributes and ZIP64 extensions. Alternative ZipArchive. It does not require php-zip extension.", + "homepage": "https://github.com/Ne-Lexa/php-zip", + "keywords": [ + "archive", + "extract", + "unzip", + "winzip", + "zip", + "ziparchive" + ], + "support": { + "issues": "https://github.com/Ne-Lexa/php-zip/issues", + "source": "https://github.com/Ne-Lexa/php-zip/tree/4.0.2" + }, + "install-path": "../nelexa/zip" + }, + { + "name": "overtrue/pinyin", + "version": "3.0.6", + "version_normalized": "3.0.6.0", + "source": { + "type": "git", + "url": "https://github.com/overtrue/pinyin.git", + "reference": "3b781d267197b74752daa32814d3a2cf5d140779" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/overtrue/pinyin/zipball/3b781d267197b74752daa32814d3a2cf5d140779", + "reference": "3b781d267197b74752daa32814d3a2cf5d140779", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "time": "2017-07-10T07:20:01+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Overtrue\\Pinyin\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Carlos", + "homepage": "http://github.com/overtrue" + } + ], + "description": "Chinese to pinyin translator.", + "homepage": "https://github.com/overtrue/pinyin", + "keywords": [ + "Chinese", + "Pinyin", + "cn2pinyin" + ], + "support": { + "issues": "https://github.com/overtrue/pinyin/issues", + "source": "https://github.com/overtrue/pinyin/tree/master" + }, + "install-path": "../overtrue/pinyin" + }, + { + "name": "overtrue/socialite", + "version": "2.0.24", + "version_normalized": "2.0.24.0", + "source": { + "type": "git", + "url": "https://github.com/overtrue/socialite.git", + "reference": "ee7e7b000ec7d64f2b8aba1f6a2eec5cdf3f8bec" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/overtrue/socialite/zipball/ee7e7b000ec7d64f2b8aba1f6a2eec5cdf3f8bec", + "reference": "ee7e7b000ec7d64f2b8aba1f6a2eec5cdf3f8bec", + "shasum": "" + }, + "require": { + "ext-json": "*", + "guzzlehttp/guzzle": "^5.0|^6.0|^7.0", + "php": ">=5.6", + "symfony/http-foundation": "^2.7|^3.0|^4.0|^5.0" + }, + "require-dev": { + "mockery/mockery": "~1.2", + "phpunit/phpunit": "^6.0|^7.0|^8.0|^9.0" + }, + "time": "2021-05-13T16:04:48+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Overtrue\\Socialite\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "overtrue", + "email": "anzhengchao@gmail.com" + } + ], + "description": "A collection of OAuth 2 packages that extracts from laravel/socialite.", + "keywords": [ + "login", + "oauth", + "qq", + "social", + "wechat", + "weibo" + ], + "support": { + "issues": "https://github.com/overtrue/socialite/issues", + "source": "https://github.com/overtrue/socialite/tree/2.0.24" + }, + "funding": [ + { + "url": "https://www.patreon.com/overtrue", + "type": "patreon" + } + ], + "install-path": "../overtrue/socialite" + }, + { + "name": "overtrue/wechat", + "version": "4.9.0", + "version_normalized": "4.9.0.0", + "source": { + "type": "git", + "url": "https://github.com/w7corp/easywechat.git", + "reference": "92791f5d957269c633b9aa175f842f6006f945b1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/w7corp/easywechat/zipball/92791f5d957269c633b9aa175f842f6006f945b1", + "reference": "92791f5d957269c633b9aa175f842f6006f945b1", + "shasum": "" + }, + "require": { + "easywechat-composer/easywechat-composer": "^1.1", + "ext-fileinfo": "*", + "ext-openssl": "*", + "ext-simplexml": "*", + "guzzlehttp/guzzle": "^6.2 || ^7.0", + "monolog/monolog": "^1.22 || ^2.0", + "overtrue/socialite": "~2.0", + "php": ">=7.2", + "pimple/pimple": "^3.0", + "psr/simple-cache": "^1.0", + "symfony/cache": "^3.3 || ^4.3 || ^5.0", + "symfony/event-dispatcher": "^4.3 || ^5.0", + "symfony/http-foundation": "^2.7 || ^3.0 || ^4.0 || ^5.0", + "symfony/psr-http-message-bridge": "^0.3 || ^1.0 || ^2.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.15", + "mikey179/vfsstream": "^1.6", + "mockery/mockery": "^1.2.3", + "phpstan/phpstan": "^0.12.0", + "phpunit/phpunit": "^7.5" + }, + "time": "2023-04-28T03:30:34+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/Kernel/Support/Helpers.php", + "src/Kernel/Helpers.php" + ], + "psr-4": { + "EasyWeChat\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "overtrue", + "email": "anzhengchao@gmail.com" + } + ], + "description": "微信SDK", + "keywords": [ + "easywechat", + "sdk", + "wechat", + "weixin", + "weixin-sdk" + ], + "support": { + "issues": "https://github.com/w7corp/easywechat/issues", + "source": "https://github.com/w7corp/easywechat/tree/4.9.0" + }, + "funding": [ + { + "url": "https://github.com/overtrue", + "type": "github" + } + ], + "abandoned": "w7corp/easywechat", + "install-path": "../overtrue/wechat" + }, + { + "name": "phpoffice/phpspreadsheet", + "version": "1.29.10", + "version_normalized": "1.29.10.0", + "source": { + "type": "git", + "url": "https://github.com/PHPOffice/PhpSpreadsheet.git", + "reference": "c80041b1628c4f18030407134fe88303661d4e4e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPOffice/PhpSpreadsheet/zipball/c80041b1628c4f18030407134fe88303661d4e4e", + "reference": "c80041b1628c4f18030407134fe88303661d4e4e", + "shasum": "" + }, + "require": { + "composer/pcre": "^1||^2||^3", + "ext-ctype": "*", + "ext-dom": "*", + "ext-fileinfo": "*", + "ext-gd": "*", + "ext-iconv": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-simplexml": "*", + "ext-xml": "*", + "ext-xmlreader": "*", + "ext-xmlwriter": "*", + "ext-zip": "*", + "ext-zlib": "*", + "ezyang/htmlpurifier": "^4.15", + "maennchen/zipstream-php": "^2.1 || ^3.0", + "markbaker/complex": "^3.0", + "markbaker/matrix": "^3.0", + "php": "^7.4 || ^8.0", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "psr/simple-cache": "^1.0 || ^2.0 || ^3.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "dev-main", + "dompdf/dompdf": "^1.0 || ^2.0 || ^3.0", + "friendsofphp/php-cs-fixer": "^3.2", + "mitoteam/jpgraph": "^10.3", + "mpdf/mpdf": "^8.1.1", + "phpcompatibility/php-compatibility": "^9.3", + "phpstan/phpstan": "^1.1", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^8.5 || ^9.0", + "squizlabs/php_codesniffer": "^3.7", + "tecnickcom/tcpdf": "^6.5" + }, + "suggest": { + "dompdf/dompdf": "Option for rendering PDF with PDF Writer", + "ext-intl": "PHP Internationalization Functions", + "mitoteam/jpgraph": "Option for rendering charts, or including charts with PDF or HTML Writers", + "mpdf/mpdf": "Option for rendering PDF with PDF Writer", + "tecnickcom/tcpdf": "Option for rendering PDF with PDF Writer" + }, + "time": "2025-02-08T02:56:14+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "PhpOffice\\PhpSpreadsheet\\": "src/PhpSpreadsheet" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maarten Balliauw", + "homepage": "https://blog.maartenballiauw.be" + }, + { + "name": "Mark Baker", + "homepage": "https://markbakeruk.net" + }, + { + "name": "Franck Lefevre", + "homepage": "https://rootslabs.net" + }, + { + "name": "Erik Tilt" + }, + { + "name": "Adrien Crivelli" + } + ], + "description": "PHPSpreadsheet - Read, Create and Write Spreadsheet documents in PHP - Spreadsheet engine", + "homepage": "https://github.com/PHPOffice/PhpSpreadsheet", + "keywords": [ + "OpenXML", + "excel", + "gnumeric", + "ods", + "php", + "spreadsheet", + "xls", + "xlsx" + ], + "support": { + "issues": "https://github.com/PHPOffice/PhpSpreadsheet/issues", + "source": "https://github.com/PHPOffice/PhpSpreadsheet/tree/1.29.10" + }, + "install-path": "../phpoffice/phpspreadsheet" + }, + { + "name": "pimple/pimple", + "version": "v3.5.0", + "version_normalized": "3.5.0.0", + "source": { + "type": "git", + "url": "https://github.com/silexphp/Pimple.git", + "reference": "a94b3a4db7fb774b3d78dad2315ddc07629e1bed" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/silexphp/Pimple/zipball/a94b3a4db7fb774b3d78dad2315ddc07629e1bed", + "reference": "a94b3a4db7fb774b3d78dad2315ddc07629e1bed", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/container": "^1.1 || ^2.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^5.4@dev" + }, + "time": "2021-10-28T11:13:42+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Pimple": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Pimple, a simple Dependency Injection Container", + "homepage": "https://pimple.symfony.com", + "keywords": [ + "container", + "dependency injection" + ], + "support": { + "source": "https://github.com/silexphp/Pimple/tree/v3.5.0" + }, + "install-path": "../pimple/pimple" + }, + { + "name": "psr/cache", + "version": "1.0.1", + "version_normalized": "1.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8", + "reference": "d11b50ad223250cf17b86e38383413f5a6764bf8", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2016-08-06T20:24:11+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "support": { + "source": "https://github.com/php-fig/cache/tree/master" + }, + "install-path": "../psr/cache" + }, + { + "name": "psr/container", + "version": "2.0.2", + "version_normalized": "2.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "time": "2021-11-05T16:47:00+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "install-path": "../psr/container" + }, + { + "name": "psr/event-dispatcher", + "version": "1.0.0", + "version_normalized": "1.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/event-dispatcher.git", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/event-dispatcher/zipball/dbefd12671e8a14ec7f180cab83036ed26714bb0", + "reference": "dbefd12671e8a14ec7f180cab83036ed26714bb0", + "shasum": "" + }, + "require": { + "php": ">=7.2.0" + }, + "time": "2019-01-08T18:20:26+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\EventDispatcher\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Standard interfaces for event handling.", + "keywords": [ + "events", + "psr", + "psr-14" + ], + "support": { + "issues": "https://github.com/php-fig/event-dispatcher/issues", + "source": "https://github.com/php-fig/event-dispatcher/tree/1.0.0" + }, + "install-path": "../psr/event-dispatcher" + }, + { + "name": "psr/http-client", + "version": "1.0.3", + "version_normalized": "1.0.3.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/bb5906edc1c324c9a05aa0873d40117941e5fa90", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "time": "2023-09-23T14:17:50+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client" + }, + "install-path": "../psr/http-client" + }, + { + "name": "psr/http-factory", + "version": "1.0.2", + "version_normalized": "1.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "e616d01114759c4c489f93b099585439f795fe35" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/e616d01114759c4c489f93b099585439f795fe35", + "reference": "e616d01114759c4c489f93b099585439f795fe35", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0 || ^2.0" + }, + "time": "2023-04-10T20:10:41+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory/tree/1.0.2" + }, + "install-path": "../psr/http-factory" + }, + { + "name": "psr/http-message", + "version": "1.1", + "version_normalized": "1.1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba", + "reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "time": "2023-04-04T09:50:52+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/1.1" + }, + "install-path": "../psr/http-message" + }, + { + "name": "psr/log", + "version": "1.1.4", + "version_normalized": "1.1.4.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11", + "reference": "d49695b909c3b7628b6289db5479a1c204601f11", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2021-05-03T11:20:27+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Log\\": "Psr/Log/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/1.1.4" + }, + "install-path": "../psr/log" + }, + { + "name": "psr/simple-cache", + "version": "1.0.1", + "version_normalized": "1.0.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "reference": "408d5eafb83c57f6365a3ca330ff23aa4a5fa39b", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "time": "2017-10-23T01:57:42+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/master" + }, + "install-path": "../psr/simple-cache" + }, + { + "name": "ralouphie/getallheaders", + "version": "3.0.3", + "version_normalized": "3.0.3.0", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "120b605dfeb996808c31b6477290a714d356e822" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", + "reference": "120b605dfeb996808c31b6477290a714d356e822", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.1", + "phpunit/phpunit": "^5 || ^6.5" + }, + "time": "2019-03-08T08:55:37+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "install-path": "../ralouphie/getallheaders" + }, + { + "name": "symfony/cache", + "version": "v5.4.46", + "version_normalized": "5.4.46.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/cache.git", + "reference": "0fe08ee32cec2748fbfea10c52d3ee02049e0f6b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/cache/zipball/0fe08ee32cec2748fbfea10c52d3ee02049e0f6b", + "reference": "0fe08ee32cec2748fbfea10c52d3ee02049e0f6b", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/cache": "^1.0|^2.0", + "psr/log": "^1.1|^2|^3", + "symfony/cache-contracts": "^1.1.7|^2", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php73": "^1.9", + "symfony/polyfill-php80": "^1.16", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/var-exporter": "^4.4|^5.0|^6.0" + }, + "conflict": { + "doctrine/dbal": "<2.13.1", + "symfony/dependency-injection": "<4.4", + "symfony/http-kernel": "<4.4", + "symfony/var-dumper": "<4.4" + }, + "provide": { + "psr/cache-implementation": "1.0|2.0", + "psr/simple-cache-implementation": "1.0|2.0", + "symfony/cache-implementation": "1.0|2.0" + }, + "require-dev": { + "cache/integration-tests": "dev-master", + "doctrine/cache": "^1.6|^2.0", + "doctrine/dbal": "^2.13.1|^3|^4", + "predis/predis": "^1.1|^2.0", + "psr/simple-cache": "^1.0|^2.0", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/filesystem": "^4.4|^5.0|^6.0", + "symfony/http-kernel": "^4.4|^5.0|^6.0", + "symfony/messenger": "^4.4|^5.0|^6.0", + "symfony/var-dumper": "^4.4|^5.0|^6.0" + }, + "time": "2024-11-04T11:43:55+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Component\\Cache\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides extended PSR-6, PSR-16 (and tags) implementations", + "homepage": "https://symfony.com", + "keywords": [ + "caching", + "psr6" + ], + "support": { + "source": "https://github.com/symfony/cache/tree/v5.4.46" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/cache" + }, + { + "name": "symfony/cache-contracts", + "version": "v2.5.4", + "version_normalized": "2.5.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/cache-contracts.git", + "reference": "517c3a3619dadfa6952c4651767fcadffb4df65e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/cache-contracts/zipball/517c3a3619dadfa6952c4651767fcadffb4df65e", + "reference": "517c3a3619dadfa6952c4651767fcadffb4df65e", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/cache": "^1.0|^2.0|^3.0" + }, + "suggest": { + "symfony/cache-implementation": "" + }, + "time": "2024-09-25T14:11:13+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Cache\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to caching", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/cache-contracts/tree/v2.5.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/cache-contracts" + }, + { + "name": "symfony/deprecation-contracts", + "version": "v2.5.4", + "version_normalized": "2.5.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/605389f2a7e5625f273b53960dc46aeaf9c62918", + "reference": "605389f2a7e5625f273b53960dc46aeaf9c62918", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "time": "2024-09-25T14:11:13+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "function.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/deprecation-contracts" + }, + { + "name": "symfony/event-dispatcher", + "version": "v5.4.45", + "version_normalized": "5.4.45.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "72982eb416f61003e9bb6e91f8b3213600dcf9e9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/72982eb416f61003e9bb6e91f8b3213600dcf9e9", + "reference": "72982eb416f61003e9bb6e91f8b3213600dcf9e9", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/event-dispatcher-contracts": "^2|^3", + "symfony/polyfill-php80": "^1.16" + }, + "conflict": { + "symfony/dependency-injection": "<4.4" + }, + "provide": { + "psr/event-dispatcher-implementation": "1.0", + "symfony/event-dispatcher-implementation": "2.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^4.4|^5.0|^6.0", + "symfony/error-handler": "^4.4|^5.0|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/http-foundation": "^4.4|^5.0|^6.0", + "symfony/service-contracts": "^1.1|^2|^3", + "symfony/stopwatch": "^4.4|^5.0|^6.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "time": "2024-09-25T14:11:13+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/event-dispatcher/tree/v5.4.45" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/event-dispatcher" + }, + { + "name": "symfony/event-dispatcher-contracts", + "version": "v2.5.4", + "version_normalized": "2.5.4.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher-contracts.git", + "reference": "e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f", + "reference": "e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/event-dispatcher": "^1" + }, + "suggest": { + "symfony/event-dispatcher-implementation": "" + }, + "time": "2024-09-25T14:11:13+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "2.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Contracts\\EventDispatcher\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to dispatching event", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/event-dispatcher-contracts/tree/v2.5.4" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/event-dispatcher-contracts" + }, + { + "name": "symfony/finder", + "version": "v5.4.45", + "version_normalized": "5.4.45.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/finder.git", + "reference": "63741784cd7b9967975eec610b256eed3ede022b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/finder/zipball/63741784cd7b9967975eec610b256eed3ede022b", + "reference": "63741784cd7b9967975eec610b256eed3ede022b", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-php80": "^1.16" + }, + "time": "2024-09-28T13:32:08+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Component\\Finder\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Finds files and directories via an intuitive fluent interface", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/finder/tree/v5.4.45" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/finder" + }, + { + "name": "symfony/http-foundation", + "version": "v5.4.48", + "version_normalized": "5.4.48.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/http-foundation.git", + "reference": "3f38b8af283b830e1363acd79e5bc3412d055341" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/3f38b8af283b830e1363acd79e5bc3412d055341", + "reference": "3f38b8af283b830e1363acd79e5bc3412d055341", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/deprecation-contracts": "^2.1|^3", + "symfony/polyfill-mbstring": "~1.1", + "symfony/polyfill-php80": "^1.16" + }, + "require-dev": { + "predis/predis": "^1.0|^2.0", + "symfony/cache": "^4.4|^5.0|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/expression-language": "^4.4|^5.0|^6.0", + "symfony/http-kernel": "^5.4.12|^6.0.12|^6.1.4", + "symfony/mime": "^4.4|^5.0|^6.0", + "symfony/rate-limiter": "^5.2|^6.0" + }, + "suggest": { + "symfony/mime": "To use the file extension guesser" + }, + "time": "2024-11-13T18:58:02+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Component\\HttpFoundation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Defines an object-oriented layer for the HTTP specification", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/http-foundation/tree/v5.4.48" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/http-foundation" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.31.0", + "version_normalized": "1.31.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/85181ba99b2345b0ef10ce42ecac37612d9fd341", + "reference": "85181ba99b2345b0ef10ce42ecac37612d9fd341", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "php": ">=7.2" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "time": "2024-09-09T11:45:10+00:00", + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.31.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-mbstring" + }, + { + "name": "symfony/polyfill-php73", + "version": "v1.32.0", + "version_normalized": "1.32.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php73.git", + "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/0f68c03565dcaaf25a890667542e8bd75fe7e5bb", + "reference": "0f68c03565dcaaf25a890667542e8bd75fe7e5bb", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "time": "2024-09-09T11:45:10+00:00", + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php73\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php73/tree/v1.32.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-php73" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.32.0", + "version_normalized": "1.32.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "reference": "0cc9dd0f17f61d8131e7df6b84bd344899fe2608", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "time": "2025-01-02T08:10:11+00:00", + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.32.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/polyfill-php80" + }, + { + "name": "symfony/psr-http-message-bridge", + "version": "v2.3.1", + "version_normalized": "2.3.1.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/psr-http-message-bridge.git", + "reference": "581ca6067eb62640de5ff08ee1ba6850a0ee472e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/581ca6067eb62640de5ff08ee1ba6850a0ee472e", + "reference": "581ca6067eb62640de5ff08ee1ba6850a0ee472e", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "psr/http-message": "^1.0 || ^2.0", + "symfony/deprecation-contracts": "^2.5 || ^3.0", + "symfony/http-foundation": "^5.4 || ^6.0" + }, + "require-dev": { + "nyholm/psr7": "^1.1", + "psr/log": "^1.1 || ^2 || ^3", + "symfony/browser-kit": "^5.4 || ^6.0", + "symfony/config": "^5.4 || ^6.0", + "symfony/event-dispatcher": "^5.4 || ^6.0", + "symfony/framework-bundle": "^5.4 || ^6.0", + "symfony/http-kernel": "^5.4 || ^6.0", + "symfony/phpunit-bridge": "^6.2" + }, + "suggest": { + "nyholm/psr7": "For a super lightweight PSR-7/17 implementation" + }, + "time": "2023-07-26T11:53:26+00:00", + "type": "symfony-bridge", + "extra": { + "branch-alias": { + "dev-main": "2.3-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Bridge\\PsrHttpMessage\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "PSR HTTP message bridge", + "homepage": "http://symfony.com", + "keywords": [ + "http", + "http-message", + "psr-17", + "psr-7" + ], + "support": { + "issues": "https://github.com/symfony/psr-http-message-bridge/issues", + "source": "https://github.com/symfony/psr-http-message-bridge/tree/v2.3.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/psr-http-message-bridge" + }, + { + "name": "symfony/service-contracts", + "version": "v1.1.2", + "version_normalized": "1.1.2.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/service-contracts.git", + "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/191afdcb5804db960d26d8566b7e9a2843cab3a0", + "reference": "191afdcb5804db960d26d8566b7e9a2843cab3a0", + "shasum": "" + }, + "require": { + "php": "^7.1.3" + }, + "suggest": { + "psr/container": "", + "symfony/service-implementation": "" + }, + "time": "2019-05-28T07:50:59+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Service\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to writing services", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/service-contracts/tree/v1.1.2" + }, + "install-path": "../symfony/service-contracts" + }, + { + "name": "symfony/var-exporter", + "version": "v5.4.45", + "version_normalized": "5.4.45.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/var-exporter.git", + "reference": "862700068db0ddfd8c5b850671e029a90246ec75" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/var-exporter/zipball/862700068db0ddfd8c5b850671e029a90246ec75", + "reference": "862700068db0ddfd8c5b850671e029a90246ec75", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-php80": "^1.16" + }, + "require-dev": { + "symfony/var-dumper": "^4.4.9|^5.0.9|^6.0" + }, + "time": "2024-09-25T14:11:13+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Symfony\\Component\\VarExporter\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Allows exporting any serializable PHP data structure to plain PHP code", + "homepage": "https://symfony.com", + "keywords": [ + "clone", + "construct", + "export", + "hydrate", + "instantiate", + "serialize" + ], + "support": { + "source": "https://github.com/symfony/var-exporter/tree/v5.4.45" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "install-path": "../symfony/var-exporter" + }, + { + "name": "topthink/framework", + "version": "dev-master", + "version_normalized": "dev-master", + "source": { + "type": "git", + "url": "https://gitee.com/fastadminnet/framework.git", + "reference": "e95df87aa1a37e83d7c5fb29722cc70967feb54b" + }, + "require": { + "php": ">=7.1.0", + "topthink/think-installer": "~1.0" + }, + "require-dev": { + "johnkary/phpunit-speedtrap": "^1.0", + "mikey179/vfsstream": "~1.6", + "phpdocumentor/reflection-docblock": "^2.0", + "phploc/phploc": "2.*", + "phpunit/phpunit": "4.8.*", + "sebastian/phpcpd": "2.*" + }, + "time": "2025-03-12T07:32:08+00:00", + "default-branch": true, + "type": "think-framework", + "installation-source": "source", + "autoload": { + "psr-4": { + "think\\": "library/think" + } + }, + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "liu21st", + "email": "liu21st@gmail.com" + } + ], + "description": "the new thinkphp framework", + "homepage": "http://thinkphp.cn/", + "keywords": [ + "ORM", + "framework", + "thinkphp" + ], + "install-path": "../../thinkphp" + }, + { + "name": "topthink/think-captcha", + "version": "v1.0.9", + "version_normalized": "1.0.9.0", + "source": { + "type": "git", + "url": "https://gitee.com/fastadminnet/think-captcha.git", + "reference": "9be9dd7e61c7fa3c478c4b92910d7230b94d0d23" + }, + "require": { + "topthink/framework": "~5.0.0 || dev-master", + "topthink/think-installer": ">=1.0.10" + }, + "time": "2023-07-16T09:41:14+00:00", + "type": "library", + "installation-source": "source", + "autoload": { + "psr-4": { + "think\\captcha\\": "src/" + }, + "files": [ + "src/helper.php" + ] + }, + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "captcha package for thinkphp5", + "install-path": "../topthink/think-captcha" + }, + { + "name": "topthink/think-helper", + "version": "v1.0.7", + "version_normalized": "1.0.7.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-helper.git", + "reference": "5f92178606c8ce131d36b37a57c58eb71e55f019" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-helper/zipball/5f92178606c8ce131d36b37a57c58eb71e55f019", + "reference": "5f92178606c8ce131d36b37a57c58eb71e55f019", + "shasum": "" + }, + "time": "2018-10-05T00:43:21+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/helper.php" + ], + "psr-4": { + "think\\helper\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "The ThinkPHP5 Helper Package", + "support": { + "issues": "https://github.com/top-think/think-helper/issues", + "source": "https://github.com/top-think/think-helper/tree/master" + }, + "install-path": "../topthink/think-helper" + }, + { + "name": "topthink/think-installer", + "version": "v1.0.14", + "version_normalized": "1.0.14.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-installer.git", + "reference": "eae1740ac264a55c06134b6685dfb9f837d004d1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-installer/zipball/eae1740ac264a55c06134b6685dfb9f837d004d1", + "reference": "eae1740ac264a55c06134b6685dfb9f837d004d1", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0||^2.0" + }, + "require-dev": { + "composer/composer": "^1.0||^2.0" + }, + "time": "2021-03-25T08:34:02+00:00", + "type": "composer-plugin", + "extra": { + "class": "think\\composer\\Plugin" + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "think\\composer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "support": { + "issues": "https://github.com/top-think/think-installer/issues", + "source": "https://github.com/top-think/think-installer/tree/v1.0.14" + }, + "install-path": "../topthink/think-installer" + }, + { + "name": "topthink/think-queue", + "version": "v1.1.6", + "version_normalized": "1.1.6.0", + "source": { + "type": "git", + "url": "https://github.com/top-think/think-queue.git", + "reference": "250650eb0e8ea5af4cfdc7ae46f3f4e0a24ac245" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/top-think/think-queue/zipball/250650eb0e8ea5af4cfdc7ae46f3f4e0a24ac245", + "reference": "250650eb0e8ea5af4cfdc7ae46f3f4e0a24ac245", + "shasum": "" + }, + "require": { + "topthink/think-helper": ">=1.0.4", + "topthink/think-installer": ">=1.0.10" + }, + "require-dev": { + "topthink/framework": "~5.0.0" + }, + "time": "2018-10-15T10:16:55+00:00", + "type": "think-extend", + "extra": { + "think-config": { + "queue": "src/config.php" + } + }, + "installation-source": "dist", + "autoload": { + "files": [ + "src/common.php" + ], + "psr-4": { + "think\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "yunwuxin", + "email": "448901948@qq.com" + } + ], + "description": "The ThinkPHP5 Queue Package", + "support": { + "issues": "https://github.com/top-think/think-queue/issues", + "source": "https://github.com/top-think/think-queue/tree/master" + }, + "install-path": "../topthink/think-queue" + } + ], + "dev": true, + "dev-package-names": [] +} diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php new file mode 100644 index 0000000..5988428 --- /dev/null +++ b/vendor/composer/installed.php @@ -0,0 +1,601 @@ + array( + 'name' => 'fastadminnet/fastadmin', + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'reference' => null, + 'type' => 'project', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev' => true, + ), + 'versions' => array( + 'adbario/php-dot-notation' => array( + 'pretty_version' => '2.5.0', + 'version' => '2.5.0.0', + 'reference' => '081e2cca50c84bfeeea2e3ef9b2c8d206d80ccae', + 'type' => 'library', + 'install_path' => __DIR__ . '/../adbario/php-dot-notation', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/credentials' => array( + 'pretty_version' => '1.2.3', + 'version' => '1.2.3.0', + 'reference' => 'f6d1986e7b7be8da781d0b99f24c92d9860ba0c1', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/credentials', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/darabonba-openapi' => array( + 'pretty_version' => '0.2.15', + 'version' => '0.2.15.0', + 'reference' => 'de1a60831d74b0ddf78c16f6d31be57d95b7d49e', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/darabonba-openapi', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/dypnsapi-20170525' => array( + 'pretty_version' => '1.1.3', + 'version' => '1.1.3.0', + 'reference' => 'dec5e2a15a4cacfa98f3c26e477d90bf750c0f0e', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/dypnsapi-20170525', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/endpoint-util' => array( + 'pretty_version' => '0.1.1', + 'version' => '0.1.1.0', + 'reference' => 'f3fe88a25d8df4faa3b0ae14ff202a9cc094e6c5', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/endpoint-util', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/gateway-spi' => array( + 'pretty_version' => '1.0.0', + 'version' => '1.0.0.0', + 'reference' => '7440f77750c329d8ab252db1d1d967314ccd1fcb', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/gateway-spi', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/openapi-util' => array( + 'pretty_version' => '0.2.1', + 'version' => '0.2.1.0', + 'reference' => 'f31f7bcd835e08ca24b6b8ba33637eb4eceb093a', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/openapi-util', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/tea' => array( + 'pretty_version' => '3.2.1', + 'version' => '3.2.1.0', + 'reference' => '1619cb96c158384f72b873e1f85de8b299c9c367', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/tea', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/tea-utils' => array( + 'pretty_version' => '0.2.21', + 'version' => '0.2.21.0', + 'reference' => '5039e45714c6456186d267f5d81a4b260a652495', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/tea-utils', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'alibabacloud/tea-xml' => array( + 'pretty_version' => '0.2.4', + 'version' => '0.2.4.0', + 'reference' => '3e0c000bf536224eebbac913c371bef174c0a16a', + 'type' => 'library', + 'install_path' => __DIR__ . '/../alibabacloud/tea-xml', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'aliyuncs/oss-sdk-php' => array( + 'pretty_version' => 'v2.7.2', + 'version' => '2.7.2.0', + 'reference' => '483dd0b8bff5d47f0e4ffc99f6077a295c5ccbb5', + 'type' => 'library', + 'install_path' => __DIR__ . '/../aliyuncs/oss-sdk-php', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'composer/pcre' => array( + 'pretty_version' => '3.3.2', + 'version' => '3.3.2.0', + 'reference' => 'b2bed4734f0cc156ee1fe9c0da2550420d99a21e', + 'type' => 'library', + 'install_path' => __DIR__ . '/./pcre', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'easywechat-composer/easywechat-composer' => array( + 'pretty_version' => '1.4.1', + 'version' => '1.4.1.0', + 'reference' => '3fc6a7ab6d3853c0f4e2922539b56cc37ef361cd', + 'type' => 'composer-plugin', + 'install_path' => __DIR__ . '/../easywechat-composer/easywechat-composer', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'ezyang/htmlpurifier' => array( + 'pretty_version' => 'v4.18.0', + 'version' => '4.18.0.0', + 'reference' => 'cb56001e54359df7ae76dc522d08845dc741621b', + 'type' => 'library', + 'install_path' => __DIR__ . '/../ezyang/htmlpurifier', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'fastadminnet/fastadmin' => array( + 'pretty_version' => '1.0.0+no-version-set', + 'version' => '1.0.0.0', + 'reference' => null, + 'type' => 'project', + 'install_path' => __DIR__ . '/../../', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'fastadminnet/fastadmin-addons' => array( + 'pretty_version' => '1.4.1', + 'version' => '1.4.1.0', + 'reference' => 'f98418b69fbdd07569ee97d9fd4a83dfd7fdc770', + 'type' => 'library', + 'install_path' => __DIR__ . '/../fastadminnet/fastadmin-addons', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'fastadminnet/fastadmin-mailer' => array( + 'pretty_version' => 'v2.1.0', + 'version' => '2.1.0.0', + 'reference' => '99b7369406d52c35cf4c9c38b0322b6846ca227a', + 'type' => 'library', + 'install_path' => __DIR__ . '/../fastadminnet/fastadmin-mailer', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'guzzlehttp/guzzle' => array( + 'pretty_version' => '7.9.2', + 'version' => '7.9.2.0', + 'reference' => 'd281ed313b989f213357e3be1a179f02196ac99b', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/guzzle', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'guzzlehttp/promises' => array( + 'pretty_version' => '2.2.0', + 'version' => '2.2.0.0', + 'reference' => '7c69f28996b0a6920945dd20b3857e499d9ca96c', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/promises', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'guzzlehttp/psr7' => array( + 'pretty_version' => '2.7.1', + 'version' => '2.7.1.0', + 'reference' => 'c2270caaabe631b3b44c85f99e5a04bbb8060d16', + 'type' => 'library', + 'install_path' => __DIR__ . '/../guzzlehttp/psr7', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'lizhichao/one-sm' => array( + 'pretty_version' => '1.10', + 'version' => '1.10.0.0', + 'reference' => '687a012a44a5bfd4d9143a0234e1060543be455a', + 'type' => 'library', + 'install_path' => __DIR__ . '/../lizhichao/one-sm', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'maennchen/zipstream-php' => array( + 'pretty_version' => '2.2.6', + 'version' => '2.2.6.0', + 'reference' => '30ad6f93cf3efe4192bc7a4c9cad11ff8f4f237f', + 'type' => 'library', + 'install_path' => __DIR__ . '/../maennchen/zipstream-php', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'markbaker/complex' => array( + 'pretty_version' => '3.0.2', + 'version' => '3.0.2.0', + 'reference' => '95c56caa1cf5c766ad6d65b6344b807c1e8405b9', + 'type' => 'library', + 'install_path' => __DIR__ . '/../markbaker/complex', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'markbaker/matrix' => array( + 'pretty_version' => '3.0.1', + 'version' => '3.0.1.0', + 'reference' => '728434227fe21be27ff6d86621a1b13107a2562c', + 'type' => 'library', + 'install_path' => __DIR__ . '/../markbaker/matrix', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'monolog/monolog' => array( + 'pretty_version' => '2.10.0', + 'version' => '2.10.0.0', + 'reference' => '5cf826f2991858b54d5c3809bee745560a1042a7', + 'type' => 'library', + 'install_path' => __DIR__ . '/../monolog/monolog', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'myclabs/php-enum' => array( + 'pretty_version' => '1.8.5', + 'version' => '1.8.5.0', + 'reference' => 'e7be26966b7398204a234f8673fdad5ac6277802', + 'type' => 'library', + 'install_path' => __DIR__ . '/../myclabs/php-enum', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'nelexa/zip' => array( + 'pretty_version' => '4.0.2', + 'version' => '4.0.2.0', + 'reference' => '88a1b6549be813278ff2dd3b6b2ac188827634a7', + 'type' => 'library', + 'install_path' => __DIR__ . '/../nelexa/zip', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'overtrue/pinyin' => array( + 'pretty_version' => '3.0.6', + 'version' => '3.0.6.0', + 'reference' => '3b781d267197b74752daa32814d3a2cf5d140779', + 'type' => 'library', + 'install_path' => __DIR__ . '/../overtrue/pinyin', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'overtrue/socialite' => array( + 'pretty_version' => '2.0.24', + 'version' => '2.0.24.0', + 'reference' => 'ee7e7b000ec7d64f2b8aba1f6a2eec5cdf3f8bec', + 'type' => 'library', + 'install_path' => __DIR__ . '/../overtrue/socialite', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'overtrue/wechat' => array( + 'pretty_version' => '4.9.0', + 'version' => '4.9.0.0', + 'reference' => '92791f5d957269c633b9aa175f842f6006f945b1', + 'type' => 'library', + 'install_path' => __DIR__ . '/../overtrue/wechat', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'phpoffice/phpspreadsheet' => array( + 'pretty_version' => '1.29.10', + 'version' => '1.29.10.0', + 'reference' => 'c80041b1628c4f18030407134fe88303661d4e4e', + 'type' => 'library', + 'install_path' => __DIR__ . '/../phpoffice/phpspreadsheet', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'pimple/pimple' => array( + 'pretty_version' => 'v3.5.0', + 'version' => '3.5.0.0', + 'reference' => 'a94b3a4db7fb774b3d78dad2315ddc07629e1bed', + 'type' => 'library', + 'install_path' => __DIR__ . '/../pimple/pimple', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/cache' => array( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'reference' => 'd11b50ad223250cf17b86e38383413f5a6764bf8', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/cache', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/cache-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0|2.0', + ), + ), + 'psr/container' => array( + 'pretty_version' => '2.0.2', + 'version' => '2.0.2.0', + 'reference' => 'c71ecc56dfe541dbd90c5360474fbc405f8d5963', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/container', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/event-dispatcher' => array( + 'pretty_version' => '1.0.0', + 'version' => '1.0.0.0', + 'reference' => 'dbefd12671e8a14ec7f180cab83036ed26714bb0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/event-dispatcher', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/event-dispatcher-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/http-client' => array( + 'pretty_version' => '1.0.3', + 'version' => '1.0.3.0', + 'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-client', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/http-client-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/http-factory' => array( + 'pretty_version' => '1.0.2', + 'version' => '1.0.2.0', + 'reference' => 'e616d01114759c4c489f93b099585439f795fe35', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-factory', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/http-factory-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/http-message' => array( + 'pretty_version' => '1.1', + 'version' => '1.1.0.0', + 'reference' => 'cb6ce4845ce34a8ad9e68117c10ee90a29919eba', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/http-message', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/http-message-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0', + ), + ), + 'psr/log' => array( + 'pretty_version' => '1.1.4', + 'version' => '1.1.4.0', + 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/log', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/log-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0.0 || 2.0.0 || 3.0.0', + ), + ), + 'psr/simple-cache' => array( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'reference' => '408d5eafb83c57f6365a3ca330ff23aa4a5fa39b', + 'type' => 'library', + 'install_path' => __DIR__ . '/../psr/simple-cache', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'psr/simple-cache-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0|2.0', + ), + ), + 'ralouphie/getallheaders' => array( + 'pretty_version' => '3.0.3', + 'version' => '3.0.3.0', + 'reference' => '120b605dfeb996808c31b6477290a714d356e822', + 'type' => 'library', + 'install_path' => __DIR__ . '/../ralouphie/getallheaders', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/cache' => array( + 'pretty_version' => 'v5.4.46', + 'version' => '5.4.46.0', + 'reference' => '0fe08ee32cec2748fbfea10c52d3ee02049e0f6b', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/cache', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/cache-contracts' => array( + 'pretty_version' => 'v2.5.4', + 'version' => '2.5.4.0', + 'reference' => '517c3a3619dadfa6952c4651767fcadffb4df65e', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/cache-contracts', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/cache-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '1.0|2.0', + ), + ), + 'symfony/deprecation-contracts' => array( + 'pretty_version' => 'v2.5.4', + 'version' => '2.5.4.0', + 'reference' => '605389f2a7e5625f273b53960dc46aeaf9c62918', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/event-dispatcher' => array( + 'pretty_version' => 'v5.4.45', + 'version' => '5.4.45.0', + 'reference' => '72982eb416f61003e9bb6e91f8b3213600dcf9e9', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/event-dispatcher', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/event-dispatcher-contracts' => array( + 'pretty_version' => 'v2.5.4', + 'version' => '2.5.4.0', + 'reference' => 'e0fe3d79b516eb75126ac6fa4cbf19b79b08c99f', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/event-dispatcher-contracts', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/event-dispatcher-implementation' => array( + 'dev_requirement' => false, + 'provided' => array( + 0 => '2.0', + ), + ), + 'symfony/finder' => array( + 'pretty_version' => 'v5.4.45', + 'version' => '5.4.45.0', + 'reference' => '63741784cd7b9967975eec610b256eed3ede022b', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/finder', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/http-foundation' => array( + 'pretty_version' => 'v5.4.48', + 'version' => '5.4.48.0', + 'reference' => '3f38b8af283b830e1363acd79e5bc3412d055341', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/http-foundation', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/polyfill-mbstring' => array( + 'pretty_version' => 'v1.31.0', + 'version' => '1.31.0.0', + 'reference' => '85181ba99b2345b0ef10ce42ecac37612d9fd341', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-mbstring', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/polyfill-php73' => array( + 'pretty_version' => 'v1.32.0', + 'version' => '1.32.0.0', + 'reference' => '0f68c03565dcaaf25a890667542e8bd75fe7e5bb', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-php73', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/polyfill-php80' => array( + 'pretty_version' => 'v1.32.0', + 'version' => '1.32.0.0', + 'reference' => '0cc9dd0f17f61d8131e7df6b84bd344899fe2608', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/polyfill-php80', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/psr-http-message-bridge' => array( + 'pretty_version' => 'v2.3.1', + 'version' => '2.3.1.0', + 'reference' => '581ca6067eb62640de5ff08ee1ba6850a0ee472e', + 'type' => 'symfony-bridge', + 'install_path' => __DIR__ . '/../symfony/psr-http-message-bridge', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/service-contracts' => array( + 'pretty_version' => 'v1.1.2', + 'version' => '1.1.2.0', + 'reference' => '191afdcb5804db960d26d8566b7e9a2843cab3a0', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/service-contracts', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'symfony/var-exporter' => array( + 'pretty_version' => 'v5.4.45', + 'version' => '5.4.45.0', + 'reference' => '862700068db0ddfd8c5b850671e029a90246ec75', + 'type' => 'library', + 'install_path' => __DIR__ . '/../symfony/var-exporter', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/framework' => array( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'reference' => 'e95df87aa1a37e83d7c5fb29722cc70967feb54b', + 'type' => 'think-framework', + 'install_path' => __DIR__ . '/../../thinkphp', + 'aliases' => array( + 0 => '9999999-dev', + ), + 'dev_requirement' => false, + ), + 'topthink/think-captcha' => array( + 'pretty_version' => 'v1.0.9', + 'version' => '1.0.9.0', + 'reference' => '9be9dd7e61c7fa3c478c4b92910d7230b94d0d23', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/think-captcha', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think-helper' => array( + 'pretty_version' => 'v1.0.7', + 'version' => '1.0.7.0', + 'reference' => '5f92178606c8ce131d36b37a57c58eb71e55f019', + 'type' => 'library', + 'install_path' => __DIR__ . '/../topthink/think-helper', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think-installer' => array( + 'pretty_version' => 'v1.0.14', + 'version' => '1.0.14.0', + 'reference' => 'eae1740ac264a55c06134b6685dfb9f837d004d1', + 'type' => 'composer-plugin', + 'install_path' => __DIR__ . '/../topthink/think-installer', + 'aliases' => array(), + 'dev_requirement' => false, + ), + 'topthink/think-queue' => array( + 'pretty_version' => 'v1.1.6', + 'version' => '1.1.6.0', + 'reference' => '250650eb0e8ea5af4cfdc7ae46f3f4e0a24ac245', + 'type' => 'think-extend', + 'install_path' => __DIR__ . '/../topthink/think-queue', + 'aliases' => array(), + 'dev_requirement' => false, + ), + ), +); diff --git a/vendor/composer/pcre/LICENSE b/vendor/composer/pcre/LICENSE new file mode 100644 index 0000000..c5a282f --- /dev/null +++ b/vendor/composer/pcre/LICENSE @@ -0,0 +1,19 @@ +Copyright (C) 2021 Composer + +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. diff --git a/vendor/composer/pcre/README.md b/vendor/composer/pcre/README.md new file mode 100644 index 0000000..4906514 --- /dev/null +++ b/vendor/composer/pcre/README.md @@ -0,0 +1,189 @@ +composer/pcre +============= + +PCRE wrapping library that offers type-safe `preg_*` replacements. + +This library gives you a way to ensure `preg_*` functions do not fail silently, returning +unexpected `null`s that may not be handled. + +As of 3.0 this library enforces [`PREG_UNMATCHED_AS_NULL`](#preg_unmatched_as_null) usage +for all matching and replaceCallback functions, [read more below](#preg_unmatched_as_null) +to understand the implications. + +It thus makes it easier to work with static analysis tools like PHPStan or Psalm as it +simplifies and reduces the possible return values from all the `preg_*` functions which +are quite packed with edge cases. As of v2.2.0 / v3.2.0 the library also comes with a +[PHPStan extension](#phpstan-extension) for parsing regular expressions and giving you even better output types. + +This library is a thin wrapper around `preg_*` functions with [some limitations](#restrictions--limitations). +If you are looking for a richer API to handle regular expressions have a look at +[rawr/t-regx](https://packagist.org/packages/rawr/t-regx) instead. + +[![Continuous Integration](https://github.com/composer/pcre/workflows/Continuous%20Integration/badge.svg?branch=main)](https://github.com/composer/pcre/actions) + + +Installation +------------ + +Install the latest version with: + +```bash +$ composer require composer/pcre +``` + + +Requirements +------------ + +* PHP 7.4.0 is required for 3.x versions +* PHP 7.2.0 is required for 2.x versions +* PHP 5.3.2 is required for 1.x versions + + +Basic usage +----------- + +Instead of: + +```php +if (preg_match('{fo+}', $string, $matches)) { ... } +if (preg_match('{fo+}', $string, $matches, PREG_OFFSET_CAPTURE)) { ... } +if (preg_match_all('{fo+}', $string, $matches)) { ... } +$newString = preg_replace('{fo+}', 'bar', $string); +$newString = preg_replace_callback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string); +$newString = preg_replace_callback_array(['{fo+}' => fn ($match) => strtoupper($match[0])], $string); +$filtered = preg_grep('{[a-z]}', $elements); +$array = preg_split('{[a-z]+}', $string); +``` + +You can now call these on the `Preg` class: + +```php +use Composer\Pcre\Preg; + +if (Preg::match('{fo+}', $string, $matches)) { ... } +if (Preg::matchWithOffsets('{fo+}', $string, $matches)) { ... } +if (Preg::matchAll('{fo+}', $string, $matches)) { ... } +$newString = Preg::replace('{fo+}', 'bar', $string); +$newString = Preg::replaceCallback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string); +$newString = Preg::replaceCallbackArray(['{fo+}' => fn ($match) => strtoupper($match[0])], $string); +$filtered = Preg::grep('{[a-z]}', $elements); +$array = Preg::split('{[a-z]+}', $string); +``` + +The main difference is if anything fails to match/replace/.., it will throw a `Composer\Pcre\PcreException` +instead of returning `null` (or false in some cases), so you can now use the return values safely relying on +the fact that they can only be strings (for replace), ints (for match) or arrays (for grep/split). + +Additionally the `Preg` class provides match methods that return `bool` rather than `int`, for stricter type safety +when the number of pattern matches is not useful: + +```php +use Composer\Pcre\Preg; + +if (Preg::isMatch('{fo+}', $string, $matches)) // bool +if (Preg::isMatchAll('{fo+}', $string, $matches)) // bool +``` + +Finally the `Preg` class provides a few `*StrictGroups` method variants that ensure match groups +are always present and thus non-nullable, making it easier to write type-safe code: + +```php +use Composer\Pcre\Preg; + +// $matches is guaranteed to be an array of strings, if a subpattern does not match and produces a null it will throw +if (Preg::matchStrictGroups('{fo+}', $string, $matches)) +if (Preg::matchAllStrictGroups('{fo+}', $string, $matches)) +``` + +**Note:** This is generally safe to use as long as you do not have optional subpatterns (i.e. `(something)?` +or `(something)*` or branches with a `|` that result in some groups not being matched at all). +A subpattern that can match an empty string like `(.*)` is **not** optional, it will be present as an +empty string in the matches. A non-matching subpattern, even if optional like `(?:foo)?` will anyway not be present in +matches so it is also not a problem to use these with `*StrictGroups` methods. + +If you would prefer a slightly more verbose usage, replacing by-ref arguments by result objects, you can use the `Regex` class: + +```php +use Composer\Pcre\Regex; + +// this is useful when you are just interested in knowing if something matched +// as it returns a bool instead of int(1/0) for match +$bool = Regex::isMatch('{fo+}', $string); + +$result = Regex::match('{fo+}', $string); +if ($result->matched) { something($result->matches); } + +$result = Regex::matchWithOffsets('{fo+}', $string); +if ($result->matched) { something($result->matches); } + +$result = Regex::matchAll('{fo+}', $string); +if ($result->matched && $result->count > 3) { something($result->matches); } + +$newString = Regex::replace('{fo+}', 'bar', $string)->result; +$newString = Regex::replaceCallback('{fo+}', function ($match) { return strtoupper($match[0]); }, $string)->result; +$newString = Regex::replaceCallbackArray(['{fo+}' => fn ($match) => strtoupper($match[0])], $string)->result; +``` + +Note that `preg_grep` and `preg_split` are only callable via the `Preg` class as they do not have +complex return types warranting a specific result object. + +See the [MatchResult](src/MatchResult.php), [MatchWithOffsetsResult](src/MatchWithOffsetsResult.php), [MatchAllResult](src/MatchAllResult.php), +[MatchAllWithOffsetsResult](src/MatchAllWithOffsetsResult.php), and [ReplaceResult](src/ReplaceResult.php) class sources for more details. + +Restrictions / Limitations +-------------------------- + +Due to type safety requirements a few restrictions are in place. + +- matching using `PREG_OFFSET_CAPTURE` is made available via `matchWithOffsets` and `matchAllWithOffsets`. + You cannot pass the flag to `match`/`matchAll`. +- `Preg::split` will also reject `PREG_SPLIT_OFFSET_CAPTURE` and you should use `splitWithOffsets` + instead. +- `matchAll` rejects `PREG_SET_ORDER` as it also changes the shape of the returned matches. There + is no alternative provided as you can fairly easily code around it. +- `preg_filter` is not supported as it has a rather crazy API, most likely you should rather + use `Preg::grep` in combination with some loop and `Preg::replace`. +- `replace`, `replaceCallback` and `replaceCallbackArray` do not support an array `$subject`, + only simple strings. +- As of 2.0, the library always uses `PREG_UNMATCHED_AS_NULL` for matching, which offers [much + saner/more predictable results](#preg_unmatched_as_null). As of 3.0 the flag is also set for + `replaceCallback` and `replaceCallbackArray`. + +#### PREG_UNMATCHED_AS_NULL + +As of 2.0, this library always uses PREG_UNMATCHED_AS_NULL for all `match*` and `isMatch*` +functions. As of 3.0 it is also done for `replaceCallback` and `replaceCallbackArray`. + +This means your matches will always contain all matching groups, either as null if unmatched +or as string if it matched. + +The advantages in clarity and predictability are clearer if you compare the two outputs of +running this with and without PREG_UNMATCHED_AS_NULL in $flags: + +```php +preg_match('/(a)(b)*(c)(d)*/', 'ac', $matches, $flags); +``` + +| no flag | PREG_UNMATCHED_AS_NULL | +| --- | --- | +| array (size=4) | array (size=5) | +| 0 => string 'ac' (length=2) | 0 => string 'ac' (length=2) | +| 1 => string 'a' (length=1) | 1 => string 'a' (length=1) | +| 2 => string '' (length=0) | 2 => null | +| 3 => string 'c' (length=1) | 3 => string 'c' (length=1) | +| | 4 => null | +| group 2 (any unmatched group preceding one that matched) is set to `''`. You cannot tell if it matched an empty string or did not match at all | group 2 is `null` when unmatched and a string if it matched, easy to check for | +| group 4 (any optional group without a matching one following) is missing altogether. So you have to check with `isset()`, but really you want `isset($m[4]) && $m[4] !== ''` for safety unless you are very careful to check that a non-optional group follows it | group 4 is always set, and null in this case as there was no match, easy to check for with `$m[4] !== null` | + +PHPStan Extension +----------------- + +To use the PHPStan extension if you do not use `phpstan/extension-installer` you can include `vendor/composer/pcre/extension.neon` in your PHPStan config. + +The extension provides much better type information for $matches as well as regex validation where possible. + +License +------- + +composer/pcre is licensed under the MIT License, see the LICENSE file for details. diff --git a/vendor/composer/pcre/composer.json b/vendor/composer/pcre/composer.json new file mode 100644 index 0000000..d3a7e67 --- /dev/null +++ b/vendor/composer/pcre/composer.json @@ -0,0 +1,54 @@ +{ + "name": "composer/pcre", + "description": "PCRE wrapping library that offers type-safe preg_* replacements.", + "type": "library", + "license": "MIT", + "keywords": [ + "pcre", + "regex", + "preg", + "regular expression" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "require": { + "php": "^7.4 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^8 || ^9", + "phpstan/phpstan": "^1.12 || ^2", + "phpstan/phpstan-strict-rules": "^1 || ^2" + }, + "conflict": { + "phpstan/phpstan": "<1.11.10" + }, + "autoload": { + "psr-4": { + "Composer\\Pcre\\": "src" + } + }, + "autoload-dev": { + "psr-4": { + "Composer\\Pcre\\": "tests" + } + }, + "extra": { + "branch-alias": { + "dev-main": "3.x-dev" + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "scripts": { + "test": "@php vendor/bin/phpunit", + "phpstan": "@php phpstan analyse" + } +} diff --git a/vendor/composer/pcre/extension.neon b/vendor/composer/pcre/extension.neon new file mode 100644 index 0000000..b9cea11 --- /dev/null +++ b/vendor/composer/pcre/extension.neon @@ -0,0 +1,22 @@ +# composer/pcre PHPStan extensions +# +# These can be reused by third party packages by including 'vendor/composer/pcre/extension.neon' +# in your phpstan config + +services: + - + class: Composer\Pcre\PHPStan\PregMatchParameterOutTypeExtension + tags: + - phpstan.staticMethodParameterOutTypeExtension + - + class: Composer\Pcre\PHPStan\PregMatchTypeSpecifyingExtension + tags: + - phpstan.typeSpecifier.staticMethodTypeSpecifyingExtension + - + class: Composer\Pcre\PHPStan\PregReplaceCallbackClosureTypeExtension + tags: + - phpstan.staticMethodParameterClosureTypeExtension + +rules: + - Composer\Pcre\PHPStan\UnsafeStrictGroupsCallRule + - Composer\Pcre\PHPStan\InvalidRegexPatternRule diff --git a/vendor/composer/pcre/src/MatchAllResult.php b/vendor/composer/pcre/src/MatchAllResult.php new file mode 100644 index 0000000..b22b52d --- /dev/null +++ b/vendor/composer/pcre/src/MatchAllResult.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +final class MatchAllResult +{ + /** + * An array of match group => list of matched strings + * + * @readonly + * @var array> + */ + public $matches; + + /** + * @readonly + * @var 0|positive-int + */ + public $count; + + /** + * @readonly + * @var bool + */ + public $matched; + + /** + * @param 0|positive-int $count + * @param array> $matches + */ + public function __construct(int $count, array $matches) + { + $this->matches = $matches; + $this->matched = (bool) $count; + $this->count = $count; + } +} diff --git a/vendor/composer/pcre/src/MatchAllStrictGroupsResult.php b/vendor/composer/pcre/src/MatchAllStrictGroupsResult.php new file mode 100644 index 0000000..b7ec397 --- /dev/null +++ b/vendor/composer/pcre/src/MatchAllStrictGroupsResult.php @@ -0,0 +1,46 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +final class MatchAllStrictGroupsResult +{ + /** + * An array of match group => list of matched strings + * + * @readonly + * @var array> + */ + public $matches; + + /** + * @readonly + * @var 0|positive-int + */ + public $count; + + /** + * @readonly + * @var bool + */ + public $matched; + + /** + * @param 0|positive-int $count + * @param array> $matches + */ + public function __construct(int $count, array $matches) + { + $this->matches = $matches; + $this->matched = (bool) $count; + $this->count = $count; + } +} diff --git a/vendor/composer/pcre/src/MatchAllWithOffsetsResult.php b/vendor/composer/pcre/src/MatchAllWithOffsetsResult.php new file mode 100644 index 0000000..032a02c --- /dev/null +++ b/vendor/composer/pcre/src/MatchAllWithOffsetsResult.php @@ -0,0 +1,48 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +final class MatchAllWithOffsetsResult +{ + /** + * An array of match group => list of matches, every match being a pair of string matched + offset in bytes (or -1 if no match) + * + * @readonly + * @var array> + * @phpstan-var array}>> + */ + public $matches; + + /** + * @readonly + * @var 0|positive-int + */ + public $count; + + /** + * @readonly + * @var bool + */ + public $matched; + + /** + * @param 0|positive-int $count + * @param array> $matches + * @phpstan-param array}>> $matches + */ + public function __construct(int $count, array $matches) + { + $this->matches = $matches; + $this->matched = (bool) $count; + $this->count = $count; + } +} diff --git a/vendor/composer/pcre/src/MatchResult.php b/vendor/composer/pcre/src/MatchResult.php new file mode 100644 index 0000000..e951a5e --- /dev/null +++ b/vendor/composer/pcre/src/MatchResult.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +final class MatchResult +{ + /** + * An array of match group => string matched + * + * @readonly + * @var array + */ + public $matches; + + /** + * @readonly + * @var bool + */ + public $matched; + + /** + * @param 0|positive-int $count + * @param array $matches + */ + public function __construct(int $count, array $matches) + { + $this->matches = $matches; + $this->matched = (bool) $count; + } +} diff --git a/vendor/composer/pcre/src/MatchStrictGroupsResult.php b/vendor/composer/pcre/src/MatchStrictGroupsResult.php new file mode 100644 index 0000000..126ee62 --- /dev/null +++ b/vendor/composer/pcre/src/MatchStrictGroupsResult.php @@ -0,0 +1,39 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +final class MatchStrictGroupsResult +{ + /** + * An array of match group => string matched + * + * @readonly + * @var array + */ + public $matches; + + /** + * @readonly + * @var bool + */ + public $matched; + + /** + * @param 0|positive-int $count + * @param array $matches + */ + public function __construct(int $count, array $matches) + { + $this->matches = $matches; + $this->matched = (bool) $count; + } +} diff --git a/vendor/composer/pcre/src/MatchWithOffsetsResult.php b/vendor/composer/pcre/src/MatchWithOffsetsResult.php new file mode 100644 index 0000000..ba4d4bc --- /dev/null +++ b/vendor/composer/pcre/src/MatchWithOffsetsResult.php @@ -0,0 +1,41 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +final class MatchWithOffsetsResult +{ + /** + * An array of match group => pair of string matched + offset in bytes (or -1 if no match) + * + * @readonly + * @var array + * @phpstan-var array}> + */ + public $matches; + + /** + * @readonly + * @var bool + */ + public $matched; + + /** + * @param 0|positive-int $count + * @param array $matches + * @phpstan-param array}> $matches + */ + public function __construct(int $count, array $matches) + { + $this->matches = $matches; + $this->matched = (bool) $count; + } +} diff --git a/vendor/composer/pcre/src/PHPStan/InvalidRegexPatternRule.php b/vendor/composer/pcre/src/PHPStan/InvalidRegexPatternRule.php new file mode 100644 index 0000000..8a05fb2 --- /dev/null +++ b/vendor/composer/pcre/src/PHPStan/InvalidRegexPatternRule.php @@ -0,0 +1,142 @@ + + */ +class InvalidRegexPatternRule implements Rule +{ + public function getNodeType(): string + { + return StaticCall::class; + } + + public function processNode(Node $node, Scope $scope): array + { + $patterns = $this->extractPatterns($node, $scope); + + $errors = []; + foreach ($patterns as $pattern) { + $errorMessage = $this->validatePattern($pattern); + if ($errorMessage === null) { + continue; + } + + $errors[] = RuleErrorBuilder::message(sprintf('Regex pattern is invalid: %s', $errorMessage))->identifier('regexp.pattern')->build(); + } + + return $errors; + } + + /** + * @return string[] + */ + private function extractPatterns(StaticCall $node, Scope $scope): array + { + if (!$node->class instanceof FullyQualified) { + return []; + } + $isRegex = $node->class->toString() === Regex::class; + $isPreg = $node->class->toString() === Preg::class; + if (!$isRegex && !$isPreg) { + return []; + } + if (!$node->name instanceof Node\Identifier || !Preg::isMatch('{^(match|isMatch|grep|replace|split)}', $node->name->name)) { + return []; + } + + $functionName = $node->name->name; + if (!isset($node->getArgs()[0])) { + return []; + } + + $patternNode = $node->getArgs()[0]->value; + $patternType = $scope->getType($patternNode); + + $patternStrings = []; + + foreach ($patternType->getConstantStrings() as $constantStringType) { + if ($functionName === 'replaceCallbackArray') { + continue; + } + + $patternStrings[] = $constantStringType->getValue(); + } + + foreach ($patternType->getConstantArrays() as $constantArrayType) { + if ( + in_array($functionName, [ + 'replace', + 'replaceCallback', + ], true) + ) { + foreach ($constantArrayType->getValueTypes() as $arrayKeyType) { + foreach ($arrayKeyType->getConstantStrings() as $constantString) { + $patternStrings[] = $constantString->getValue(); + } + } + } + + if ($functionName !== 'replaceCallbackArray') { + continue; + } + + foreach ($constantArrayType->getKeyTypes() as $arrayKeyType) { + foreach ($arrayKeyType->getConstantStrings() as $constantString) { + $patternStrings[] = $constantString->getValue(); + } + } + } + + return $patternStrings; + } + + private function validatePattern(string $pattern): ?string + { + try { + $msg = null; + $prev = set_error_handler(function (int $severity, string $message, string $file) use (&$msg): bool { + $msg = preg_replace("#^preg_match(_all)?\\(.*?\\): #", '', $message); + + return true; + }); + + if ($pattern === '') { + return 'Empty string is not a valid regular expression'; + } + + Preg::match($pattern, ''); + if ($msg !== null) { + return $msg; + } + } catch (PcreException $e) { + if ($e->getCode() === PREG_INTERNAL_ERROR && $msg !== null) { + return $msg; + } + + return preg_replace('{.*? failed executing ".*": }', '', $e->getMessage()); + } finally { + restore_error_handler(); + } + + return null; + } + +} diff --git a/vendor/composer/pcre/src/PHPStan/PregMatchFlags.php b/vendor/composer/pcre/src/PHPStan/PregMatchFlags.php new file mode 100644 index 0000000..aa30ab3 --- /dev/null +++ b/vendor/composer/pcre/src/PHPStan/PregMatchFlags.php @@ -0,0 +1,70 @@ +getType($flagsArg->value); + + $constantScalars = $flagsType->getConstantScalarValues(); + if ($constantScalars === []) { + return null; + } + + $internalFlagsTypes = []; + foreach ($flagsType->getConstantScalarValues() as $constantScalarValue) { + if (!is_int($constantScalarValue)) { + return null; + } + + $internalFlagsTypes[] = new ConstantIntegerType($constantScalarValue | PREG_UNMATCHED_AS_NULL); + } + return TypeCombinator::union(...$internalFlagsTypes); + } + + static public function removeNullFromMatches(Type $matchesType): Type + { + return TypeTraverser::map($matchesType, static function (Type $type, callable $traverse): Type { + if ($type instanceof UnionType || $type instanceof IntersectionType) { + return $traverse($type); + } + + if ($type instanceof ConstantArrayType) { + return new ConstantArrayType( + $type->getKeyTypes(), + array_map(static function (Type $valueType) use ($traverse): Type { + return $traverse($valueType); + }, $type->getValueTypes()), + $type->getNextAutoIndexes(), + [], + $type->isList() + ); + } + + if ($type instanceof ArrayType) { + return new ArrayType($type->getKeyType(), $traverse($type->getItemType())); + } + + return TypeCombinator::removeNull($type); + }); + } + +} diff --git a/vendor/composer/pcre/src/PHPStan/PregMatchParameterOutTypeExtension.php b/vendor/composer/pcre/src/PHPStan/PregMatchParameterOutTypeExtension.php new file mode 100644 index 0000000..e0d6020 --- /dev/null +++ b/vendor/composer/pcre/src/PHPStan/PregMatchParameterOutTypeExtension.php @@ -0,0 +1,65 @@ +regexShapeMatcher = $regexShapeMatcher; + } + + public function isStaticMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter): bool + { + return + $methodReflection->getDeclaringClass()->getName() === Preg::class + && in_array($methodReflection->getName(), [ + 'match', 'isMatch', 'matchStrictGroups', 'isMatchStrictGroups', + 'matchAll', 'isMatchAll', 'matchAllStrictGroups', 'isMatchAllStrictGroups' + ], true) + && $parameter->getName() === 'matches'; + } + + public function getParameterOutTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, ParameterReflection $parameter, Scope $scope): ?Type + { + $args = $methodCall->getArgs(); + $patternArg = $args[0] ?? null; + $matchesArg = $args[2] ?? null; + $flagsArg = $args[3] ?? null; + + if ( + $patternArg === null || $matchesArg === null + ) { + return null; + } + + $flagsType = PregMatchFlags::getType($flagsArg, $scope); + if ($flagsType === null) { + return null; + } + + if (stripos($methodReflection->getName(), 'matchAll') !== false) { + return $this->regexShapeMatcher->matchAllExpr($patternArg->value, $flagsType, TrinaryLogic::createMaybe(), $scope); + } + + return $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createMaybe(), $scope); + } + +} diff --git a/vendor/composer/pcre/src/PHPStan/PregMatchTypeSpecifyingExtension.php b/vendor/composer/pcre/src/PHPStan/PregMatchTypeSpecifyingExtension.php new file mode 100644 index 0000000..3db0ce0 --- /dev/null +++ b/vendor/composer/pcre/src/PHPStan/PregMatchTypeSpecifyingExtension.php @@ -0,0 +1,119 @@ +regexShapeMatcher = $regexShapeMatcher; + } + + public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void + { + $this->typeSpecifier = $typeSpecifier; + } + + public function getClass(): string + { + return Preg::class; + } + + public function isStaticMethodSupported(MethodReflection $methodReflection, StaticCall $node, TypeSpecifierContext $context): bool + { + return in_array($methodReflection->getName(), [ + 'match', 'isMatch', 'matchStrictGroups', 'isMatchStrictGroups', + 'matchAll', 'isMatchAll', 'matchAllStrictGroups', 'isMatchAllStrictGroups' + ], true) + && !$context->null(); + } + + public function specifyTypes(MethodReflection $methodReflection, StaticCall $node, Scope $scope, TypeSpecifierContext $context): SpecifiedTypes + { + $args = $node->getArgs(); + $patternArg = $args[0] ?? null; + $matchesArg = $args[2] ?? null; + $flagsArg = $args[3] ?? null; + + if ( + $patternArg === null || $matchesArg === null + ) { + return new SpecifiedTypes(); + } + + $flagsType = PregMatchFlags::getType($flagsArg, $scope); + if ($flagsType === null) { + return new SpecifiedTypes(); + } + + if (stripos($methodReflection->getName(), 'matchAll') !== false) { + $matchedType = $this->regexShapeMatcher->matchAllExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope); + } else { + $matchedType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope); + } + + if ($matchedType === null) { + return new SpecifiedTypes(); + } + + if ( + in_array($methodReflection->getName(), ['matchStrictGroups', 'isMatchStrictGroups', 'matchAllStrictGroups', 'isMatchAllStrictGroups'], true) + ) { + $matchedType = PregMatchFlags::removeNullFromMatches($matchedType); + } + + $overwrite = false; + if ($context->false()) { + $overwrite = true; + $context = $context->negate(); + } + + // @phpstan-ignore function.alreadyNarrowedType + if (method_exists('PHPStan\Analyser\SpecifiedTypes', 'setRootExpr')) { + $typeSpecifier = $this->typeSpecifier->create( + $matchesArg->value, + $matchedType, + $context, + $scope + )->setRootExpr($node); + + return $overwrite ? $typeSpecifier->setAlwaysOverwriteTypes() : $typeSpecifier; + } + + // @phpstan-ignore arguments.count + return $this->typeSpecifier->create( + $matchesArg->value, + $matchedType, + $context, + // @phpstan-ignore argument.type + $overwrite, + $scope, + $node + ); + } +} diff --git a/vendor/composer/pcre/src/PHPStan/PregReplaceCallbackClosureTypeExtension.php b/vendor/composer/pcre/src/PHPStan/PregReplaceCallbackClosureTypeExtension.php new file mode 100644 index 0000000..7b95367 --- /dev/null +++ b/vendor/composer/pcre/src/PHPStan/PregReplaceCallbackClosureTypeExtension.php @@ -0,0 +1,91 @@ +regexShapeMatcher = $regexShapeMatcher; + } + + public function isStaticMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter): bool + { + return in_array($methodReflection->getDeclaringClass()->getName(), [Preg::class, Regex::class], true) + && in_array($methodReflection->getName(), ['replaceCallback', 'replaceCallbackStrictGroups'], true) + && $parameter->getName() === 'replacement'; + } + + public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, ParameterReflection $parameter, Scope $scope): ?Type + { + $args = $methodCall->getArgs(); + $patternArg = $args[0] ?? null; + $flagsArg = $args[5] ?? null; + + if ( + $patternArg === null + ) { + return null; + } + + $flagsType = PregMatchFlags::getType($flagsArg, $scope); + + $matchesType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createYes(), $scope); + if ($matchesType === null) { + return null; + } + + if ($methodReflection->getName() === 'replaceCallbackStrictGroups' && count($matchesType->getConstantArrays()) === 1) { + $matchesType = $matchesType->getConstantArrays()[0]; + $matchesType = new ConstantArrayType( + $matchesType->getKeyTypes(), + array_map(static function (Type $valueType): Type { + if (count($valueType->getConstantArrays()) === 1) { + $valueTypeArray = $valueType->getConstantArrays()[0]; + return new ConstantArrayType( + $valueTypeArray->getKeyTypes(), + array_map(static function (Type $valueType): Type { + return TypeCombinator::removeNull($valueType); + }, $valueTypeArray->getValueTypes()), + $valueTypeArray->getNextAutoIndexes(), + [], + $valueTypeArray->isList() + ); + } + return TypeCombinator::removeNull($valueType); + }, $matchesType->getValueTypes()), + $matchesType->getNextAutoIndexes(), + [], + $matchesType->isList() + ); + } + + return new ClosureType( + [ + new NativeParameterReflection($parameter->getName(), $parameter->isOptional(), $matchesType, $parameter->passedByReference(), $parameter->isVariadic(), $parameter->getDefaultValue()), + ], + new StringType() + ); + } +} diff --git a/vendor/composer/pcre/src/PHPStan/UnsafeStrictGroupsCallRule.php b/vendor/composer/pcre/src/PHPStan/UnsafeStrictGroupsCallRule.php new file mode 100644 index 0000000..5bced50 --- /dev/null +++ b/vendor/composer/pcre/src/PHPStan/UnsafeStrictGroupsCallRule.php @@ -0,0 +1,112 @@ + + */ +final class UnsafeStrictGroupsCallRule implements Rule +{ + /** + * @var RegexArrayShapeMatcher + */ + private $regexShapeMatcher; + + public function __construct(RegexArrayShapeMatcher $regexShapeMatcher) + { + $this->regexShapeMatcher = $regexShapeMatcher; + } + + public function getNodeType(): string + { + return StaticCall::class; + } + + public function processNode(Node $node, Scope $scope): array + { + if (!$node->class instanceof FullyQualified) { + return []; + } + $isRegex = $node->class->toString() === Regex::class; + $isPreg = $node->class->toString() === Preg::class; + if (!$isRegex && !$isPreg) { + return []; + } + if (!$node->name instanceof Node\Identifier || !in_array($node->name->name, ['matchStrictGroups', 'isMatchStrictGroups', 'matchAllStrictGroups', 'isMatchAllStrictGroups'], true)) { + return []; + } + + $args = $node->getArgs(); + if (!isset($args[0])) { + return []; + } + + $patternArg = $args[0] ?? null; + if ($isPreg) { + if (!isset($args[2])) { // no matches set, skip as the matches won't be used anyway + return []; + } + $flagsArg = $args[3] ?? null; + } else { + $flagsArg = $args[2] ?? null; + } + + if ($patternArg === null) { + return []; + } + + $flagsType = PregMatchFlags::getType($flagsArg, $scope); + if ($flagsType === null) { + return []; + } + + $matchedType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createYes(), $scope); + if ($matchedType === null) { + return [ + RuleErrorBuilder::message(sprintf('The %s call is potentially unsafe as $matches\' type could not be inferred.', $node->name->name)) + ->identifier('composerPcre.maybeUnsafeStrictGroups') + ->build(), + ]; + } + + if (count($matchedType->getConstantArrays()) === 1) { + $matchedType = $matchedType->getConstantArrays()[0]; + $nullableGroups = []; + foreach ($matchedType->getValueTypes() as $index => $type) { + if (TypeCombinator::containsNull($type)) { + $nullableGroups[] = $matchedType->getKeyTypes()[$index]->getValue(); + } + } + + if (\count($nullableGroups) > 0) { + return [ + RuleErrorBuilder::message(sprintf( + 'The %s call is unsafe as match group%s "%s" %s optional and may be null.', + $node->name->name, + \count($nullableGroups) > 1 ? 's' : '', + implode('", "', $nullableGroups), + \count($nullableGroups) > 1 ? 'are' : 'is' + ))->identifier('composerPcre.unsafeStrictGroups')->build(), + ]; + } + } + + return []; + } +} diff --git a/vendor/composer/pcre/src/PcreException.php b/vendor/composer/pcre/src/PcreException.php new file mode 100644 index 0000000..23d9327 --- /dev/null +++ b/vendor/composer/pcre/src/PcreException.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +class PcreException extends \RuntimeException +{ + /** + * @param string $function + * @param string|string[] $pattern + * @return self + */ + public static function fromFunction($function, $pattern) + { + $code = preg_last_error(); + + if (is_array($pattern)) { + $pattern = implode(', ', $pattern); + } + + return new PcreException($function.'(): failed executing "'.$pattern.'": '.self::pcreLastErrorMessage($code), $code); + } + + /** + * @param int $code + * @return string + */ + private static function pcreLastErrorMessage($code) + { + if (function_exists('preg_last_error_msg')) { + return preg_last_error_msg(); + } + + $constants = get_defined_constants(true); + if (!isset($constants['pcre']) || !is_array($constants['pcre'])) { + return 'UNDEFINED_ERROR'; + } + + foreach ($constants['pcre'] as $const => $val) { + if ($val === $code && substr($const, -6) === '_ERROR') { + return $const; + } + } + + return 'UNDEFINED_ERROR'; + } +} diff --git a/vendor/composer/pcre/src/Preg.php b/vendor/composer/pcre/src/Preg.php new file mode 100644 index 0000000..400abbf --- /dev/null +++ b/vendor/composer/pcre/src/Preg.php @@ -0,0 +1,430 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +class Preg +{ + /** @internal */ + public const ARRAY_MSG = '$subject as an array is not supported. You can use \'foreach\' instead.'; + /** @internal */ + public const INVALID_TYPE_MSG = '$subject must be a string, %s given.'; + + /** + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * @return 0|1 + * + * @param-out array $matches + */ + public static function match(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int + { + self::checkOffsetCapture($flags, 'matchWithOffsets'); + + $result = preg_match($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset); + if ($result === false) { + throw PcreException::fromFunction('preg_match', $pattern); + } + + return $result; + } + + /** + * Variant of `match()` which outputs non-null matches (or throws) + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * @return 0|1 + * @throws UnexpectedNullMatchException + * + * @param-out array $matches + */ + public static function matchStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int + { + $result = self::match($pattern, $subject, $matchesInternal, $flags, $offset); + $matches = self::enforceNonNullMatches($pattern, $matchesInternal, 'match'); + + return $result; + } + + /** + * Runs preg_match with PREG_OFFSET_CAPTURE + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL and PREG_OFFSET_CAPTURE are always set, no other flags are supported + * @return 0|1 + * + * @param-out array}> $matches + */ + public static function matchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): int + { + $result = preg_match($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset); + if ($result === false) { + throw PcreException::fromFunction('preg_match', $pattern); + } + + return $result; + } + + /** + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * @return 0|positive-int + * + * @param-out array> $matches + */ + public static function matchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int + { + self::checkOffsetCapture($flags, 'matchAllWithOffsets'); + self::checkSetOrder($flags); + + $result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL, $offset); + if (!is_int($result)) { // PHP < 8 may return null, 8+ returns int|false + throw PcreException::fromFunction('preg_match_all', $pattern); + } + + return $result; + } + + /** + * Variant of `match()` which outputs non-null matches (or throws) + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * @return 0|positive-int + * @throws UnexpectedNullMatchException + * + * @param-out array> $matches + */ + public static function matchAllStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): int + { + $result = self::matchAll($pattern, $subject, $matchesInternal, $flags, $offset); + $matches = self::enforceNonNullMatchAll($pattern, $matchesInternal, 'matchAll'); + + return $result; + } + + /** + * Runs preg_match_all with PREG_OFFSET_CAPTURE + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported + * @return 0|positive-int + * + * @param-out array}>> $matches + */ + public static function matchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): int + { + self::checkSetOrder($flags); + + $result = preg_match_all($pattern, $subject, $matches, $flags | PREG_UNMATCHED_AS_NULL | PREG_OFFSET_CAPTURE, $offset); + if (!is_int($result)) { // PHP < 8 may return null, 8+ returns int|false + throw PcreException::fromFunction('preg_match_all', $pattern); + } + + return $result; + } + + /** + * @param string|string[] $pattern + * @param string|string[] $replacement + * @param string $subject + * @param int $count Set by method + * + * @param-out int<0, max> $count + */ + public static function replace($pattern, $replacement, $subject, int $limit = -1, ?int &$count = null): string + { + if (!is_scalar($subject)) { + if (is_array($subject)) { + throw new \InvalidArgumentException(static::ARRAY_MSG); + } + + throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject))); + } + + $result = preg_replace($pattern, $replacement, $subject, $limit, $count); + if ($result === null) { + throw PcreException::fromFunction('preg_replace', $pattern); + } + + return $result; + } + + /** + * @param string|string[] $pattern + * @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array}>): string) : callable(array): string) $replacement + * @param string $subject + * @param int $count Set by method + * @param int-mask $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set + * + * @param-out int<0, max> $count + */ + public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, ?int &$count = null, int $flags = 0): string + { + if (!is_scalar($subject)) { + if (is_array($subject)) { + throw new \InvalidArgumentException(static::ARRAY_MSG); + } + + throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject))); + } + + $result = preg_replace_callback($pattern, $replacement, $subject, $limit, $count, $flags | PREG_UNMATCHED_AS_NULL); + if ($result === null) { + throw PcreException::fromFunction('preg_replace_callback', $pattern); + } + + return $result; + } + + /** + * Variant of `replaceCallback()` which outputs non-null matches (or throws) + * + * @param string $pattern + * @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array}>): string) : callable(array): string) $replacement + * @param string $subject + * @param int $count Set by method + * @param int-mask $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set + * + * @param-out int<0, max> $count + */ + public static function replaceCallbackStrictGroups(string $pattern, callable $replacement, $subject, int $limit = -1, ?int &$count = null, int $flags = 0): string + { + return self::replaceCallback($pattern, function (array $matches) use ($pattern, $replacement) { + return $replacement(self::enforceNonNullMatches($pattern, $matches, 'replaceCallback')); + }, $subject, $limit, $count, $flags); + } + + /** + * @param ($flags is PREG_OFFSET_CAPTURE ? (array}>): string>) : array): string>) $pattern + * @param string $subject + * @param int $count Set by method + * @param int-mask $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set + * + * @param-out int<0, max> $count + */ + public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, ?int &$count = null, int $flags = 0): string + { + if (!is_scalar($subject)) { + if (is_array($subject)) { + throw new \InvalidArgumentException(static::ARRAY_MSG); + } + + throw new \TypeError(sprintf(static::INVALID_TYPE_MSG, gettype($subject))); + } + + $result = preg_replace_callback_array($pattern, $subject, $limit, $count, $flags | PREG_UNMATCHED_AS_NULL); + if ($result === null) { + $pattern = array_keys($pattern); + throw PcreException::fromFunction('preg_replace_callback_array', $pattern); + } + + return $result; + } + + /** + * @param int-mask $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE + * @return list + */ + public static function split(string $pattern, string $subject, int $limit = -1, int $flags = 0): array + { + if (($flags & PREG_SPLIT_OFFSET_CAPTURE) !== 0) { + throw new \InvalidArgumentException('PREG_SPLIT_OFFSET_CAPTURE is not supported as it changes the type of $matches, use splitWithOffsets() instead'); + } + + $result = preg_split($pattern, $subject, $limit, $flags); + if ($result === false) { + throw PcreException::fromFunction('preg_split', $pattern); + } + + return $result; + } + + /** + * @param int-mask $flags PREG_SPLIT_NO_EMPTY or PREG_SPLIT_DELIM_CAPTURE, PREG_SPLIT_OFFSET_CAPTURE is always set + * @return list + * @phpstan-return list}> + */ + public static function splitWithOffsets(string $pattern, string $subject, int $limit = -1, int $flags = 0): array + { + $result = preg_split($pattern, $subject, $limit, $flags | PREG_SPLIT_OFFSET_CAPTURE); + if ($result === false) { + throw PcreException::fromFunction('preg_split', $pattern); + } + + return $result; + } + + /** + * @template T of string|\Stringable + * @param string $pattern + * @param array $array + * @param int-mask $flags PREG_GREP_INVERT + * @return array + */ + public static function grep(string $pattern, array $array, int $flags = 0): array + { + $result = preg_grep($pattern, $array, $flags); + if ($result === false) { + throw PcreException::fromFunction('preg_grep', $pattern); + } + + return $result; + } + + /** + * Variant of match() which returns a bool instead of int + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * + * @param-out array $matches + */ + public static function isMatch(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool + { + return (bool) static::match($pattern, $subject, $matches, $flags, $offset); + } + + /** + * Variant of `isMatch()` which outputs non-null matches (or throws) + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * @throws UnexpectedNullMatchException + * + * @param-out array $matches + */ + public static function isMatchStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool + { + return (bool) self::matchStrictGroups($pattern, $subject, $matches, $flags, $offset); + } + + /** + * Variant of matchAll() which returns a bool instead of int + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * + * @param-out array> $matches + */ + public static function isMatchAll(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool + { + return (bool) static::matchAll($pattern, $subject, $matches, $flags, $offset); + } + + /** + * Variant of `isMatchAll()` which outputs non-null matches (or throws) + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * + * @param-out array> $matches + */ + public static function isMatchAllStrictGroups(string $pattern, string $subject, ?array &$matches = null, int $flags = 0, int $offset = 0): bool + { + return (bool) self::matchAllStrictGroups($pattern, $subject, $matches, $flags, $offset); + } + + /** + * Variant of matchWithOffsets() which returns a bool instead of int + * + * Runs preg_match with PREG_OFFSET_CAPTURE + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * + * @param-out array}> $matches + */ + public static function isMatchWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): bool + { + return (bool) static::matchWithOffsets($pattern, $subject, $matches, $flags, $offset); + } + + /** + * Variant of matchAllWithOffsets() which returns a bool instead of int + * + * Runs preg_match_all with PREG_OFFSET_CAPTURE + * + * @param non-empty-string $pattern + * @param array $matches Set by method + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * + * @param-out array}>> $matches + */ + public static function isMatchAllWithOffsets(string $pattern, string $subject, ?array &$matches, int $flags = 0, int $offset = 0): bool + { + return (bool) static::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset); + } + + private static function checkOffsetCapture(int $flags, string $useFunctionName): void + { + if (($flags & PREG_OFFSET_CAPTURE) !== 0) { + throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the type of $matches, use ' . $useFunctionName . '() instead'); + } + } + + private static function checkSetOrder(int $flags): void + { + if (($flags & PREG_SET_ORDER) !== 0) { + throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the type of $matches'); + } + } + + /** + * @param array $matches + * @return array + * @throws UnexpectedNullMatchException + */ + private static function enforceNonNullMatches(string $pattern, array $matches, string $variantMethod) + { + foreach ($matches as $group => $match) { + if (is_string($match) || (is_array($match) && is_string($match[0]))) { + continue; + } + + throw new UnexpectedNullMatchException('Pattern "'.$pattern.'" had an unexpected unmatched group "'.$group.'", make sure the pattern always matches or use '.$variantMethod.'() instead.'); + } + + /** @var array */ + return $matches; + } + + /** + * @param array> $matches + * @return array> + * @throws UnexpectedNullMatchException + */ + private static function enforceNonNullMatchAll(string $pattern, array $matches, string $variantMethod) + { + foreach ($matches as $group => $groupMatches) { + foreach ($groupMatches as $match) { + if (null === $match) { + throw new UnexpectedNullMatchException('Pattern "'.$pattern.'" had an unexpected unmatched group "'.$group.'", make sure the pattern always matches or use '.$variantMethod.'() instead.'); + } + } + } + + /** @var array> */ + return $matches; + } +} diff --git a/vendor/composer/pcre/src/Regex.php b/vendor/composer/pcre/src/Regex.php new file mode 100644 index 0000000..038cf06 --- /dev/null +++ b/vendor/composer/pcre/src/Regex.php @@ -0,0 +1,176 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +class Regex +{ + /** + * @param non-empty-string $pattern + */ + public static function isMatch(string $pattern, string $subject, int $offset = 0): bool + { + return (bool) Preg::match($pattern, $subject, $matches, 0, $offset); + } + + /** + * @param non-empty-string $pattern + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + */ + public static function match(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchResult + { + self::checkOffsetCapture($flags, 'matchWithOffsets'); + + $count = Preg::match($pattern, $subject, $matches, $flags, $offset); + + return new MatchResult($count, $matches); + } + + /** + * Variant of `match()` which returns non-null matches (or throws) + * + * @param non-empty-string $pattern + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * @throws UnexpectedNullMatchException + */ + public static function matchStrictGroups(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchStrictGroupsResult + { + // @phpstan-ignore composerPcre.maybeUnsafeStrictGroups + $count = Preg::matchStrictGroups($pattern, $subject, $matches, $flags, $offset); + + return new MatchStrictGroupsResult($count, $matches); + } + + /** + * Runs preg_match with PREG_OFFSET_CAPTURE + * + * @param non-empty-string $pattern + * @param int-mask $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported + */ + public static function matchWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchWithOffsetsResult + { + $count = Preg::matchWithOffsets($pattern, $subject, $matches, $flags, $offset); + + return new MatchWithOffsetsResult($count, $matches); + } + + /** + * @param non-empty-string $pattern + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + */ + public static function matchAll(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllResult + { + self::checkOffsetCapture($flags, 'matchAllWithOffsets'); + self::checkSetOrder($flags); + + $count = Preg::matchAll($pattern, $subject, $matches, $flags, $offset); + + return new MatchAllResult($count, $matches); + } + + /** + * Variant of `matchAll()` which returns non-null matches (or throws) + * + * @param non-empty-string $pattern + * @param int-mask $flags PREG_UNMATCHED_AS_NULL is always set, no other flags are supported + * @throws UnexpectedNullMatchException + */ + public static function matchAllStrictGroups(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllStrictGroupsResult + { + self::checkOffsetCapture($flags, 'matchAllWithOffsets'); + self::checkSetOrder($flags); + + // @phpstan-ignore composerPcre.maybeUnsafeStrictGroups + $count = Preg::matchAllStrictGroups($pattern, $subject, $matches, $flags, $offset); + + return new MatchAllStrictGroupsResult($count, $matches); + } + + /** + * Runs preg_match_all with PREG_OFFSET_CAPTURE + * + * @param non-empty-string $pattern + * @param int-mask $flags PREG_UNMATCHED_AS_NULL and PREG_MATCH_OFFSET are always set, no other flags are supported + */ + public static function matchAllWithOffsets(string $pattern, string $subject, int $flags = 0, int $offset = 0): MatchAllWithOffsetsResult + { + self::checkSetOrder($flags); + + $count = Preg::matchAllWithOffsets($pattern, $subject, $matches, $flags, $offset); + + return new MatchAllWithOffsetsResult($count, $matches); + } + /** + * @param string|string[] $pattern + * @param string|string[] $replacement + * @param string $subject + */ + public static function replace($pattern, $replacement, $subject, int $limit = -1): ReplaceResult + { + $result = Preg::replace($pattern, $replacement, $subject, $limit, $count); + + return new ReplaceResult($count, $result); + } + + /** + * @param string|string[] $pattern + * @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array}>): string) : callable(array): string) $replacement + * @param string $subject + * @param int-mask $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set + */ + public static function replaceCallback($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0): ReplaceResult + { + $result = Preg::replaceCallback($pattern, $replacement, $subject, $limit, $count, $flags); + + return new ReplaceResult($count, $result); + } + + /** + * Variant of `replaceCallback()` which outputs non-null matches (or throws) + * + * @param string $pattern + * @param ($flags is PREG_OFFSET_CAPTURE ? (callable(array}>): string) : callable(array): string) $replacement + * @param string $subject + * @param int-mask $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set + */ + public static function replaceCallbackStrictGroups($pattern, callable $replacement, $subject, int $limit = -1, int $flags = 0): ReplaceResult + { + $result = Preg::replaceCallbackStrictGroups($pattern, $replacement, $subject, $limit, $count, $flags); + + return new ReplaceResult($count, $result); + } + + /** + * @param ($flags is PREG_OFFSET_CAPTURE ? (array}>): string>) : array): string>) $pattern + * @param string $subject + * @param int-mask $flags PREG_OFFSET_CAPTURE is supported, PREG_UNMATCHED_AS_NULL is always set + */ + public static function replaceCallbackArray(array $pattern, $subject, int $limit = -1, int $flags = 0): ReplaceResult + { + $result = Preg::replaceCallbackArray($pattern, $subject, $limit, $count, $flags); + + return new ReplaceResult($count, $result); + } + + private static function checkOffsetCapture(int $flags, string $useFunctionName): void + { + if (($flags & PREG_OFFSET_CAPTURE) !== 0) { + throw new \InvalidArgumentException('PREG_OFFSET_CAPTURE is not supported as it changes the return type, use '.$useFunctionName.'() instead'); + } + } + + private static function checkSetOrder(int $flags): void + { + if (($flags & PREG_SET_ORDER) !== 0) { + throw new \InvalidArgumentException('PREG_SET_ORDER is not supported as it changes the return type'); + } + } +} diff --git a/vendor/composer/pcre/src/ReplaceResult.php b/vendor/composer/pcre/src/ReplaceResult.php new file mode 100644 index 0000000..3384771 --- /dev/null +++ b/vendor/composer/pcre/src/ReplaceResult.php @@ -0,0 +1,43 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +final class ReplaceResult +{ + /** + * @readonly + * @var string + */ + public $result; + + /** + * @readonly + * @var 0|positive-int + */ + public $count; + + /** + * @readonly + * @var bool + */ + public $matched; + + /** + * @param 0|positive-int $count + */ + public function __construct(int $count, string $result) + { + $this->count = $count; + $this->matched = (bool) $count; + $this->result = $result; + } +} diff --git a/vendor/composer/pcre/src/UnexpectedNullMatchException.php b/vendor/composer/pcre/src/UnexpectedNullMatchException.php new file mode 100644 index 0000000..f123828 --- /dev/null +++ b/vendor/composer/pcre/src/UnexpectedNullMatchException.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view + * the LICENSE file that was distributed with this source code. + */ + +namespace Composer\Pcre; + +class UnexpectedNullMatchException extends PcreException +{ + public static function fromFunction($function, $pattern) + { + throw new \LogicException('fromFunction should not be called on '.self::class.', use '.PcreException::class); + } +} diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php new file mode 100644 index 0000000..580fa96 --- /dev/null +++ b/vendor/composer/platform_check.php @@ -0,0 +1,26 @@ += 70400)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 7.4.0". You are running ' . PHP_VERSION . '.'; +} + +if ($issues) { + if (!headers_sent()) { + header('HTTP/1.1 500 Internal Server Error'); + } + if (!ini_get('display_errors')) { + if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { + fwrite(STDERR, 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . implode(PHP_EOL, $issues) . PHP_EOL.PHP_EOL); + } elseif (!headers_sent()) { + echo 'Composer detected issues in your platform:' . PHP_EOL.PHP_EOL . str_replace('You are running '.PHP_VERSION.'.', '', implode(PHP_EOL, $issues)) . PHP_EOL.PHP_EOL; + } + } + trigger_error( + 'Composer detected issues in your platform: ' . implode(' ', $issues), + E_USER_ERROR + ); +} diff --git a/vendor/easywechat-composer/easywechat-composer/.gitignore b/vendor/easywechat-composer/easywechat-composer/.gitignore new file mode 100644 index 0000000..c7a0a65 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/.gitignore @@ -0,0 +1,5 @@ +.idea/ +/vendor +composer.lock +extensions.php +.php_cs.cache diff --git a/vendor/easywechat-composer/easywechat-composer/.php_cs b/vendor/easywechat-composer/easywechat-composer/.php_cs new file mode 100644 index 0000000..d256932 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/.php_cs @@ -0,0 +1,29 @@ + + +This source file is subject to the MIT license that is bundled +with this source code in the file LICENSE. +EOF; + +return PhpCsFixer\Config::create() + ->setRiskyAllowed(true) + ->setRules([ + '@Symfony' => true, + 'header_comment' => ['header' => $header], + 'declare_strict_types' => true, + 'ordered_imports' => true, + 'strict_comparison' => true, + 'no_empty_comment' => false, + 'yoda_style' => false, + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->notPath('src/Laravel/config.php', 'src/Laravel/routes.php') + ->in(__DIR__) + ) +; diff --git a/vendor/easywechat-composer/easywechat-composer/.travis.yml b/vendor/easywechat-composer/easywechat-composer/.travis.yml new file mode 100644 index 0000000..e819807 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/.travis.yml @@ -0,0 +1,12 @@ +language: php + +php: + - 7.0 + - 7.1 + - 7.2 + - 7.3 + +install: + - travis_retry composer install --no-interaction --no-suggest + +script: ./vendor/bin/phpunit diff --git a/vendor/easywechat-composer/easywechat-composer/LICENSE b/vendor/easywechat-composer/easywechat-composer/LICENSE new file mode 100644 index 0000000..3559904 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 张铭阳 + +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. diff --git a/vendor/easywechat-composer/easywechat-composer/README.md b/vendor/easywechat-composer/easywechat-composer/README.md new file mode 100644 index 0000000..a08c1be --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/README.md @@ -0,0 +1,55 @@ +

+

EasyWeChat Composer Plugin

+

+ +

+ Build Status + Scrutinizer Code Quality + Latest Stable Version + Total Downloads + License +

+ +Usage +--- + +Set the `type` to be `easywechat-extension` in your package composer.json file: + +```json +{ + "name": "your/package", + "type": "easywechat-extension" +} +``` + +Specify server observer classes in the extra section: + +```json +{ + "name": "your/package", + "type": "easywechat-extension", + "extra": { + "observers": [ + "Acme\\Observers\\Handler" + ] + } +} +``` + +Examples +--- +* [easywechat-composer/open-platform-testcase](https://github.com/mingyoung/open-platform-testcase) + +Server Delegation +--- + +> 目前仅支持 Laravel + +1. 在 `config/app.php` 中添加 `EasyWeChatComposer\Laravel\ServiceProvider::class` + +2. 在**本地项目**的 `.env` 文件中添加如下配置: + +``` +EASYWECHAT_DELEGATION=true # false 则不启用 +EASYWECHAT_DELEGATION_HOST=https://example.com # 线上域名 +``` diff --git a/vendor/easywechat-composer/easywechat-composer/composer.json b/vendor/easywechat-composer/easywechat-composer/composer.json new file mode 100644 index 0000000..32d7c94 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/composer.json @@ -0,0 +1,35 @@ +{ + "name": "easywechat-composer/easywechat-composer", + "description": "The composer plugin for EasyWeChat", + "type": "composer-plugin", + "license": "MIT", + "authors": [ + { + "name": "张铭阳", + "email": "mingyoungcheung@gmail.com" + } + ], + "require": { + "php": ">=7.0", + "composer-plugin-api": "^1.0 || ^2.0" + }, + "require-dev": { + "composer/composer": "^1.0 || ^2.0", + "phpunit/phpunit": "^6.5 || ^7.0" + }, + "autoload": { + "psr-4": { + "EasyWeChatComposer\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "EasyWeChatComposer\\Tests\\": "tests/" + } + }, + "extra": { + "class": "EasyWeChatComposer\\Plugin" + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/vendor/easywechat-composer/easywechat-composer/phpunit.xml b/vendor/easywechat-composer/easywechat-composer/phpunit.xml new file mode 100644 index 0000000..361d92c --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/phpunit.xml @@ -0,0 +1,20 @@ + + + + tests + + + + + src + + + diff --git a/vendor/easywechat-composer/easywechat-composer/src/Commands/ExtensionsCommand.php b/vendor/easywechat-composer/easywechat-composer/src/Commands/ExtensionsCommand.php new file mode 100644 index 0000000..bc0155e --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Commands/ExtensionsCommand.php @@ -0,0 +1,63 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Commands; + +use Composer\Command\BaseCommand; +use Symfony\Component\Console\Helper\Table; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +class ExtensionsCommand extends BaseCommand +{ + /** + * Configures the current command. + */ + protected function configure() + { + $this->setName('easywechat:extensions') + ->setDescription('Lists all installed extensions.'); + } + + /** + * Executes the current command. + * + * @param InputInterface $input + * @param OutputInterface $output + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $extensions = require __DIR__.'/../../extensions.php'; + + if (empty($extensions) || !is_array($extensions)) { + return $output->writeln('No extension installed.'); + } + + $table = new Table($output); + $table->setHeaders(['Name', 'Observers']) + ->setRows( + array_map([$this, 'getRows'], array_keys($extensions), $extensions) + )->render(); + } + + /** + * @param string $name + * @param array $extension + * + * @return array + */ + protected function getRows($name, $extension) + { + return [$name, implode("\n", $extension['observers'] ?? [])]; + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Commands/Provider.php b/vendor/easywechat-composer/easywechat-composer/src/Commands/Provider.php new file mode 100644 index 0000000..928f096 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Commands/Provider.php @@ -0,0 +1,31 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Commands; + +use Composer\Plugin\Capability\CommandProvider; + +class Provider implements CommandProvider +{ + /** + * Retrieves an array of commands. + * + * @return \Composer\Command\BaseCommand[] + */ + public function getCommands() + { + return [ + new ExtensionsCommand(), + ]; + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Contracts/Encrypter.php b/vendor/easywechat-composer/easywechat-composer/src/Contracts/Encrypter.php new file mode 100644 index 0000000..af8b8d1 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Contracts/Encrypter.php @@ -0,0 +1,35 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Contracts; + +interface Encrypter +{ + /** + * Encrypt the given value. + * + * @param string $value + * + * @return string + */ + public function encrypt($value); + + /** + * Decrypt the given value. + * + * @param string $payload + * + * @return string + */ + public function decrypt($payload); +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Delegation/DelegationOptions.php b/vendor/easywechat-composer/easywechat-composer/src/Delegation/DelegationOptions.php new file mode 100644 index 0000000..a333261 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Delegation/DelegationOptions.php @@ -0,0 +1,80 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Delegation; + +use EasyWeChatComposer\EasyWeChat; + +class DelegationOptions +{ + /** + * @var array + */ + protected $config = [ + 'enabled' => false, + ]; + + /** + * @return $this + */ + public function enable() + { + $this->config['enabled'] = true; + + return $this; + } + + /** + * @return $this + */ + public function disable() + { + $this->config['enabled'] = false; + + return $this; + } + + /** + * @param bool $ability + * + * @return $this + */ + public function ability($ability) + { + $this->config['enabled'] = (bool) $ability; + + return $this; + } + + /** + * @param string $host + * + * @return $this + */ + public function toHost($host) + { + $this->config['host'] = $host; + + return $this; + } + + /** + * Destructor. + */ + public function __destruct() + { + EasyWeChat::mergeConfig([ + 'delegation' => $this->config, + ]); + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Delegation/DelegationTo.php b/vendor/easywechat-composer/easywechat-composer/src/Delegation/DelegationTo.php new file mode 100644 index 0000000..2e9e6db --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Delegation/DelegationTo.php @@ -0,0 +1,83 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Delegation; + +use EasyWeChatComposer\Traits\MakesHttpRequests; + +class DelegationTo +{ + use MakesHttpRequests; + + /** + * @var \EasyWeChat\Kernel\ServiceContainer + */ + protected $app; + + /** + * @var array + */ + protected $identifiers = []; + + /** + * @param \EasyWeChat\Kernel\ServiceContainer $app + * @param string $identifier + */ + public function __construct($app, $identifier) + { + $this->app = $app; + + $this->push($identifier); + } + + /** + * @param string $identifier + */ + public function push($identifier) + { + $this->identifiers[] = $identifier; + } + + /** + * @param string $identifier + * + * @return $this + */ + public function __get($identifier) + { + $this->push($identifier); + + return $this; + } + + /** + * @param string $method + * @param array $arguments + * + * @return mixed + */ + public function __call($method, $arguments) + { + $config = array_intersect_key($this->app->getConfig(), array_flip(['app_id', 'secret', 'token', 'aes_key', 'response_type', 'component_app_id', 'refresh_token'])); + + $data = [ + 'config' => $config, + 'application' => get_class($this->app), + 'identifiers' => $this->identifiers, + 'method' => $method, + 'arguments' => $arguments, + ]; + + return $this->request('easywechat-composer/delegate', $data); + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Delegation/Hydrate.php b/vendor/easywechat-composer/easywechat-composer/src/Delegation/Hydrate.php new file mode 100644 index 0000000..b83bbe9 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Delegation/Hydrate.php @@ -0,0 +1,83 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Delegation; + +use EasyWeChat; +use EasyWeChatComposer\Http\DelegationResponse; + +class Hydrate +{ + /** + * @var array + */ + protected $attributes; + + /** + * @param array $attributes + */ + public function __construct(array $attributes) + { + $this->attributes = $attributes; + } + + /** + * @return array + */ + public function handle() + { + $app = $this->createsApplication()->shouldntDelegate(); + + foreach ($this->attributes['identifiers'] as $identifier) { + $app = $app->$identifier; + } + + return call_user_func_array([$app, $this->attributes['method']], $this->attributes['arguments']); + } + + /** + * @return \EasyWeChat\Kernel\ServiceContainer + */ + protected function createsApplication() + { + $application = $this->attributes['application']; + + if ($application === EasyWeChat\OpenPlatform\Authorizer\OfficialAccount\Application::class) { + return $this->createsOpenPlatformApplication('officialAccount'); + } + + if ($application === EasyWeChat\OpenPlatform\Authorizer\MiniProgram\Application::class) { + return $this->createsOpenPlatformApplication('miniProgram'); + } + + return new $application($this->buildConfig($this->attributes['config'])); + } + + protected function createsOpenPlatformApplication($type) + { + $config = $this->attributes['config']; + + $authorizerAppId = $config['app_id']; + + $config['app_id'] = $config['component_app_id']; + + return EasyWeChat\Factory::openPlatform($this->buildConfig($config))->$type($authorizerAppId, $config['refresh_token']); + } + + protected function buildConfig(array $config) + { + $config['response_type'] = DelegationResponse::class; + + return $config; + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/EasyWeChat.php b/vendor/easywechat-composer/easywechat-composer/src/EasyWeChat.php new file mode 100644 index 0000000..4ff3d9b --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/EasyWeChat.php @@ -0,0 +1,79 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer; + +use EasyWeChatComposer\Delegation\DelegationOptions; + +class EasyWeChat +{ + /** + * @var array + */ + protected static $config = []; + + /** + * Encryption key. + * + * @var string + */ + protected static $encryptionKey; + + /** + * @param array $config + */ + public static function mergeConfig(array $config) + { + static::$config = array_merge(static::$config, $config); + } + + /** + * @return array + */ + public static function config() + { + return static::$config; + } + + /** + * Set encryption key. + * + * @param string $key + * + * @return static + */ + public static function setEncryptionKey(string $key) + { + static::$encryptionKey = $key; + + return new static(); + } + + /** + * Get encryption key. + * + * @return string + */ + public static function getEncryptionKey(): string + { + return static::$encryptionKey; + } + + /** + * @return \EasyWeChatComposer\Delegation\DelegationOptions + */ + public static function withDelegation() + { + return new DelegationOptions(); + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Encryption/DefaultEncrypter.php b/vendor/easywechat-composer/easywechat-composer/src/Encryption/DefaultEncrypter.php new file mode 100644 index 0000000..2c4cd53 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Encryption/DefaultEncrypter.php @@ -0,0 +1,89 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Encryption; + +use EasyWeChatComposer\Contracts\Encrypter; +use EasyWeChatComposer\Exceptions\DecryptException; +use EasyWeChatComposer\Exceptions\EncryptException; + +class DefaultEncrypter implements Encrypter +{ + /** + * @var string + */ + protected $key; + + /** + * @var string + */ + protected $cipher; + + /** + * @param string $key + * @param string $cipher + */ + public function __construct($key, $cipher = 'AES-256-CBC') + { + $this->key = $key; + $this->cipher = $cipher; + } + + /** + * Encrypt the given value. + * + * @param string $value + * + * @return string + * + * @throws \EasyWeChatComposer\Exceptions\EncryptException + */ + public function encrypt($value) + { + $iv = random_bytes(openssl_cipher_iv_length($this->cipher)); + + $value = openssl_encrypt($value, $this->cipher, $this->key, 0, $iv); + + if ($value === false) { + throw new EncryptException('Could not encrypt the data.'); + } + + $iv = base64_encode($iv); + + return base64_encode(json_encode(compact('iv', 'value'))); + } + + /** + * Decrypt the given value. + * + * @param string $payload + * + * @return string + * + * @throws \EasyWeChatComposer\Exceptions\DecryptException + */ + public function decrypt($payload) + { + $payload = json_decode(base64_decode($payload), true); + + $iv = base64_decode($payload['iv']); + + $decrypted = openssl_decrypt($payload['value'], $this->cipher, $this->key, 0, $iv); + + if ($decrypted === false) { + throw new DecryptException('Could not decrypt the data.'); + } + + return $decrypted; + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Exceptions/DecryptException.php b/vendor/easywechat-composer/easywechat-composer/src/Exceptions/DecryptException.php new file mode 100644 index 0000000..e210d1f --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Exceptions/DecryptException.php @@ -0,0 +1,21 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Exceptions; + +use Exception; + +class DecryptException extends Exception +{ + // +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Exceptions/DelegationException.php b/vendor/easywechat-composer/easywechat-composer/src/Exceptions/DelegationException.php new file mode 100644 index 0000000..0af9c2d --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Exceptions/DelegationException.php @@ -0,0 +1,42 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Exceptions; + +use Exception; + +class DelegationException extends Exception +{ + /** + * @var string + */ + protected $exception; + + /** + * @param string $exception + */ + public function setException($exception) + { + $this->exception = $exception; + + return $this; + } + + /** + * @return string + */ + public function getException() + { + return $this->exception; + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Exceptions/EncryptException.php b/vendor/easywechat-composer/easywechat-composer/src/Exceptions/EncryptException.php new file mode 100644 index 0000000..f88f8f4 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Exceptions/EncryptException.php @@ -0,0 +1,21 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Exceptions; + +use Exception; + +class EncryptException extends Exception +{ + // +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Extension.php b/vendor/easywechat-composer/easywechat-composer/src/Extension.php new file mode 100644 index 0000000..6a521d1 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Extension.php @@ -0,0 +1,143 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer; + +use EasyWeChat\Kernel\Contracts\EventHandlerInterface; +use Pimple\Container; +use ReflectionClass; + +class Extension +{ + /** + * @var \Pimple\Container + */ + protected $app; + + /** + * @var string + */ + protected $manifestPath; + + /** + * @var array|null + */ + protected $manifest; + + /** + * @param \Pimple\Container $app + */ + public function __construct(Container $app) + { + $this->app = $app; + $this->manifestPath = __DIR__.'/../extensions.php'; + } + + /** + * Get observers. + * + * @return array + */ + public function observers(): array + { + if ($this->shouldIgnore()) { + return []; + } + + $observers = []; + + foreach ($this->getManifest() as $name => $extra) { + $observers = array_merge($observers, $extra['observers'] ?? []); + } + + return array_map([$this, 'listObserver'], array_filter($observers, [$this, 'validateObserver'])); + } + + /** + * @param mixed $observer + * + * @return bool + */ + protected function isDisable($observer): bool + { + return in_array($observer, $this->app->config->get('disable_observers', [])); + } + + /** + * Get the observers should be ignore. + * + * @return bool + */ + protected function shouldIgnore(): bool + { + return !file_exists($this->manifestPath) || $this->isDisable('*'); + } + + /** + * Validate the given observer. + * + * @param mixed $observer + * + * @return bool + * + * @throws \ReflectionException + */ + protected function validateObserver($observer): bool + { + return !$this->isDisable($observer) + && (new ReflectionClass($observer))->implementsInterface(EventHandlerInterface::class) + && $this->accessible($observer); + } + + /** + * Determine whether the given observer is accessible. + * + * @param string $observer + * + * @return bool + */ + protected function accessible($observer): bool + { + if (!method_exists($observer, 'getAccessor')) { + return true; + } + + return in_array(get_class($this->app), (array) $observer::getAccessor()); + } + + /** + * @param mixed $observer + * + * @return array + */ + protected function listObserver($observer): array + { + $condition = method_exists($observer, 'onCondition') ? $observer::onCondition() : '*'; + + return [$observer, $condition]; + } + + /** + * Get the easywechat manifest. + * + * @return array + */ + protected function getManifest(): array + { + if (!is_null($this->manifest)) { + return $this->manifest; + } + + return $this->manifest = file_exists($this->manifestPath) ? require $this->manifestPath : []; + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Http/DelegationResponse.php b/vendor/easywechat-composer/easywechat-composer/src/Http/DelegationResponse.php new file mode 100644 index 0000000..329eb54 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Http/DelegationResponse.php @@ -0,0 +1,25 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Http; + +class DelegationResponse extends Response +{ + /** + * @return string + */ + public function getBodyContents() + { + return $this->response->getBodyContents(); + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Http/Response.php b/vendor/easywechat-composer/easywechat-composer/src/Http/Response.php new file mode 100644 index 0000000..534bf54 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Http/Response.php @@ -0,0 +1,104 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Http; + +use EasyWeChat\Kernel\Contracts\Arrayable; +use EasyWeChat\Kernel\Http\Response as HttpResponse; +use JsonSerializable; + +class Response implements Arrayable, JsonSerializable +{ + /** + * @var \EasyWeChat\Kernel\Http\Response + */ + protected $response; + + /** + * @var array + */ + protected $array; + + /** + * @param \EasyWeChat\Kernel\Http\Response $response + */ + public function __construct(HttpResponse $response) + { + $this->response = $response; + } + + /** + * @see \ArrayAccess::offsetExists + * + * @param string $offset + * + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->toArray()[$offset]); + } + + /** + * @see \ArrayAccess::offsetGet + * + * @param string $offset + * + * @return mixed + */ + public function offsetGet($offset) + { + return $this->toArray()[$offset] ?? null; + } + + /** + * @see \ArrayAccess::offsetSet + * + * @param string $offset + * @param mixed $value + */ + public function offsetSet($offset, $value) + { + // + } + + /** + * @see \ArrayAccess::offsetUnset + * + * @param string $offset + */ + public function offsetUnset($offset) + { + // + } + + /** + * Get the instance as an array. + * + * @return array + */ + public function toArray() + { + return $this->array ?: $this->array = $this->response->toArray(); + } + + /** + * Convert the object into something JSON serializable. + * + * @return array + */ + public function jsonSerialize() + { + return $this->toArray(); + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Laravel/Http/Controllers/DelegatesController.php b/vendor/easywechat-composer/easywechat-composer/src/Laravel/Http/Controllers/DelegatesController.php new file mode 100644 index 0000000..ad014d8 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Laravel/Http/Controllers/DelegatesController.php @@ -0,0 +1,49 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Laravel\Http\Controllers; + +use EasyWeChatComposer\Delegation\Hydrate; +use EasyWeChatComposer\Encryption\DefaultEncrypter; +use Illuminate\Http\Request; +use Throwable; + +class DelegatesController +{ + /** + * @param \Illuminate\Http\Request $request + * @param \EasyWeChatComposer\Encryption\DefaultEncrypter $encrypter + * + * @return \Illuminate\Http\Response + */ + public function __invoke(Request $request, DefaultEncrypter $encrypter) + { + try { + $data = json_decode($encrypter->decrypt($request->get('encrypted')), true); + + $hydrate = new Hydrate($data); + + $response = $hydrate->handle(); + + return response()->json([ + 'response_type' => get_class($response), + 'response' => $encrypter->encrypt($response->getBodyContents()), + ]); + } catch (Throwable $t) { + return [ + 'exception' => get_class($t), + 'message' => $t->getMessage(), + ]; + } + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Laravel/ServiceProvider.php b/vendor/easywechat-composer/easywechat-composer/src/Laravel/ServiceProvider.php new file mode 100644 index 0000000..4c43b04 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Laravel/ServiceProvider.php @@ -0,0 +1,116 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Laravel; + +use EasyWeChatComposer\EasyWeChat; +use EasyWeChatComposer\Encryption\DefaultEncrypter; +use Illuminate\Foundation\Application; +use Illuminate\Support\Arr; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Route; +use Illuminate\Support\ServiceProvider as LaravelServiceProvider; +use RuntimeException; + +class ServiceProvider extends LaravelServiceProvider +{ + /** + * Bootstrap any application services. + */ + public function boot() + { + $this->registerRoutes(); + $this->publishes([ + __DIR__.'/config.php' => config_path('easywechat-composer.php'), + ]); + + EasyWeChat::setEncryptionKey( + $defaultKey = $this->getKey() + ); + + EasyWeChat::withDelegation() + ->toHost($this->config('delegation.host')) + ->ability($this->config('delegation.enabled')); + + $this->app->when(DefaultEncrypter::class)->needs('$key')->give($defaultKey); + } + + /** + * Register routes. + */ + protected function registerRoutes() + { + Route::prefix('easywechat-composer')->namespace('EasyWeChatComposer\Laravel\Http\Controllers')->group(function () { + $this->loadRoutesFrom(__DIR__.'/routes.php'); + }); + } + + /** + * Register any application services. + */ + public function register() + { + $this->configure(); + } + + /** + * Register config. + */ + protected function configure() + { + $this->mergeConfigFrom( + __DIR__.'/config.php', 'easywechat-composer' + ); + } + + /** + * Get the specified configuration value. + * + * @param string|null $key + * @param mixed $default + * + * @return mixed + */ + protected function config($key = null, $default = null) + { + $config = $this->app['config']->get('easywechat-composer'); + + if (is_null($key)) { + return $config; + } + + return Arr::get($config, $key, $default); + } + + /** + * @return string + */ + protected function getKey() + { + return $this->config('encryption.key') ?: $this->getMd5Key(); + } + + /** + * @return string + */ + protected function getMd5Key() + { + $ttl = (version_compare(Application::VERSION, '5.8') === -1) ? 30 : 1800; + + return Cache::remember('easywechat-composer.encryption_key', $ttl, function () { + throw_unless(file_exists($path = base_path('composer.lock')), RuntimeException::class, 'No encryption key provided.'); + + return md5_file($path); + }); + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Laravel/config.php b/vendor/easywechat-composer/easywechat-composer/src/Laravel/config.php new file mode 100644 index 0000000..5deabef --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Laravel/config.php @@ -0,0 +1,29 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +return [ + + 'encryption' => [ + + 'key' => env('EASYWECHAT_KEY'), + + ], + + 'delegation' => [ + + 'enabled' => env('EASYWECHAT_DELEGATION', false), + + 'host' => env('EASYWECHAT_DELEGATION_HOST'), + ], + +]; diff --git a/vendor/easywechat-composer/easywechat-composer/src/Laravel/routes.php b/vendor/easywechat-composer/easywechat-composer/src/Laravel/routes.php new file mode 100644 index 0000000..6a3041a --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Laravel/routes.php @@ -0,0 +1,16 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +use Illuminate\Support\Facades\Route; + +Route::post('delegate', 'DelegatesController'); diff --git a/vendor/easywechat-composer/easywechat-composer/src/ManifestManager.php b/vendor/easywechat-composer/easywechat-composer/src/ManifestManager.php new file mode 100644 index 0000000..e1af69c --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/ManifestManager.php @@ -0,0 +1,127 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer; + +use Composer\Plugin\PluginInterface; + +class ManifestManager +{ + const PACKAGE_TYPE = 'easywechat-extension'; + + const EXTRA_OBSERVER = 'observers'; + + /** + * The vendor path. + * + * @var string + */ + protected $vendorPath; + + /** + * The manifest path. + * + * @var string + */ + protected $manifestPath; + + /** + * @param string $vendorPath + * @param string|null $manifestPath + */ + public function __construct(string $vendorPath, string $manifestPath = null) + { + $this->vendorPath = $vendorPath; + $this->manifestPath = $manifestPath ?: $vendorPath.'/easywechat-composer/easywechat-composer/extensions.php'; + } + + /** + * Remove manifest file. + * + * @return $this + */ + public function unlink() + { + if (file_exists($this->manifestPath)) { + @unlink($this->manifestPath); + } + + return $this; + } + + /** + * Build the manifest file. + */ + public function build() + { + $packages = []; + + if (file_exists($installed = $this->vendorPath.'/composer/installed.json')) { + $packages = json_decode(file_get_contents($installed), true); + if (version_compare(PluginInterface::PLUGIN_API_VERSION, '2.0.0', 'ge')) { + $packages = $packages['packages']; + } + } + + $this->write($this->map($packages)); + } + + /** + * @param array $packages + * + * @return array + */ + protected function map(array $packages): array + { + $manifest = []; + + $packages = array_filter($packages, function ($package) { + if(isset($package['type'])){ + return $package['type'] === self::PACKAGE_TYPE; + } + }); + + foreach ($packages as $package) { + $manifest[$package['name']] = [self::EXTRA_OBSERVER => $package['extra'][self::EXTRA_OBSERVER] ?? []]; + } + + return $manifest; + } + + /** + * Write the manifest array to a file. + * + * @param array $manifest + */ + protected function write(array $manifest) + { + file_put_contents( + $this->manifestPath, + 'invalidate($this->manifestPath); + } + + /** + * Invalidate the given file. + * + * @param string $file + */ + protected function invalidate($file) + { + if (function_exists('opcache_invalidate')) { + @opcache_invalidate($file, true); + } + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Plugin.php b/vendor/easywechat-composer/easywechat-composer/src/Plugin.php new file mode 100644 index 0000000..cd9e504 --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Plugin.php @@ -0,0 +1,107 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer; + +use Composer\Composer; +use Composer\EventDispatcher\EventSubscriberInterface; +use Composer\Installer\PackageEvent; +use Composer\Installer\PackageEvents; +use Composer\IO\IOInterface; +use Composer\Plugin\Capable; +use Composer\Plugin\PluginInterface; +use Composer\Script\Event; +use Composer\Script\ScriptEvents; + +class Plugin implements PluginInterface, EventSubscriberInterface, Capable +{ + /** + * @var bool + */ + protected $activated = true; + + /** + * Apply plugin modifications to Composer. + */ + public function activate(Composer $composer, IOInterface $io) + { + // + } + + /** + * Remove any hooks from Composer. + * + * This will be called when a plugin is deactivated before being + * uninstalled, but also before it gets upgraded to a new version + * so the old one can be deactivated and the new one activated. + */ + public function deactivate(Composer $composer, IOInterface $io) + { + // + } + + /** + * Prepare the plugin to be uninstalled. + * + * This will be called after deactivate. + */ + public function uninstall(Composer $composer, IOInterface $io) + { + } + + /** + * @return array + */ + public function getCapabilities() + { + return [ + 'Composer\Plugin\Capability\CommandProvider' => 'EasyWeChatComposer\Commands\Provider', + ]; + } + + /** + * Listen events. + * + * @return array + */ + public static function getSubscribedEvents() + { + return [ + PackageEvents::PRE_PACKAGE_UNINSTALL => 'prePackageUninstall', + ScriptEvents::POST_AUTOLOAD_DUMP => 'postAutoloadDump', + ]; + } + + /** + * @param \Composer\Installer\PackageEvent + */ + public function prePackageUninstall(PackageEvent $event) + { + if ($event->getOperation()->getPackage()->getName() === 'overtrue/wechat') { + $this->activated = false; + } + } + + public function postAutoloadDump(Event $event) + { + if (!$this->activated) { + return; + } + + $manifest = new ManifestManager( + rtrim($event->getComposer()->getConfig()->get('vendor-dir'), '/') + ); + + $manifest->unlink()->build(); + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Traits/MakesHttpRequests.php b/vendor/easywechat-composer/easywechat-composer/src/Traits/MakesHttpRequests.php new file mode 100644 index 0000000..091a75c --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Traits/MakesHttpRequests.php @@ -0,0 +1,110 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Traits; + +use EasyWeChat\Kernel\Http\StreamResponse; +use EasyWeChat\Kernel\Traits\ResponseCastable; +use EasyWeChatComposer\Contracts\Encrypter; +use EasyWeChatComposer\EasyWeChat; +use EasyWeChatComposer\Encryption\DefaultEncrypter; +use EasyWeChatComposer\Exceptions\DelegationException; +use GuzzleHttp\Client; +use GuzzleHttp\ClientInterface; + +trait MakesHttpRequests +{ + use ResponseCastable; + + /** + * @var \GuzzleHttp\ClientInterface + */ + protected $httpClient; + + /** + * @var \EasyWeChatComposer\Contracts\Encrypter + */ + protected $encrypter; + + /** + * @param string $endpoint + * @param array $payload + * + * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string + * + * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException + * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException + * @throws \GuzzleHttp\Exception\GuzzleException + */ + protected function request($endpoint, array $payload) + { + $response = $this->getHttpClient()->request('POST', $endpoint, [ + 'form_params' => $this->buildFormParams($payload), + ]); + + $parsed = $this->parseResponse($response); + + return $this->detectAndCastResponseToType( + $this->getEncrypter()->decrypt($parsed['response']), + ($parsed['response_type'] === StreamResponse::class) ? 'raw' : $this->app['config']['response_type'] + ); + } + + /** + * @param array $payload + * + * @return array + */ + protected function buildFormParams($payload) + { + return [ + 'encrypted' => $this->getEncrypter()->encrypt(json_encode($payload)), + ]; + } + + /** + * @param \Psr\Http\Message\ResponseInterface $response + * + * @return array + */ + protected function parseResponse($response) + { + $result = json_decode((string) $response->getBody(), true); + + if (isset($result['exception'])) { + throw (new DelegationException($result['message']))->setException($result['exception']); + } + + return $result; + } + + /** + * @return \GuzzleHttp\ClientInterface + */ + protected function getHttpClient(): ClientInterface + { + return $this->httpClient ?: $this->httpClient = new Client([ + 'base_uri' => $this->app['config']['delegation']['host'], + ]); + } + + /** + * @return \EasyWeChatComposer\Contracts\Encrypter + */ + protected function getEncrypter(): Encrypter + { + return $this->encrypter ?: $this->encrypter = new DefaultEncrypter( + EasyWeChat::getEncryptionKey() + ); + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/src/Traits/WithAggregator.php b/vendor/easywechat-composer/easywechat-composer/src/Traits/WithAggregator.php new file mode 100644 index 0000000..a3eb16e --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/src/Traits/WithAggregator.php @@ -0,0 +1,60 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Traits; + +use EasyWeChat\Kernel\BaseClient; +use EasyWeChatComposer\Delegation\DelegationTo; +use EasyWeChatComposer\EasyWeChat; + +trait WithAggregator +{ + /** + * Aggregate. + */ + protected function aggregate() + { + foreach (EasyWeChat::config() as $key => $value) { + $this['config']->set($key, $value); + } + } + + /** + * @return bool + */ + public function shouldDelegate($id) + { + return $this['config']->get('delegation.enabled') + && $this->offsetGet($id) instanceof BaseClient; + } + + /** + * @return $this + */ + public function shouldntDelegate() + { + $this['config']->set('delegation.enabled', false); + + return $this; + } + + /** + * @param string $id + * + * @return \EasyWeChatComposer\Delegation + */ + public function delegateTo($id) + { + return new DelegationTo($this, $id); + } +} diff --git a/vendor/easywechat-composer/easywechat-composer/tests/ManifestManagerTest.php b/vendor/easywechat-composer/easywechat-composer/tests/ManifestManagerTest.php new file mode 100644 index 0000000..23b8e2c --- /dev/null +++ b/vendor/easywechat-composer/easywechat-composer/tests/ManifestManagerTest.php @@ -0,0 +1,37 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace EasyWeChatComposer\Tests; + +use EasyWeChatComposer\ManifestManager; +use PHPUnit\Framework\TestCase; + +class ManifestManagerTest extends TestCase +{ + private $vendorPath; + private $manifestPath; + + protected function getManifestManager() + { + return new ManifestManager( + $this->vendorPath = __DIR__.'/__fixtures__/vendor/', + $this->manifestPath = __DIR__.'/__fixtures__/extensions.php' + ); + } + + public function testUnlink() + { + $this->assertInstanceOf(ManifestManager::class, $this->getManifestManager()->unlink()); + $this->assertFalse(file_exists($this->manifestPath)); + } +} diff --git a/vendor/ezyang/htmlpurifier/CREDITS b/vendor/ezyang/htmlpurifier/CREDITS new file mode 100644 index 0000000..7921b45 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/CREDITS @@ -0,0 +1,9 @@ + +CREDITS + +Almost everything written by Edward Z. Yang (Ambush Commander). Lots of thanks +to the DevNetwork Community for their help (see docs/ref-devnetwork.html for +more details), Feyd especially (namely IPv6 and optimization). Thanks to RSnake +for letting me package his fantastic XSS cheatsheet for a smoketest. + + vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/LICENSE b/vendor/ezyang/htmlpurifier/LICENSE new file mode 100644 index 0000000..8c88a20 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/LICENSE @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/README.md b/vendor/ezyang/htmlpurifier/README.md new file mode 100644 index 0000000..e6b7199 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/README.md @@ -0,0 +1,29 @@ +HTML Purifier [![Build Status](https://github.com/ezyang/htmlpurifier/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/ezyang/htmlpurifier/actions/workflows/ci.yml) +============= + +HTML Purifier is an HTML filtering solution that uses a unique combination +of robust whitelists and aggressive parsing to ensure that not only are +XSS attacks thwarted, but the resulting HTML is standards compliant. + +HTML Purifier is oriented towards richly formatted documents from +untrusted sources that require CSS and a full tag-set. This library can +be configured to accept a more restrictive set of tags, but it won't be +as efficient as more bare-bones parsers. It will, however, do the job +right, which may be more important. + +Places to go: + +* See INSTALL for a quick installation guide +* See docs/ for developer-oriented documentation, code examples and + an in-depth installation guide. +* See WYSIWYG for information on editors like TinyMCE and FCKeditor + +HTML Purifier can be found on the web at: [http://htmlpurifier.org/](http://htmlpurifier.org/) + +## Installation + +Package available on [Composer](https://packagist.org/packages/ezyang/htmlpurifier). + +If you're using Composer to manage dependencies, you can use + + $ composer require ezyang/htmlpurifier diff --git a/vendor/ezyang/htmlpurifier/VERSION b/vendor/ezyang/htmlpurifier/VERSION new file mode 100644 index 0000000..ef8ffbd --- /dev/null +++ b/vendor/ezyang/htmlpurifier/VERSION @@ -0,0 +1 @@ +4.18.0 \ No newline at end of file diff --git a/vendor/ezyang/htmlpurifier/composer.json b/vendor/ezyang/htmlpurifier/composer.json new file mode 100644 index 0000000..7799d1d --- /dev/null +++ b/vendor/ezyang/htmlpurifier/composer.json @@ -0,0 +1,45 @@ +{ + "name": "ezyang/htmlpurifier", + "description": "Standards compliant HTML filter written in PHP", + "type": "library", + "keywords": ["html"], + "homepage": "http://htmlpurifier.org/", + "license": "LGPL-2.1-or-later", + "authors": [ + { + "name": "Edward Z. Yang", + "email": "admin@htmlpurifier.org", + "homepage": "http://ezyang.com" + } + ], + "require": { + "php": "~5.6.0 || ~7.0.0 || ~7.1.0 || ~7.2.0 || ~7.3.0 || ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0" + }, + "require-dev": { + "cerdic/css-tidy": "^1.7 || ^2.0", + "simpletest/simpletest": "dev-master" + }, + "autoload": { + "psr-0": { "HTMLPurifier": "library/" }, + "files": ["library/HTMLPurifier.composer.php"], + "exclude-from-classmap": [ + "/library/HTMLPurifier/Language/" + ] + }, + "suggest": { + "cerdic/css-tidy": "If you want to use the filter 'Filter.ExtractStyleBlocks'.", + "ext-iconv": "Converts text to and from non-UTF-8 encodings", + "ext-bcmath": "Used for unit conversion and imagecrash protection", + "ext-tidy": "Used for pretty-printing HTML" + }, + "config": { + "sort-packages": true + }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/ezyang/simpletest.git", + "no-api": true + } + ] +} diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier.auto.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier.auto.php new file mode 100644 index 0000000..1960c39 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier.auto.php @@ -0,0 +1,11 @@ +purify($html, $config); +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier.includes.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier.includes.php new file mode 100644 index 0000000..4c713a3 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier.includes.php @@ -0,0 +1,236 @@ + $attributes) { + $allowed_elements[$element] = true; + foreach ($attributes as $attribute => $x) { + $allowed_attributes["$element.$attribute"] = true; + } + } + $config->set('HTML.AllowedElements', $allowed_elements); + $config->set('HTML.AllowedAttributes', $allowed_attributes); + if ($allowed_protocols !== null) { + $config->set('URI.AllowedSchemes', $allowed_protocols); + } + $purifier = new HTMLPurifier($config); + return $purifier->purify($string); +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier.path.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier.path.php new file mode 100644 index 0000000..39b1b65 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier.path.php @@ -0,0 +1,11 @@ +config = HTMLPurifier_Config::create($config); + $this->strategy = new HTMLPurifier_Strategy_Core(); + } + + /** + * Adds a filter to process the output. First come first serve + * + * @param HTMLPurifier_Filter $filter HTMLPurifier_Filter object + */ + public function addFilter($filter) + { + trigger_error( + 'HTMLPurifier->addFilter() is deprecated, use configuration directives' . + ' in the Filter namespace or Filter.Custom', + E_USER_WARNING + ); + $this->filters[] = $filter; + } + + /** + * Filters an HTML snippet/document to be XSS-free and standards-compliant. + * + * @param string $html String of HTML to purify + * @param HTMLPurifier_Config $config Config object for this operation, + * if omitted, defaults to the config object specified during this + * object's construction. The parameter can also be any type + * that HTMLPurifier_Config::create() supports. + * + * @return string Purified HTML + */ + public function purify($html, $config = null) + { + // :TODO: make the config merge in, instead of replace + $config = $config ? HTMLPurifier_Config::create($config) : $this->config; + + // implementation is partially environment dependant, partially + // configuration dependant + $lexer = HTMLPurifier_Lexer::create($config); + + $context = new HTMLPurifier_Context(); + + // setup HTML generator + $this->generator = new HTMLPurifier_Generator($config, $context); + $context->register('Generator', $this->generator); + + // set up global context variables + if ($config->get('Core.CollectErrors')) { + // may get moved out if other facilities use it + $language_factory = HTMLPurifier_LanguageFactory::instance(); + $language = $language_factory->create($config, $context); + $context->register('Locale', $language); + + $error_collector = new HTMLPurifier_ErrorCollector($context); + $context->register('ErrorCollector', $error_collector); + } + + // setup id_accumulator context, necessary due to the fact that + // AttrValidator can be called from many places + $id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context); + $context->register('IDAccumulator', $id_accumulator); + + $html = HTMLPurifier_Encoder::convertToUTF8($html, $config, $context); + + // setup filters + $filter_flags = $config->getBatch('Filter'); + $custom_filters = $filter_flags['Custom']; + unset($filter_flags['Custom']); + $filters = array(); + foreach ($filter_flags as $filter => $flag) { + if (!$flag) { + continue; + } + if (strpos($filter, '.') !== false) { + continue; + } + $class = "HTMLPurifier_Filter_$filter"; + $filters[] = new $class; + } + foreach ($custom_filters as $filter) { + // maybe "HTMLPurifier_Filter_$filter", but be consistent with AutoFormat + $filters[] = $filter; + } + $filters = array_merge($filters, $this->filters); + // maybe prepare(), but later + + for ($i = 0, $filter_size = count($filters); $i < $filter_size; $i++) { + $html = $filters[$i]->preFilter($html, $config, $context); + } + + // purified HTML + $html = + $this->generator->generateFromTokens( + // list of tokens + $this->strategy->execute( + // list of un-purified tokens + $lexer->tokenizeHTML( + // un-purified HTML + $html, + $config, + $context + ), + $config, + $context + ) + ); + + for ($i = $filter_size - 1; $i >= 0; $i--) { + $html = $filters[$i]->postFilter($html, $config, $context); + } + + $html = HTMLPurifier_Encoder::convertFromUTF8($html, $config, $context); + $this->context =& $context; + return $html; + } + + /** + * Filters an array of HTML snippets + * + * @param string[] $array_of_html Array of html snippets + * @param HTMLPurifier_Config $config Optional config object for this operation. + * See HTMLPurifier::purify() for more details. + * + * @return string[] Array of purified HTML + */ + public function purifyArray($array_of_html, $config = null) + { + $context_array = array(); + $array = array(); + foreach($array_of_html as $key=>$value){ + if (is_array($value)) { + $array[$key] = $this->purifyArray($value, $config); + } else { + $array[$key] = $this->purify($value, $config); + } + $context_array[$key] = $this->context; + } + $this->context = $context_array; + return $array; + } + + /** + * Singleton for enforcing just one HTML Purifier in your system + * + * @param HTMLPurifier|HTMLPurifier_Config $prototype Optional prototype + * HTMLPurifier instance to overload singleton with, + * or HTMLPurifier_Config instance to configure the + * generated version with. + * + * @return HTMLPurifier + */ + public static function instance($prototype = null) + { + if (!self::$instance || $prototype) { + if ($prototype instanceof HTMLPurifier) { + self::$instance = $prototype; + } elseif ($prototype) { + self::$instance = new HTMLPurifier($prototype); + } else { + self::$instance = new HTMLPurifier(); + } + } + return self::$instance; + } + + /** + * Singleton for enforcing just one HTML Purifier in your system + * + * @param HTMLPurifier|HTMLPurifier_Config $prototype Optional prototype + * HTMLPurifier instance to overload singleton with, + * or HTMLPurifier_Config instance to configure the + * generated version with. + * + * @return HTMLPurifier + * @note Backwards compatibility, see instance() + */ + public static function getInstance($prototype = null) + { + return HTMLPurifier::instance($prototype); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier.safe-includes.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier.safe-includes.php new file mode 100644 index 0000000..8a417d2 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier.safe-includes.php @@ -0,0 +1,230 @@ +getHTMLDefinition(); + $parent = new HTMLPurifier_Token_Start($definition->info_parent); + $stack = array($parent->toNode()); + foreach ($tokens as $token) { + $token->skip = null; // [MUT] + $token->carryover = null; // [MUT] + if ($token instanceof HTMLPurifier_Token_End) { + $token->start = null; // [MUT] + $r = array_pop($stack); + //assert($r->name === $token->name); + //assert(empty($token->attr)); + $r->endCol = $token->col; + $r->endLine = $token->line; + $r->endArmor = $token->armor; + continue; + } + $node = $token->toNode(); + $stack[count($stack)-1]->children[] = $node; + if ($token instanceof HTMLPurifier_Token_Start) { + $stack[] = $node; + } + } + //assert(count($stack) == 1); + return $stack[0]; + } + + public static function flatten($node, $config, $context) { + $level = 0; + $nodes = array($level => new HTMLPurifier_Queue(array($node))); + $closingTokens = array(); + $tokens = array(); + do { + while (!$nodes[$level]->isEmpty()) { + $node = $nodes[$level]->shift(); // FIFO + list($start, $end) = $node->toTokenPair(); + if ($level > 0) { + $tokens[] = $start; + } + if ($end !== NULL) { + $closingTokens[$level][] = $end; + } + if ($node instanceof HTMLPurifier_Node_Element) { + $level++; + $nodes[$level] = new HTMLPurifier_Queue(); + foreach ($node->children as $childNode) { + $nodes[$level]->push($childNode); + } + } + } + $level--; + if ($level && isset($closingTokens[$level])) { + while ($token = array_pop($closingTokens[$level])) { + $tokens[] = $token; + } + } + } while ($level > 0); + return $tokens; + } +} diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrCollections.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrCollections.php new file mode 100644 index 0000000..c7b17cf --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrCollections.php @@ -0,0 +1,148 @@ +doConstruct($attr_types, $modules); + } + + public function doConstruct($attr_types, $modules) + { + // load extensions from the modules + foreach ($modules as $module) { + foreach ($module->attr_collections as $coll_i => $coll) { + if (!isset($this->info[$coll_i])) { + $this->info[$coll_i] = array(); + } + foreach ($coll as $attr_i => $attr) { + if ($attr_i === 0 && isset($this->info[$coll_i][$attr_i])) { + // merge in includes + $this->info[$coll_i][$attr_i] = array_merge( + $this->info[$coll_i][$attr_i], + $attr + ); + continue; + } + $this->info[$coll_i][$attr_i] = $attr; + } + } + } + // perform internal expansions and inclusions + foreach ($this->info as $name => $attr) { + // merge attribute collections that include others + $this->performInclusions($this->info[$name]); + // replace string identifiers with actual attribute objects + $this->expandIdentifiers($this->info[$name], $attr_types); + } + } + + /** + * Takes a reference to an attribute associative array and performs + * all inclusions specified by the zero index. + * @param array &$attr Reference to attribute array + */ + public function performInclusions(&$attr) + { + if (!isset($attr[0])) { + return; + } + $merge = $attr[0]; + $seen = array(); // recursion guard + // loop through all the inclusions + for ($i = 0; isset($merge[$i]); $i++) { + if (isset($seen[$merge[$i]])) { + continue; + } + $seen[$merge[$i]] = true; + // foreach attribute of the inclusion, copy it over + if (!isset($this->info[$merge[$i]])) { + continue; + } + foreach ($this->info[$merge[$i]] as $key => $value) { + if (isset($attr[$key])) { + continue; + } // also catches more inclusions + $attr[$key] = $value; + } + if (isset($this->info[$merge[$i]][0])) { + // recursion + $merge = array_merge($merge, $this->info[$merge[$i]][0]); + } + } + unset($attr[0]); + } + + /** + * Expands all string identifiers in an attribute array by replacing + * them with the appropriate values inside HTMLPurifier_AttrTypes + * @param array &$attr Reference to attribute array + * @param HTMLPurifier_AttrTypes $attr_types HTMLPurifier_AttrTypes instance + */ + public function expandIdentifiers(&$attr, $attr_types) + { + // because foreach will process new elements we add, make sure we + // skip duplicates + $processed = array(); + + foreach ($attr as $def_i => $def) { + // skip inclusions + if ($def_i === 0) { + continue; + } + + if (isset($processed[$def_i])) { + continue; + } + + // determine whether or not attribute is required + if ($required = (strpos($def_i, '*') !== false)) { + // rename the definition + unset($attr[$def_i]); + $def_i = trim($def_i, '*'); + $attr[$def_i] = $def; + } + + $processed[$def_i] = true; + + // if we've already got a literal object, move on + if (is_object($def)) { + // preserve previous required + $attr[$def_i]->required = ($required || $attr[$def_i]->required); + continue; + } + + if ($def === false) { + unset($attr[$def_i]); + continue; + } + + if ($t = $attr_types->get($def)) { + $attr[$def_i] = $t; + $attr[$def_i]->required = $required; + } else { + unset($attr[$def_i]); + } + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef.php new file mode 100644 index 0000000..739646f --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef.php @@ -0,0 +1,144 @@ + by removing + * leading and trailing whitespace, ignoring line feeds, and replacing + * carriage returns and tabs with spaces. While most useful for HTML + * attributes specified as CDATA, it can also be applied to most CSS + * values. + * + * @note This method is not entirely standards compliant, as trim() removes + * more types of whitespace than specified in the spec. In practice, + * this is rarely a problem, as those extra characters usually have + * already been removed by HTMLPurifier_Encoder. + * + * @warning This processing is inconsistent with XML's whitespace handling + * as specified by section 3.3.3 and referenced XHTML 1.0 section + * 4.7. However, note that we are NOT necessarily + * parsing XML, thus, this behavior may still be correct. We + * assume that newlines have been normalized. + */ + public function parseCDATA($string) + { + $string = trim($string); + $string = str_replace(array("\n", "\t", "\r"), ' ', $string); + return $string; + } + + /** + * Factory method for creating this class from a string. + * @param string $string String construction info + * @return HTMLPurifier_AttrDef Created AttrDef object corresponding to $string + */ + public function make($string) + { + // default implementation, return a flyweight of this object. + // If $string has an effect on the returned object (i.e. you + // need to overload this method), it is best + // to clone or instantiate new copies. (Instantiation is safer.) + return $this; + } + + /** + * Removes spaces from rgb(0, 0, 0) so that shorthand CSS properties work + * properly. THIS IS A HACK! + * @param string $string a CSS colour definition + * @return string + */ + protected function mungeRgb($string) + { + $p = '\s*(\d+(\.\d+)?([%]?))\s*'; + + if (preg_match('/(rgba|hsla)\(/', $string)) { + return preg_replace('/(rgba|hsla)\('.$p.','.$p.','.$p.','.$p.'\)/', '\1(\2,\5,\8,\11)', $string); + } + + return preg_replace('/(rgb|hsl)\('.$p.','.$p.','.$p.'\)/', '\1(\2,\5,\8)', $string); + } + + /** + * Parses a possibly escaped CSS string and returns the "pure" + * version of it. + */ + protected function expandCSSEscape($string) + { + // flexibly parse it + $ret = ''; + for ($i = 0, $c = strlen($string); $i < $c; $i++) { + if ($string[$i] === '\\') { + $i++; + if ($i >= $c) { + $ret .= '\\'; + break; + } + if (ctype_xdigit($string[$i])) { + $code = $string[$i]; + for ($a = 1, $i++; $i < $c && $a < 6; $i++, $a++) { + if (!ctype_xdigit($string[$i])) { + break; + } + $code .= $string[$i]; + } + // We have to be extremely careful when adding + // new characters, to make sure we're not breaking + // the encoding. + $char = HTMLPurifier_Encoder::unichr(hexdec($code)); + if (HTMLPurifier_Encoder::cleanUTF8($char) === '') { + continue; + } + $ret .= $char; + if ($i < $c && trim($string[$i]) !== '') { + $i--; + } + continue; + } + if ($string[$i] === "\n") { + continue; + } + } + $ret .= $string[$i]; + } + return $ret; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS.php new file mode 100644 index 0000000..af6b8a0 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS.php @@ -0,0 +1,140 @@ +parseCDATA($css); + + $definition = $config->getCSSDefinition(); + $allow_duplicates = $config->get("CSS.AllowDuplicates"); + + $universal_attrdef = new HTMLPurifier_AttrDef_Enum( + array( + 'initial', + 'inherit', + 'unset', + ) + ); + + // According to the CSS2.1 spec, the places where a + // non-delimiting semicolon can appear are in strings + // escape sequences. So here is some dumb hack to + // handle quotes. + $len = strlen($css); + $accum = ""; + $declarations = array(); + $quoted = false; + for ($i = 0; $i < $len; $i++) { + $c = strcspn($css, ";'\"", $i); + $accum .= substr($css, $i, $c); + $i += $c; + if ($i == $len) break; + $d = $css[$i]; + if ($quoted) { + $accum .= $d; + if ($d == $quoted) { + $quoted = false; + } + } else { + if ($d == ";") { + $declarations[] = $accum; + $accum = ""; + } else { + $accum .= $d; + $quoted = $d; + } + } + } + if ($accum != "") $declarations[] = $accum; + + $propvalues = array(); + $new_declarations = ''; + + /** + * Name of the current CSS property being validated. + */ + $property = false; + $context->register('CurrentCSSProperty', $property); + + foreach ($declarations as $declaration) { + if (!$declaration) { + continue; + } + if (!strpos($declaration, ':')) { + continue; + } + list($property, $value) = explode(':', $declaration, 2); + $property = trim($property); + $value = trim($value); + $ok = false; + do { + if (isset($definition->info[$property])) { + $ok = true; + break; + } + if (ctype_lower($property)) { + break; + } + $property = strtolower($property); + if (isset($definition->info[$property])) { + $ok = true; + break; + } + } while (0); + if (!$ok) { + continue; + } + $result = $universal_attrdef->validate($value, $config, $context); + if ($result === false) { + $result = $definition->info[$property]->validate( + $value, + $config, + $context + ); + } + if ($result === false) { + continue; + } + if ($allow_duplicates) { + $new_declarations .= "$property:$result;"; + } else { + $propvalues[$property] = $result; + } + } + + $context->destroy('CurrentCSSProperty'); + + // procedure does not write the new CSS simultaneously, so it's + // slightly inefficient, but it's the only way of getting rid of + // duplicates. Perhaps config to optimize it, but not now. + + foreach ($propvalues as $prop => $value) { + $new_declarations .= "$prop:$value;"; + } + + return $new_declarations ? $new_declarations : false; + + } + +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/AlphaValue.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/AlphaValue.php new file mode 100644 index 0000000..af2b83d --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/AlphaValue.php @@ -0,0 +1,34 @@ + 1.0) { + $result = '1'; + } + return $result; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Background.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Background.php new file mode 100644 index 0000000..28c4988 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Background.php @@ -0,0 +1,113 @@ +getCSSDefinition(); + $this->info['background-color'] = $def->info['background-color']; + $this->info['background-image'] = $def->info['background-image']; + $this->info['background-repeat'] = $def->info['background-repeat']; + $this->info['background-attachment'] = $def->info['background-attachment']; + $this->info['background-position'] = $def->info['background-position']; + $this->info['background-size'] = $def->info['background-size']; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + // regular pre-processing + $string = $this->parseCDATA($string); + if ($string === '') { + return false; + } + + // munge rgb() decl if necessary + $string = $this->mungeRgb($string); + + // assumes URI doesn't have spaces in it + $bits = explode(' ', $string); // bits to process + + $caught = array(); + $caught['color'] = false; + $caught['image'] = false; + $caught['repeat'] = false; + $caught['attachment'] = false; + $caught['position'] = false; + $caught['size'] = false; + + $i = 0; // number of catches + + foreach ($bits as $bit) { + if ($bit === '') { + continue; + } + foreach ($caught as $key => $status) { + if ($key != 'position') { + if ($status !== false) { + continue; + } + $r = $this->info['background-' . $key]->validate($bit, $config, $context); + } else { + $r = $bit; + } + if ($r === false) { + continue; + } + if ($key == 'position') { + if ($caught[$key] === false) { + $caught[$key] = ''; + } + $caught[$key] .= $r . ' '; + } else { + $caught[$key] = $r; + } + $i++; + break; + } + } + + if (!$i) { + return false; + } + if ($caught['position'] !== false) { + $caught['position'] = $this->info['background-position']-> + validate($caught['position'], $config, $context); + } + + $ret = array(); + foreach ($caught as $value) { + if ($value === false) { + continue; + } + $ret[] = $value; + } + + if (empty($ret)) { + return false; + } + return implode(' ', $ret); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php new file mode 100644 index 0000000..4580ef5 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/BackgroundPosition.php @@ -0,0 +1,157 @@ + | | left | center | right + ] + [ + | | top | center | bottom + ]? + ] | + [ // this signifies that the vertical and horizontal adjectives + // can be arbitrarily ordered, however, there can only be two, + // one of each, or none at all + [ + left | center | right + ] || + [ + top | center | bottom + ] + ] + top, left = 0% + center, (none) = 50% + bottom, right = 100% +*/ + +/* QuirksMode says: + keyword + length/percentage must be ordered correctly, as per W3C + + Internet Explorer and Opera, however, support arbitrary ordering. We + should fix it up. + + Minor issue though, not strictly necessary. +*/ + +// control freaks may appreciate the ability to convert these to +// percentages or something, but it's not necessary + +/** + * Validates the value of background-position. + */ +class HTMLPurifier_AttrDef_CSS_BackgroundPosition extends HTMLPurifier_AttrDef +{ + + /** + * @type HTMLPurifier_AttrDef_CSS_Length + */ + protected $length; + + /** + * @type HTMLPurifier_AttrDef_CSS_Percentage + */ + protected $percentage; + + public function __construct() + { + $this->length = new HTMLPurifier_AttrDef_CSS_Length(); + $this->percentage = new HTMLPurifier_AttrDef_CSS_Percentage(); + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $string = $this->parseCDATA($string); + $bits = explode(' ', $string); + + $keywords = array(); + $keywords['h'] = false; // left, right + $keywords['v'] = false; // top, bottom + $keywords['ch'] = false; // center (first word) + $keywords['cv'] = false; // center (second word) + $measures = array(); + + $i = 0; + + $lookup = array( + 'top' => 'v', + 'bottom' => 'v', + 'left' => 'h', + 'right' => 'h', + 'center' => 'c' + ); + + foreach ($bits as $bit) { + if ($bit === '') { + continue; + } + + // test for keyword + $lbit = ctype_lower($bit) ? $bit : strtolower($bit); + if (isset($lookup[$lbit])) { + $status = $lookup[$lbit]; + if ($status == 'c') { + if ($i == 0) { + $status = 'ch'; + } else { + $status = 'cv'; + } + } + $keywords[$status] = $lbit; + $i++; + } + + // test for length + $r = $this->length->validate($bit, $config, $context); + if ($r !== false) { + $measures[] = $r; + $i++; + } + + // test for percentage + $r = $this->percentage->validate($bit, $config, $context); + if ($r !== false) { + $measures[] = $r; + $i++; + } + } + + if (!$i) { + return false; + } // no valid values were caught + + $ret = array(); + + // first keyword + if ($keywords['h']) { + $ret[] = $keywords['h']; + } elseif ($keywords['ch']) { + $ret[] = $keywords['ch']; + $keywords['cv'] = false; // prevent re-use: center = center center + } elseif (count($measures)) { + $ret[] = array_shift($measures); + } + + if ($keywords['v']) { + $ret[] = $keywords['v']; + } elseif ($keywords['cv']) { + $ret[] = $keywords['cv']; + } elseif (count($measures)) { + $ret[] = array_shift($measures); + } + + if (empty($ret)) { + return false; + } + return implode(' ', $ret); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Border.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Border.php new file mode 100644 index 0000000..16243ba --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Border.php @@ -0,0 +1,56 @@ +getCSSDefinition(); + $this->info['border-width'] = $def->info['border-width']; + $this->info['border-style'] = $def->info['border-style']; + $this->info['border-top-color'] = $def->info['border-top-color']; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $string = $this->parseCDATA($string); + $string = $this->mungeRgb($string); + $bits = explode(' ', $string); + $done = array(); // segments we've finished + $ret = ''; // return value + foreach ($bits as $bit) { + foreach ($this->info as $propname => $validator) { + if (isset($done[$propname])) { + continue; + } + $r = $validator->validate($bit, $config, $context); + if ($r !== false) { + $ret .= $r . ' '; + $done[$propname] = true; + break; + } + } + } + return rtrim($ret); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Color.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Color.php new file mode 100644 index 0000000..d7287a0 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Color.php @@ -0,0 +1,161 @@ +alpha = new HTMLPurifier_AttrDef_CSS_AlphaValue(); + } + + /** + * @param string $color + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($color, $config, $context) + { + static $colors = null; + if ($colors === null) { + $colors = $config->get('Core.ColorKeywords'); + } + + $color = trim($color); + if ($color === '') { + return false; + } + + $lower = strtolower($color); + if (isset($colors[$lower])) { + return $colors[$lower]; + } + + if (preg_match('#(rgb|rgba|hsl|hsla)\(#', $color, $matches) === 1) { + $length = strlen($color); + if (strpos($color, ')') !== $length - 1) { + return false; + } + + // get used function : rgb, rgba, hsl or hsla + $function = $matches[1]; + + $parameters_size = 3; + $alpha_channel = false; + if (substr($function, -1) === 'a') { + $parameters_size = 4; + $alpha_channel = true; + } + + /* + * Allowed types for values : + * parameter_position => [type => max_value] + */ + $allowed_types = array( + 1 => array('percentage' => 100, 'integer' => 255), + 2 => array('percentage' => 100, 'integer' => 255), + 3 => array('percentage' => 100, 'integer' => 255), + ); + $allow_different_types = false; + + if (strpos($function, 'hsl') !== false) { + $allowed_types = array( + 1 => array('integer' => 360), + 2 => array('percentage' => 100), + 3 => array('percentage' => 100), + ); + $allow_different_types = true; + } + + $values = trim(str_replace($function, '', $color), ' ()'); + + $parts = explode(',', $values); + if (count($parts) !== $parameters_size) { + return false; + } + + $type = false; + $new_parts = array(); + $i = 0; + + foreach ($parts as $part) { + $i++; + $part = trim($part); + + if ($part === '') { + return false; + } + + // different check for alpha channel + if ($alpha_channel === true && $i === count($parts)) { + $result = $this->alpha->validate($part, $config, $context); + + if ($result === false) { + return false; + } + + $new_parts[] = (string)$result; + continue; + } + + if (substr($part, -1) === '%') { + $current_type = 'percentage'; + } else { + $current_type = 'integer'; + } + + if (!array_key_exists($current_type, $allowed_types[$i])) { + return false; + } + + if (!$type) { + $type = $current_type; + } + + if ($allow_different_types === false && $type != $current_type) { + return false; + } + + $max_value = $allowed_types[$i][$current_type]; + + if ($current_type == 'integer') { + // Return value between range 0 -> $max_value + $new_parts[] = (int)max(min($part, $max_value), 0); + } elseif ($current_type == 'percentage') { + $new_parts[] = (float)max(min(rtrim($part, '%'), $max_value), 0) . '%'; + } + } + + $new_values = implode(',', $new_parts); + + $color = $function . '(' . $new_values . ')'; + } else { + // hexadecimal handling + if ($color[0] === '#') { + $hex = substr($color, 1); + } else { + $hex = $color; + $color = '#' . $color; + } + $length = strlen($hex); + if ($length !== 3 && $length !== 6) { + return false; + } + if (!ctype_xdigit($hex)) { + return false; + } + } + return $color; + } + +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Composite.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Composite.php new file mode 100644 index 0000000..9c17505 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Composite.php @@ -0,0 +1,48 @@ +defs = $defs; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + foreach ($this->defs as $i => $def) { + $result = $this->defs[$i]->validate($string, $config, $context); + if ($result !== false) { + return $result; + } + } + return false; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php new file mode 100644 index 0000000..9d77cc9 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/DenyElementDecorator.php @@ -0,0 +1,44 @@ +def = $def; + $this->element = $element; + } + + /** + * Checks if CurrentToken is set and equal to $this->element + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $token = $context->get('CurrentToken', true); + if ($token && $token->name == $this->element) { + return false; + } + return $this->def->validate($string, $config, $context); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Filter.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Filter.php new file mode 100644 index 0000000..bde4c33 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Filter.php @@ -0,0 +1,77 @@ +intValidator = new HTMLPurifier_AttrDef_Integer(); + } + + /** + * @param string $value + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($value, $config, $context) + { + $value = $this->parseCDATA($value); + if ($value === 'none') { + return $value; + } + // if we looped this we could support multiple filters + $function_length = strcspn($value, '('); + $function = trim(substr($value, 0, $function_length)); + if ($function !== 'alpha' && + $function !== 'Alpha' && + $function !== 'progid:DXImageTransform.Microsoft.Alpha' + ) { + return false; + } + $cursor = $function_length + 1; + $parameters_length = strcspn($value, ')', $cursor); + $parameters = substr($value, $cursor, $parameters_length); + $params = explode(',', $parameters); + $ret_params = array(); + $lookup = array(); + foreach ($params as $param) { + list($key, $value) = explode('=', $param); + $key = trim($key); + $value = trim($value); + if (isset($lookup[$key])) { + continue; + } + if ($key !== 'opacity') { + continue; + } + $value = $this->intValidator->validate($value, $config, $context); + if ($value === false) { + continue; + } + $int = (int)$value; + if ($int > 100) { + $value = '100'; + } + if ($int < 0) { + $value = '0'; + } + $ret_params[] = "$key=$value"; + $lookup[$key] = true; + } + $ret_parameters = implode(',', $ret_params); + $ret_function = "$function($ret_parameters)"; + return $ret_function; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Font.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Font.php new file mode 100644 index 0000000..579b97e --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Font.php @@ -0,0 +1,176 @@ +getCSSDefinition(); + $this->info['font-style'] = $def->info['font-style']; + $this->info['font-variant'] = $def->info['font-variant']; + $this->info['font-weight'] = $def->info['font-weight']; + $this->info['font-size'] = $def->info['font-size']; + $this->info['line-height'] = $def->info['line-height']; + $this->info['font-family'] = $def->info['font-family']; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + static $system_fonts = array( + 'caption' => true, + 'icon' => true, + 'menu' => true, + 'message-box' => true, + 'small-caption' => true, + 'status-bar' => true + ); + + // regular pre-processing + $string = $this->parseCDATA($string); + if ($string === '') { + return false; + } + + // check if it's one of the keywords + $lowercase_string = strtolower($string); + if (isset($system_fonts[$lowercase_string])) { + return $lowercase_string; + } + + $bits = explode(' ', $string); // bits to process + $stage = 0; // this indicates what we're looking for + $caught = array(); // which stage 0 properties have we caught? + $stage_1 = array('font-style', 'font-variant', 'font-weight'); + $final = ''; // output + + for ($i = 0, $size = count($bits); $i < $size; $i++) { + if ($bits[$i] === '') { + continue; + } + switch ($stage) { + case 0: // attempting to catch font-style, font-variant or font-weight + foreach ($stage_1 as $validator_name) { + if (isset($caught[$validator_name])) { + continue; + } + $r = $this->info[$validator_name]->validate( + $bits[$i], + $config, + $context + ); + if ($r !== false) { + $final .= $r . ' '; + $caught[$validator_name] = true; + break; + } + } + // all three caught, continue on + if (count($caught) >= 3) { + $stage = 1; + } + if ($r !== false) { + break; + } + case 1: // attempting to catch font-size and perhaps line-height + $found_slash = false; + if (strpos($bits[$i], '/') !== false) { + list($font_size, $line_height) = + explode('/', $bits[$i]); + if ($line_height === '') { + // ooh, there's a space after the slash! + $line_height = false; + $found_slash = true; + } + } else { + $font_size = $bits[$i]; + $line_height = false; + } + $r = $this->info['font-size']->validate( + $font_size, + $config, + $context + ); + if ($r !== false) { + $final .= $r; + // attempt to catch line-height + if ($line_height === false) { + // we need to scroll forward + for ($j = $i + 1; $j < $size; $j++) { + if ($bits[$j] === '') { + continue; + } + if ($bits[$j] === '/') { + if ($found_slash) { + return false; + } else { + $found_slash = true; + continue; + } + } + $line_height = $bits[$j]; + break; + } + } else { + // slash already found + $found_slash = true; + $j = $i; + } + if ($found_slash) { + $i = $j; + $r = $this->info['line-height']->validate( + $line_height, + $config, + $context + ); + if ($r !== false) { + $final .= '/' . $r; + } + } + $final .= ' '; + $stage = 2; + break; + } + return false; + case 2: // attempting to catch font-family + $font_family = + implode(' ', array_slice($bits, $i, $size - $i)); + $r = $this->info['font-family']->validate( + $font_family, + $config, + $context + ); + if ($r !== false) { + $final .= $r . ' '; + // processing completed successfully + return rtrim($final); + } + return false; + } + } + return false; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/FontFamily.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/FontFamily.php new file mode 100644 index 0000000..f1ff116 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/FontFamily.php @@ -0,0 +1,217 @@ +mask = array_reduce($c, function ($carry, $value) { + return $carry . $value; + }, '_- '); + + /* + PHP's internal strcspn implementation is + O(length of string * length of mask), making it inefficient + for large masks. However, it's still faster than + preg_match 8) + for (p = s1;;) { + spanp = s2; + do { + if (*spanp == c || p == s1_end) { + return p - s1; + } + } while (spanp++ < (s2_end - 1)); + c = *++p; + } + */ + // possible optimization: invert the mask. + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + static $generic_names = array( + 'serif' => true, + 'sans-serif' => true, + 'monospace' => true, + 'fantasy' => true, + 'cursive' => true + ); + $allowed_fonts = $config->get('CSS.AllowedFonts'); + + // assume that no font names contain commas in them + $fonts = explode(',', $string); + $final = ''; + foreach ($fonts as $font) { + $font = trim($font); + if ($font === '') { + continue; + } + // match a generic name + if (isset($generic_names[$font])) { + if ($allowed_fonts === null || isset($allowed_fonts[$font])) { + $final .= $font . ', '; + } + continue; + } + // match a quoted name + if ($font[0] === '"' || $font[0] === "'") { + $length = strlen($font); + if ($length <= 2) { + continue; + } + $quote = $font[0]; + if ($font[$length - 1] !== $quote) { + continue; + } + $font = substr($font, 1, $length - 2); + } + + $font = $this->expandCSSEscape($font); + + // $font is a pure representation of the font name + + if ($allowed_fonts !== null && !isset($allowed_fonts[$font])) { + continue; + } + + if (ctype_alnum($font) && $font !== '') { + // very simple font, allow it in unharmed + $final .= $font . ', '; + continue; + } + + // bugger out on whitespace. form feed (0C) really + // shouldn't show up regardless + $font = str_replace(array("\n", "\t", "\r", "\x0C"), ' ', $font); + + // Here, there are various classes of characters which need + // to be treated differently: + // - Alphanumeric characters are essentially safe. We + // handled these above. + // - Spaces require quoting, though most parsers will do + // the right thing if there aren't any characters that + // can be misinterpreted + // - Dashes rarely occur, but they fairly unproblematic + // for parsing/rendering purposes. + // The above characters cover the majority of Western font + // names. + // - Arbitrary Unicode characters not in ASCII. Because + // most parsers give little thought to Unicode, treatment + // of these codepoints is basically uniform, even for + // punctuation-like codepoints. These characters can + // show up in non-Western pages and are supported by most + // major browsers, for example: "MS 明朝" is a + // legitimate font-name + // . See + // the CSS3 spec for more examples: + // + // You can see live samples of these on the Internet: + // + // However, most of these fonts have ASCII equivalents: + // for example, 'MS Mincho', and it's considered + // professional to use ASCII font names instead of + // Unicode font names. Thanks Takeshi Terada for + // providing this information. + // The following characters, to my knowledge, have not been + // used to name font names. + // - Single quote. While theoretically you might find a + // font name that has a single quote in its name (serving + // as an apostrophe, e.g. Dave's Scribble), I haven't + // been able to find any actual examples of this. + // Internet Explorer's cssText translation (which I + // believe is invoked by innerHTML) normalizes any + // quoting to single quotes, and fails to escape single + // quotes. (Note that this is not IE's behavior for all + // CSS properties, just some sort of special casing for + // font-family). So a single quote *cannot* be used + // safely in the font-family context if there will be an + // innerHTML/cssText translation. Note that Firefox 3.x + // does this too. + // - Double quote. In IE, these get normalized to + // single-quotes, no matter what the encoding. (Fun + // fact, in IE8, the 'content' CSS property gained + // support, where they special cased to preserve encoded + // double quotes, but still translate unadorned double + // quotes into single quotes.) So, because their + // fixpoint behavior is identical to single quotes, they + // cannot be allowed either. Firefox 3.x displays + // single-quote style behavior. + // - Backslashes are reduced by one (so \\ -> \) every + // iteration, so they cannot be used safely. This shows + // up in IE7, IE8 and FF3 + // - Semicolons, commas and backticks are handled properly. + // - The rest of the ASCII punctuation is handled properly. + // We haven't checked what browsers do to unadorned + // versions, but this is not important as long as the + // browser doesn't /remove/ surrounding quotes (as IE does + // for HTML). + // + // With these results in hand, we conclude that there are + // various levels of safety: + // - Paranoid: alphanumeric, spaces and dashes(?) + // - International: Paranoid + non-ASCII Unicode + // - Edgy: Everything except quotes, backslashes + // - NoJS: Standards compliance, e.g. sod IE. Note that + // with some judicious character escaping (since certain + // types of escaping doesn't work) this is theoretically + // OK as long as innerHTML/cssText is not called. + // We believe that international is a reasonable default + // (that we will implement now), and once we do more + // extensive research, we may feel comfortable with dropping + // it down to edgy. + + // Edgy: alphanumeric, spaces, dashes, underscores and Unicode. Use of + // str(c)spn assumes that the string was already well formed + // Unicode (which of course it is). + if (strspn($font, $this->mask) !== strlen($font)) { + continue; + } + + // Historical: + // In the absence of innerHTML/cssText, these ugly + // transforms don't pose a security risk (as \\ and \" + // might--these escapes are not supported by most browsers). + // We could try to be clever and use single-quote wrapping + // when there is a double quote present, but I have choosen + // not to implement that. (NOTE: you can reduce the amount + // of escapes by one depending on what quoting style you use) + // $font = str_replace('\\', '\\5C ', $font); + // $font = str_replace('"', '\\22 ', $font); + // $font = str_replace("'", '\\27 ', $font); + + // font possibly with spaces, requires quoting + $final .= "'$font', "; + } + $final = rtrim($final, ', '); + if ($final === '') { + return false; + } + return $final; + } + +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ident.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ident.php new file mode 100644 index 0000000..973002c --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ident.php @@ -0,0 +1,32 @@ +def = $def; + $this->allow = $allow; + } + + /** + * Intercepts and removes !important if necessary + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + // test for ! and important tokens + $string = trim($string); + $is_important = false; + // :TODO: optimization: test directly for !important and ! important + if (strlen($string) >= 9 && substr($string, -9) === 'important') { + $temp = rtrim(substr($string, 0, -9)); + // use a temp, because we might want to restore important + if (strlen($temp) >= 1 && substr($temp, -1) === '!') { + $string = rtrim(substr($temp, 0, -1)); + $is_important = true; + } + } + $string = $this->def->validate($string, $config, $context); + if ($this->allow && $is_important) { + $string .= ' !important'; + } + return $string; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Length.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Length.php new file mode 100644 index 0000000..f12453a --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Length.php @@ -0,0 +1,77 @@ +min = $min !== null ? HTMLPurifier_Length::make($min) : null; + $this->max = $max !== null ? HTMLPurifier_Length::make($max) : null; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $string = $this->parseCDATA($string); + + // Optimizations + if ($string === '') { + return false; + } + if ($string === '0') { + return '0'; + } + if (strlen($string) === 1) { + return false; + } + + $length = HTMLPurifier_Length::make($string); + if (!$length->isValid()) { + return false; + } + + if ($this->min) { + $c = $length->compareTo($this->min); + if ($c === false) { + return false; + } + if ($c < 0) { + return false; + } + } + if ($this->max) { + $c = $length->compareTo($this->max); + if ($c === false) { + return false; + } + if ($c > 0) { + return false; + } + } + return $length->toString(); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/ListStyle.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/ListStyle.php new file mode 100644 index 0000000..e74d426 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/ListStyle.php @@ -0,0 +1,112 @@ +getCSSDefinition(); + $this->info['list-style-type'] = $def->info['list-style-type']; + $this->info['list-style-position'] = $def->info['list-style-position']; + $this->info['list-style-image'] = $def->info['list-style-image']; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + // regular pre-processing + $string = $this->parseCDATA($string); + if ($string === '') { + return false; + } + + // assumes URI doesn't have spaces in it + $bits = explode(' ', strtolower($string)); // bits to process + + $caught = array(); + $caught['type'] = false; + $caught['position'] = false; + $caught['image'] = false; + + $i = 0; // number of catches + $none = false; + + foreach ($bits as $bit) { + if ($i >= 3) { + return; + } // optimization bit + if ($bit === '') { + continue; + } + foreach ($caught as $key => $status) { + if ($status !== false) { + continue; + } + $r = $this->info['list-style-' . $key]->validate($bit, $config, $context); + if ($r === false) { + continue; + } + if ($r === 'none') { + if ($none) { + continue; + } else { + $none = true; + } + if ($key == 'image') { + continue; + } + } + $caught[$key] = $r; + $i++; + break; + } + } + + if (!$i) { + return false; + } + + $ret = array(); + + // construct type + if ($caught['type']) { + $ret[] = $caught['type']; + } + + // construct image + if ($caught['image']) { + $ret[] = $caught['image']; + } + + // construct position + if ($caught['position']) { + $ret[] = $caught['position']; + } + + if (empty($ret)) { + return false; + } + return implode(' ', $ret); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Multiple.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Multiple.php new file mode 100644 index 0000000..e707f87 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Multiple.php @@ -0,0 +1,71 @@ +single = $single; + $this->max = $max; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $string = $this->mungeRgb($this->parseCDATA($string)); + if ($string === '') { + return false; + } + $parts = explode(' ', $string); // parseCDATA replaced \r, \t and \n + $length = count($parts); + $final = ''; + for ($i = 0, $num = 0; $i < $length && $num < $this->max; $i++) { + if (ctype_space($parts[$i])) { + continue; + } + $result = $this->single->validate($parts[$i], $config, $context); + if ($result !== false) { + $final .= $result . ' '; + $num++; + } + } + if ($final === '') { + return false; + } + return rtrim($final); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Number.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Number.php new file mode 100644 index 0000000..ef49d20 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Number.php @@ -0,0 +1,90 @@ +non_negative = $non_negative; + } + + /** + * @param string $number + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return string|bool + * @warning Some contexts do not pass $config, $context. These + * variables should not be used without checking HTMLPurifier_Length + */ + public function validate($number, $config, $context) + { + $number = $this->parseCDATA($number); + + if ($number === '') { + return false; + } + if ($number === '0') { + return '0'; + } + + $sign = ''; + switch ($number[0]) { + case '-': + if ($this->non_negative) { + return false; + } + $sign = '-'; + case '+': + $number = substr($number, 1); + } + + if (ctype_digit($number)) { + $number = ltrim($number, '0'); + return $number ? $sign . $number : '0'; + } + + // Period is the only non-numeric character allowed + if (strpos($number, '.') === false) { + return false; + } + + list($left, $right) = explode('.', $number, 2); + + if ($left === '' && $right === '') { + return false; + } + if ($left !== '' && !ctype_digit($left)) { + return false; + } + + // Remove leading zeros until positive number or a zero stays left + if (ltrim($left, '0') != '') { + $left = ltrim($left, '0'); + } else { + $left = '0'; + } + + $right = rtrim($right, '0'); + + if ($right === '') { + return $left ? $sign . $left : '0'; + } elseif (!ctype_digit($right)) { + return false; + } + return $sign . $left . '.' . $right; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Percentage.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Percentage.php new file mode 100644 index 0000000..f0f25c5 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Percentage.php @@ -0,0 +1,54 @@ +number_def = new HTMLPurifier_AttrDef_CSS_Number($non_negative); + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $string = $this->parseCDATA($string); + + if ($string === '') { + return false; + } + $length = strlen($string); + if ($length === 1) { + return false; + } + if ($string[$length - 1] !== '%') { + return false; + } + + $number = substr($string, 0, $length - 1); + $number = $this->number_def->validate($number, $config, $context); + + if ($number === false) { + return false; + } + return "$number%"; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ratio.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ratio.php new file mode 100644 index 0000000..e08e2c4 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/Ratio.php @@ -0,0 +1,46 @@ +parseCDATA($ratio); + + $parts = explode('/', $ratio, 2); + $length = count($parts); + + if ($length < 1 || $length > 2) { + return false; + } + + $num = new \HTMLPurifier_AttrDef_CSS_Number(); + + if ($length === 1) { + return $num->validate($parts[0], $config, $context); + } + + $num1 = $num->validate($parts[0], $config, $context); + $num2 = $num->validate($parts[1], $config, $context); + + if ($num1 === false || $num2 === false) { + return false; + } + + return $num1 . '/' . $num2; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php new file mode 100644 index 0000000..5fd4b7f --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/TextDecoration.php @@ -0,0 +1,46 @@ + true, + 'overline' => true, + 'underline' => true, + ); + + $string = strtolower($this->parseCDATA($string)); + + if ($string === 'none') { + return $string; + } + + $parts = explode(' ', $string); + $final = ''; + foreach ($parts as $part) { + if (isset($allowed_values[$part])) { + $final .= $part . ' '; + } + } + $final = rtrim($final); + if ($final === '') { + return false; + } + return $final; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/URI.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/URI.php new file mode 100644 index 0000000..6617aca --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/CSS/URI.php @@ -0,0 +1,77 @@ +parseCDATA($uri_string); + if (strpos($uri_string, 'url(') !== 0) { + return false; + } + $uri_string = substr($uri_string, 4); + if (strlen($uri_string) == 0) { + return false; + } + $new_length = strlen($uri_string) - 1; + if ($uri_string[$new_length] != ')') { + return false; + } + $uri = trim(substr($uri_string, 0, $new_length)); + + if (!empty($uri) && ($uri[0] == "'" || $uri[0] == '"')) { + $quote = $uri[0]; + $new_length = strlen($uri) - 1; + if ($uri[$new_length] !== $quote) { + return false; + } + $uri = substr($uri, 1, $new_length - 1); + } + + $uri = $this->expandCSSEscape($uri); + + $result = parent::validate($uri, $config, $context); + + if ($result === false) { + return false; + } + + // extra sanity check; should have been done by URI + $result = str_replace(array('"', "\\", "\n", "\x0c", "\r"), "", $result); + + // suspicious characters are ()'; we're going to percent encode + // them for safety. + $result = str_replace(array('(', ')', "'"), array('%28', '%29', '%27'), $result); + + // there's an extra bug where ampersands lose their escaping on + // an innerHTML cycle, so a very unlucky query parameter could + // then change the meaning of the URL. Unfortunately, there's + // not much we can do about that... + return "url(\"$result\")"; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Clone.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Clone.php new file mode 100644 index 0000000..6698a00 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Clone.php @@ -0,0 +1,44 @@ +clone = $clone; + } + + /** + * @param string $v + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($v, $config, $context) + { + return $this->clone->validate($v, $config, $context); + } + + /** + * @param string $string + * @return HTMLPurifier_AttrDef + */ + public function make($string) + { + return clone $this->clone; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Enum.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Enum.php new file mode 100644 index 0000000..8abda7f --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Enum.php @@ -0,0 +1,73 @@ +valid_values = array_flip($valid_values); + $this->case_sensitive = $case_sensitive; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $string = trim($string); + if (!$this->case_sensitive) { + // we may want to do full case-insensitive libraries + $string = ctype_lower($string) ? $string : strtolower($string); + } + $result = isset($this->valid_values[$string]); + + return $result ? $string : false; + } + + /** + * @param string $string In form of comma-delimited list of case-insensitive + * valid values. Example: "foo,bar,baz". Prepend "s:" to make + * case sensitive + * @return HTMLPurifier_AttrDef_Enum + */ + public function make($string) + { + if (strlen($string) > 2 && $string[0] == 's' && $string[1] == ':') { + $string = substr($string, 2); + $sensitive = true; + } else { + $sensitive = false; + } + $values = explode(',', $string); + return new HTMLPurifier_AttrDef_Enum($values, $sensitive); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Bool.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Bool.php new file mode 100644 index 0000000..be3bbc8 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Bool.php @@ -0,0 +1,48 @@ +name = $name; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + return $this->name; + } + + /** + * @param string $string Name of attribute + * @return HTMLPurifier_AttrDef_HTML_Bool + */ + public function make($string) + { + return new HTMLPurifier_AttrDef_HTML_Bool($string); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Class.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Class.php new file mode 100644 index 0000000..d501348 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Class.php @@ -0,0 +1,48 @@ +getDefinition('HTML')->doctype->name; + if ($name == "XHTML 1.1" || $name == "XHTML 2.0") { + return parent::split($string, $config, $context); + } else { + return preg_split('/\s+/', $string); + } + } + + /** + * @param array $tokens + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + protected function filter($tokens, $config, $context) + { + $allowed = $config->get('Attr.AllowedClasses'); + $forbidden = $config->get('Attr.ForbiddenClasses'); + $ret = array(); + foreach ($tokens as $token) { + if (($allowed === null || isset($allowed[$token])) && + !isset($forbidden[$token]) && + // We need this O(n) check because of PHP's array + // implementation that casts -0 to 0. + !in_array($token, $ret, true) + ) { + $ret[] = $token; + } + } + return $ret; + } +} diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Color.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Color.php new file mode 100644 index 0000000..946ebb7 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Color.php @@ -0,0 +1,51 @@ +get('Core.ColorKeywords'); + } + + $string = trim($string); + + if (empty($string)) { + return false; + } + $lower = strtolower($string); + if (isset($colors[$lower])) { + return $colors[$lower]; + } + if ($string[0] === '#') { + $hex = substr($string, 1); + } else { + $hex = $string; + } + + $length = strlen($hex); + if ($length !== 3 && $length !== 6) { + return false; + } + if (!ctype_xdigit($hex)) { + return false; + } + if ($length === 3) { + $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; + } + return "#$hex"; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ContentEditable.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ContentEditable.php new file mode 100644 index 0000000..5b03d3e --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ContentEditable.php @@ -0,0 +1,16 @@ +get('HTML.Trusted')) { + $allowed = array('', 'true', 'false'); + } + + $enum = new HTMLPurifier_AttrDef_Enum($allowed); + + return $enum->validate($string, $config, $context); + } +} diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/FrameTarget.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/FrameTarget.php new file mode 100644 index 0000000..d79ba12 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/FrameTarget.php @@ -0,0 +1,38 @@ +valid_values === false) { + $this->valid_values = $config->get('Attr.AllowedFrameTargets'); + } + return parent::validate($string, $config, $context); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ID.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ID.php new file mode 100644 index 0000000..4ba4561 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/ID.php @@ -0,0 +1,113 @@ +selector = $selector; + } + + /** + * @param string $id + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($id, $config, $context) + { + if (!$this->selector && !$config->get('Attr.EnableID')) { + return false; + } + + $id = trim($id); // trim it first + + if ($id === '') { + return false; + } + + $prefix = $config->get('Attr.IDPrefix'); + if ($prefix !== '') { + $prefix .= $config->get('Attr.IDPrefixLocal'); + // prevent re-appending the prefix + if (strpos($id, $prefix) !== 0) { + $id = $prefix . $id; + } + } elseif ($config->get('Attr.IDPrefixLocal') !== '') { + trigger_error( + '%Attr.IDPrefixLocal cannot be used unless ' . + '%Attr.IDPrefix is set', + E_USER_WARNING + ); + } + + if (!$this->selector) { + $id_accumulator =& $context->get('IDAccumulator'); + if (isset($id_accumulator->ids[$id])) { + return false; + } + } + + // we purposely avoid using regex, hopefully this is faster + + if ($config->get('Attr.ID.HTML5') === true) { + if (preg_match('/[\t\n\x0b\x0c ]/', $id)) { + return false; + } + } else { + if (ctype_alpha($id)) { + // OK + } else { + if (!ctype_alpha(@$id[0])) { + return false; + } + // primitive style of regexps, I suppose + $trim = trim( + $id, + 'A..Za..z0..9:-._' + ); + if ($trim !== '') { + return false; + } + } + } + + $regexp = $config->get('Attr.IDBlacklistRegexp'); + if ($regexp && preg_match($regexp, $id)) { + return false; + } + + if (!$this->selector) { + $id_accumulator->add($id); + } + + // if no change was made to the ID, return the result + // else, return the new id if stripping whitespace made it + // valid, or return false. + return $id; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Length.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Length.php new file mode 100644 index 0000000..1c4006f --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Length.php @@ -0,0 +1,56 @@ + 100) { + return '100%'; + } + return ((string)$points) . '%'; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php new file mode 100644 index 0000000..63fa04c --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/LinkTypes.php @@ -0,0 +1,72 @@ + 'AllowedRel', + 'rev' => 'AllowedRev' + ); + if (!isset($configLookup[$name])) { + trigger_error( + 'Unrecognized attribute name for link ' . + 'relationship.', + E_USER_ERROR + ); + return; + } + $this->name = $configLookup[$name]; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $allowed = $config->get('Attr.' . $this->name); + if (empty($allowed)) { + return false; + } + + $string = $this->parseCDATA($string); + $parts = explode(' ', $string); + + // lookup to prevent duplicates + $ret_lookup = array(); + foreach ($parts as $part) { + $part = strtolower(trim($part)); + if (!isset($allowed[$part])) { + continue; + } + $ret_lookup[$part] = true; + } + + if (empty($ret_lookup)) { + return false; + } + $string = implode(' ', array_keys($ret_lookup)); + return $string; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/MultiLength.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/MultiLength.php new file mode 100644 index 0000000..bbb20f2 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/MultiLength.php @@ -0,0 +1,60 @@ +split($string, $config, $context); + $tokens = $this->filter($tokens, $config, $context); + if (empty($tokens)) { + return false; + } + return implode(' ', $tokens); + } + + /** + * Splits a space separated list of tokens into its constituent parts. + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + protected function split($string, $config, $context) + { + // OPTIMIZABLE! + // do the preg_match, capture all subpatterns for reformulation + + // we don't support U+00A1 and up codepoints or + // escaping because I don't know how to do that with regexps + // and plus it would complicate optimization efforts (you never + // see that anyway). + $pattern = '/(?:(?<=\s)|\A)' . // look behind for space or string start + '((?:--|-?[A-Za-z_])[A-Za-z_\-0-9]*)' . + '(?:(?=\s)|\z)/'; // look ahead for space or string end + preg_match_all($pattern, $string, $matches); + return $matches[1]; + } + + /** + * Template method for removing certain tokens based on arbitrary criteria. + * @note If we wanted to be really functional, we'd do an array_filter + * with a callback. But... we're not. + * @param array $tokens + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + protected function filter($tokens, $config, $context) + { + return $tokens; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Pixels.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Pixels.php new file mode 100644 index 0000000..a1d019e --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/HTML/Pixels.php @@ -0,0 +1,76 @@ +max = $max; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $string = trim($string); + if ($string === '0') { + return $string; + } + if ($string === '') { + return false; + } + $length = strlen($string); + if (substr($string, $length - 2) == 'px') { + $string = substr($string, 0, $length - 2); + } + if (!is_numeric($string)) { + return false; + } + $int = (int)$string; + + if ($int < 0) { + return '0'; + } + + // upper-bound value, extremely high values can + // crash operating systems, see + // WARNING, above link WILL crash you if you're using Windows + + if ($this->max !== null && $int > $this->max) { + return (string)$this->max; + } + return (string)$int; + } + + /** + * @param string $string + * @return HTMLPurifier_AttrDef + */ + public function make($string) + { + if ($string === '') { + $max = null; + } else { + $max = (int)$string; + } + $class = get_class($this); + return new $class($max); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Integer.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Integer.php new file mode 100644 index 0000000..400e707 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Integer.php @@ -0,0 +1,91 @@ +negative = $negative; + $this->zero = $zero; + $this->positive = $positive; + } + + /** + * @param string $integer + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($integer, $config, $context) + { + $integer = $this->parseCDATA($integer); + if ($integer === '') { + return false; + } + + // we could possibly simply typecast it to integer, but there are + // certain fringe cases that must not return an integer. + + // clip leading sign + if ($this->negative && $integer[0] === '-') { + $digits = substr($integer, 1); + if ($digits === '0') { + $integer = '0'; + } // rm minus sign for zero + } elseif ($this->positive && $integer[0] === '+') { + $digits = $integer = substr($integer, 1); // rm unnecessary plus + } else { + $digits = $integer; + } + + // test if it's numeric + if (!ctype_digit($digits)) { + return false; + } + + // perform scope tests + if (!$this->zero && $integer == 0) { + return false; + } + if (!$this->positive && $integer > 0) { + return false; + } + if (!$this->negative && $integer < 0) { + return false; + } + + return $integer; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Lang.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Lang.php new file mode 100644 index 0000000..2a55cea --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Lang.php @@ -0,0 +1,86 @@ + 8 || !ctype_alnum($subtags[1])) { + return $new_string; + } + if (!ctype_lower($subtags[1])) { + $subtags[1] = strtolower($subtags[1]); + } + + $new_string .= '-' . $subtags[1]; + if ($num_subtags == 2) { + return $new_string; + } + + // process all other subtags, index 2 and up + for ($i = 2; $i < $num_subtags; $i++) { + $length = strlen($subtags[$i]); + if ($length == 0 || $length > 8 || !ctype_alnum($subtags[$i])) { + return $new_string; + } + if (!ctype_lower($subtags[$i])) { + $subtags[$i] = strtolower($subtags[$i]); + } + $new_string .= '-' . $subtags[$i]; + } + return $new_string; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Switch.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Switch.php new file mode 100644 index 0000000..c7eb319 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Switch.php @@ -0,0 +1,53 @@ +tag = $tag; + $this->withTag = $with_tag; + $this->withoutTag = $without_tag; + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $token = $context->get('CurrentToken', true); + if (!$token || $token->name !== $this->tag) { + return $this->withoutTag->validate($string, $config, $context); + } else { + return $this->withTag->validate($string, $config, $context); + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Text.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Text.php new file mode 100644 index 0000000..4553a4e --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/Text.php @@ -0,0 +1,21 @@ +parseCDATA($string); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI.php new file mode 100644 index 0000000..c1cd897 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI.php @@ -0,0 +1,111 @@ +parser = new HTMLPurifier_URIParser(); + $this->embedsResource = (bool)$embeds_resource; + } + + /** + * @param string $string + * @return HTMLPurifier_AttrDef_URI + */ + public function make($string) + { + $embeds = ($string === 'embedded'); + return new HTMLPurifier_AttrDef_URI($embeds); + } + + /** + * @param string $uri + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($uri, $config, $context) + { + if ($config->get('URI.Disable')) { + return false; + } + + $uri = $this->parseCDATA($uri); + + // parse the URI + $uri = $this->parser->parse($uri); + if ($uri === false) { + return false; + } + + // add embedded flag to context for validators + $context->register('EmbeddedURI', $this->embedsResource); + + $ok = false; + do { + + // generic validation + $result = $uri->validate($config, $context); + if (!$result) { + break; + } + + // chained filtering + $uri_def = $config->getDefinition('URI'); + $result = $uri_def->filter($uri, $config, $context); + if (!$result) { + break; + } + + // scheme-specific validation + $scheme_obj = $uri->getSchemeObj($config, $context); + if (!$scheme_obj) { + break; + } + if ($this->embedsResource && !$scheme_obj->browsable) { + break; + } + $result = $scheme_obj->validate($uri, $config, $context); + if (!$result) { + break; + } + + // Post chained filtering + $result = $uri_def->postFilter($uri, $config, $context); + if (!$result) { + break; + } + + // survived gauntlet + $ok = true; + + } while (false); + + $context->destroy('EmbeddedURI'); + if (!$ok) { + return false; + } + // back to string + return $uri->toString(); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Email.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Email.php new file mode 100644 index 0000000..daf32b7 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Email.php @@ -0,0 +1,20 @@ +" + // that needs more percent encoding to be done + if ($string == '') { + return false; + } + $string = trim($string); + $result = preg_match('/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $string); + return $result ? $string : false; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php new file mode 100644 index 0000000..17a97c1 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/Host.php @@ -0,0 +1,136 @@ +ipv4 = new HTMLPurifier_AttrDef_URI_IPv4(); + $this->ipv6 = new HTMLPurifier_AttrDef_URI_IPv6(); + } + + /** + * @param string $string + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool|string + */ + public function validate($string, $config, $context) + { + $length = strlen($string); + // empty hostname is OK; it's usually semantically equivalent: + // the default host as defined by a URI scheme is used: + // + // If the URI scheme defines a default for host, then that + // default applies when the host subcomponent is undefined + // or when the registered name is empty (zero length). + if ($string === '') { + return ''; + } + if ($length > 1 && $string[0] === '[' && $string[$length - 1] === ']') { + //IPv6 + $ip = substr($string, 1, $length - 2); + $valid = $this->ipv6->validate($ip, $config, $context); + if ($valid === false) { + return false; + } + return '[' . $valid . ']'; + } + + // need to do checks on unusual encodings too + $ipv4 = $this->ipv4->validate($string, $config, $context); + if ($ipv4 !== false) { + return $ipv4; + } + + // A regular domain name. + + // This doesn't match I18N domain names, but we don't have proper IRI support, + // so force users to insert Punycode. + + // Underscores defined as Unreserved Characters in RFC 3986 are + // allowed in a URI. There are cases where we want to consider a + // URI containing "_" such as "_dmarc.example.com". + // Underscores are not allowed in the default. If you want to + // allow it, set Core.AllowHostnameUnderscore to true. + $underscore = $config->get('Core.AllowHostnameUnderscore') ? '_' : ''; + + // Based off of RFC 1738, but amended so that + // as per RFC 3696, the top label need only not be all numeric. + // The productions describing this are: + $a = '[a-z]'; // alpha + $an = "[a-z0-9$underscore]"; // alphanum + $and = "[a-z0-9-$underscore]"; // alphanum | "-" + // domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum + $domainlabel = "$an(?:$and*$an)?"; + // AMENDED as per RFC 3696 + // toplabel = alphanum | alphanum *( alphanum | "-" ) alphanum + // side condition: not all numeric + $toplabel = "$an(?:$and*$an)?"; + // hostname = *( domainlabel "." ) toplabel [ "." ] + if (preg_match("/^(?:$domainlabel\.)*($toplabel)\.?$/i", $string, $matches)) { + if (!ctype_digit($matches[1])) { + return $string; + } + } + + // PHP 5.3 and later support this functionality natively + if (function_exists('idn_to_ascii')) { + if (defined('IDNA_NONTRANSITIONAL_TO_ASCII') && defined('INTL_IDNA_VARIANT_UTS46')) { + $string = idn_to_ascii($string, IDNA_NONTRANSITIONAL_TO_ASCII, INTL_IDNA_VARIANT_UTS46); + } else { + $string = idn_to_ascii($string); + } + + // If we have Net_IDNA2 support, we can support IRIs by + // punycoding them. (This is the most portable thing to do, + // since otherwise we have to assume browsers support + } elseif ($config->get('Core.EnableIDNA') && class_exists('Net_IDNA2')) { + $idna = new Net_IDNA2(array('encoding' => 'utf8', 'overlong' => false, 'strict' => true)); + // we need to encode each period separately + $parts = explode('.', $string); + try { + $new_parts = array(); + foreach ($parts as $part) { + $encodable = false; + for ($i = 0, $c = strlen($part); $i < $c; $i++) { + if (ord($part[$i]) > 0x7a) { + $encodable = true; + break; + } + } + if (!$encodable) { + $new_parts[] = $part; + } else { + $new_parts[] = $idna->encode($part); + } + } + $string = implode('.', $new_parts); + } catch (Exception $e) { + // XXX error reporting + } + } + // Try again + if (preg_match("/^($domainlabel\.)*$toplabel\.?$/i", $string)) { + return $string; + } + return false; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/IPv4.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/IPv4.php new file mode 100644 index 0000000..30ac16c --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/IPv4.php @@ -0,0 +1,45 @@ +ip4) { + $this->_loadRegex(); + } + + if (preg_match('#^' . $this->ip4 . '$#s', $aIP)) { + return $aIP; + } + return false; + } + + /** + * Lazy load function to prevent regex from being stuffed in + * cache. + */ + protected function _loadRegex() + { + $oct = '(?:25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9][0-9]|[0-9])'; // 0-255 + $this->ip4 = "(?:{$oct}\\.{$oct}\\.{$oct}\\.{$oct})"; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/IPv6.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/IPv6.php new file mode 100644 index 0000000..f243793 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrDef/URI/IPv6.php @@ -0,0 +1,89 @@ +ip4) { + $this->_loadRegex(); + } + + $original = $aIP; + + $hex = '[0-9a-fA-F]'; + $blk = '(?:' . $hex . '{1,4})'; + $pre = '(?:/(?:12[0-8]|1[0-1][0-9]|[1-9][0-9]|[0-9]))'; // /0 - /128 + + // prefix check + if (strpos($aIP, '/') !== false) { + if (preg_match('#' . $pre . '$#s', $aIP, $find)) { + $aIP = substr($aIP, 0, 0 - strlen($find[0])); + unset($find); + } else { + return false; + } + } + + // IPv4-compatiblity check + if (preg_match('#(?<=:' . ')' . $this->ip4 . '$#s', $aIP, $find)) { + $aIP = substr($aIP, 0, 0 - strlen($find[0])); + $ip = explode('.', $find[0]); + $ip = array_map('dechex', $ip); + $aIP .= $ip[0] . $ip[1] . ':' . $ip[2] . $ip[3]; + unset($find, $ip); + } + + // compression check + $aIP = explode('::', $aIP); + $c = count($aIP); + if ($c > 2) { + return false; + } elseif ($c == 2) { + list($first, $second) = $aIP; + $first = explode(':', $first); + $second = explode(':', $second); + + if (count($first) + count($second) > 8) { + return false; + } + + while (count($first) < 8) { + array_push($first, '0'); + } + + array_splice($first, 8 - count($second), 8, $second); + $aIP = $first; + unset($first, $second); + } else { + $aIP = explode(':', $aIP[0]); + } + $c = count($aIP); + + if ($c != 8) { + return false; + } + + // All the pieces should be 16-bit hex strings. Are they? + foreach ($aIP as $piece) { + if (!preg_match('#^[0-9a-fA-F]{4}$#s', sprintf('%04s', $piece))) { + return false; + } + } + return $original; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform.php new file mode 100644 index 0000000..b428331 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform.php @@ -0,0 +1,60 @@ +confiscateAttr($attr, 'background'); + // some validation should happen here + + $this->prependCSS($attr, "background-image:url($background);"); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BdoDir.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BdoDir.php new file mode 100644 index 0000000..d66c04a --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BdoDir.php @@ -0,0 +1,27 @@ +get('Attr.DefaultTextDir'); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BgColor.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BgColor.php new file mode 100644 index 0000000..0f51fd2 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BgColor.php @@ -0,0 +1,28 @@ +confiscateAttr($attr, 'bgcolor'); + // some validation should happen here + + $this->prependCSS($attr, "background-color:$bgcolor;"); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BoolToCSS.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BoolToCSS.php new file mode 100644 index 0000000..f25cd01 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/BoolToCSS.php @@ -0,0 +1,47 @@ +attr = $attr; + $this->css = $css; + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr[$this->attr])) { + return $attr; + } + unset($attr[$this->attr]); + $this->prependCSS($attr, $this->css); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Border.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Border.php new file mode 100644 index 0000000..057dc01 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Border.php @@ -0,0 +1,26 @@ +confiscateAttr($attr, 'border'); + // some validation should happen here + $this->prependCSS($attr, "border:{$border_width}px solid;"); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/EnumToCSS.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/EnumToCSS.php new file mode 100644 index 0000000..7ccd0e3 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/EnumToCSS.php @@ -0,0 +1,68 @@ +attr = $attr; + $this->enumToCSS = $enum_to_css; + $this->caseSensitive = (bool)$case_sensitive; + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr[$this->attr])) { + return $attr; + } + + $value = trim($attr[$this->attr]); + unset($attr[$this->attr]); + + if (!$this->caseSensitive) { + $value = strtolower($value); + } + + if (!isset($this->enumToCSS[$value])) { + return $attr; + } + $this->prependCSS($attr, $this->enumToCSS[$value]); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ImgRequired.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ImgRequired.php new file mode 100644 index 0000000..235ebb3 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ImgRequired.php @@ -0,0 +1,47 @@ +get('Core.RemoveInvalidImg')) { + return $attr; + } + $attr['src'] = $config->get('Attr.DefaultInvalidImage'); + $src = false; + } + + if (!isset($attr['alt'])) { + if ($src) { + $alt = $config->get('Attr.DefaultImageAlt'); + if ($alt === null) { + $attr['alt'] = basename($attr['src']); + } else { + $attr['alt'] = $alt; + } + } else { + $attr['alt'] = $config->get('Attr.DefaultInvalidImageAlt'); + } + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ImgSpace.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ImgSpace.php new file mode 100644 index 0000000..350b335 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ImgSpace.php @@ -0,0 +1,61 @@ + array('left', 'right'), + 'vspace' => array('top', 'bottom') + ); + + /** + * @param string $attr + */ + public function __construct($attr) + { + $this->attr = $attr; + if (!isset($this->css[$attr])) { + trigger_error(htmlspecialchars($attr) . ' is not valid space attribute'); + } + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr[$this->attr])) { + return $attr; + } + + $width = $this->confiscateAttr($attr, $this->attr); + // some validation could happen here + + if (!isset($this->css[$this->attr])) { + return $attr; + } + + $style = ''; + foreach ($this->css[$this->attr] as $suffix) { + $property = "margin-$suffix"; + $style .= "$property:{$width}px;"; + } + $this->prependCSS($attr, $style); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Input.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Input.php new file mode 100644 index 0000000..3ab47ed --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Input.php @@ -0,0 +1,56 @@ +pixels = new HTMLPurifier_AttrDef_HTML_Pixels(); + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr['type'])) { + $t = 'text'; + } else { + $t = strtolower($attr['type']); + } + if (isset($attr['checked']) && $t !== 'radio' && $t !== 'checkbox') { + unset($attr['checked']); + } + if (isset($attr['maxlength']) && $t !== 'text' && $t !== 'password') { + unset($attr['maxlength']); + } + if (isset($attr['size']) && $t !== 'text' && $t !== 'password') { + $result = $this->pixels->validate($attr['size'], $config, $context); + if ($result === false) { + unset($attr['size']); + } else { + $attr['size'] = $result; + } + } + if (isset($attr['src']) && $t !== 'image') { + unset($attr['src']); + } + if (!isset($attr['value']) && ($t === 'radio' || $t === 'checkbox')) { + $attr['value'] = ''; + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Lang.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Lang.php new file mode 100644 index 0000000..5b0aff0 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Lang.php @@ -0,0 +1,31 @@ +name = $name; + $this->cssName = $css_name ? $css_name : $name; + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr[$this->name])) { + return $attr; + } + $length = $this->confiscateAttr($attr, $this->name); + if (ctype_digit($length)) { + $length .= 'px'; + } + $this->prependCSS($attr, $this->cssName . ":$length;"); + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Name.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Name.php new file mode 100644 index 0000000..63cce68 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Name.php @@ -0,0 +1,33 @@ +get('HTML.Attr.Name.UseCDATA')) { + return $attr; + } + if (!isset($attr['name'])) { + return $attr; + } + $id = $this->confiscateAttr($attr, 'name'); + if (isset($attr['id'])) { + return $attr; + } + $attr['id'] = $id; + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/NameSync.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/NameSync.php new file mode 100644 index 0000000..5a1fdbb --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/NameSync.php @@ -0,0 +1,46 @@ +idDef = new HTMLPurifier_AttrDef_HTML_ID(); + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr['name'])) { + return $attr; + } + $name = $attr['name']; + if (isset($attr['id']) && $attr['id'] === $name) { + return $attr; + } + $result = $this->idDef->validate($name, $config, $context); + if ($result === false) { + unset($attr['name']); + } else { + $attr['name'] = $result; + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Nofollow.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Nofollow.php new file mode 100644 index 0000000..1057ebe --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/Nofollow.php @@ -0,0 +1,52 @@ +parser = new HTMLPurifier_URIParser(); + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr['href'])) { + return $attr; + } + + // XXX Kind of inefficient + $url = $this->parser->parse($attr['href']); + $scheme = $url->getSchemeObj($config, $context); + + if ($scheme->browsable && !$url->isLocal($config, $context)) { + if (isset($attr['rel'])) { + $rels = explode(' ', $attr['rel']); + if (!in_array('nofollow', $rels)) { + $rels[] = 'nofollow'; + } + $attr['rel'] = implode(' ', $rels); + } else { + $attr['rel'] = 'nofollow'; + } + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/SafeEmbed.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/SafeEmbed.php new file mode 100644 index 0000000..231c81a --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/SafeEmbed.php @@ -0,0 +1,25 @@ +uri = new HTMLPurifier_AttrDef_URI(true); // embedded + $this->wmode = new HTMLPurifier_AttrDef_Enum(array('window', 'opaque', 'transparent')); + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + // If we add support for other objects, we'll need to alter the + // transforms. + switch ($attr['name']) { + // application/x-shockwave-flash + // Keep this synchronized with Injector/SafeObject.php + case 'allowScriptAccess': + $attr['value'] = 'never'; + break; + case 'allowNetworking': + $attr['value'] = 'internal'; + break; + case 'allowFullScreen': + if ($config->get('HTML.FlashAllowFullScreen')) { + $attr['value'] = ($attr['value'] == 'true') ? 'true' : 'false'; + } else { + $attr['value'] = 'false'; + } + break; + case 'wmode': + $attr['value'] = $this->wmode->validate($attr['value'], $config, $context); + break; + case 'movie': + case 'src': + $attr['name'] = "movie"; + $attr['value'] = $this->uri->validate($attr['value'], $config, $context); + break; + case 'flashvars': + // we're going to allow arbitrary inputs to the SWF, on + // the reasoning that it could only hack the SWF, not us. + break; + // add other cases to support other param name/value pairs + default: + $attr['name'] = $attr['value'] = null; + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ScriptRequired.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ScriptRequired.php new file mode 100644 index 0000000..b7057bb --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/ScriptRequired.php @@ -0,0 +1,23 @@ + + */ +class HTMLPurifier_AttrTransform_ScriptRequired extends HTMLPurifier_AttrTransform +{ + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr['type'])) { + $attr['type'] = 'text/javascript'; + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetBlank.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetBlank.php new file mode 100644 index 0000000..cc30ab8 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetBlank.php @@ -0,0 +1,49 @@ +parser = new HTMLPurifier_URIParser(); + } + + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + if (!isset($attr['href'])) { + return $attr; + } + + // XXX Kind of inefficient + $url = $this->parser->parse($attr['href']); + + // Ignore invalid schemes (e.g. `javascript:`) + if (!($scheme = $url->getSchemeObj($config, $context))) { + return $attr; + } + + if ($scheme->browsable && !$url->isBenign($config, $context)) { + $attr['target'] = '_blank'; + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetNoopener.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetNoopener.php new file mode 100644 index 0000000..1db3c6c --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTransform/TargetNoopener.php @@ -0,0 +1,37 @@ + + */ +class HTMLPurifier_AttrTransform_Textarea extends HTMLPurifier_AttrTransform +{ + /** + * @param array $attr + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function transform($attr, $config, $context) + { + // Calculated from Firefox + if (!isset($attr['cols'])) { + $attr['cols'] = '22'; + } + if (!isset($attr['rows'])) { + $attr['rows'] = '3'; + } + return $attr; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTypes.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTypes.php new file mode 100644 index 0000000..e4429e8 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrTypes.php @@ -0,0 +1,97 @@ +info['Enum'] = new HTMLPurifier_AttrDef_Enum(); + $this->info['Bool'] = new HTMLPurifier_AttrDef_HTML_Bool(); + + $this->info['CDATA'] = new HTMLPurifier_AttrDef_Text(); + $this->info['ID'] = new HTMLPurifier_AttrDef_HTML_ID(); + $this->info['Length'] = new HTMLPurifier_AttrDef_HTML_Length(); + $this->info['MultiLength'] = new HTMLPurifier_AttrDef_HTML_MultiLength(); + $this->info['NMTOKENS'] = new HTMLPurifier_AttrDef_HTML_Nmtokens(); + $this->info['Pixels'] = new HTMLPurifier_AttrDef_HTML_Pixels(); + $this->info['Text'] = new HTMLPurifier_AttrDef_Text(); + $this->info['URI'] = new HTMLPurifier_AttrDef_URI(); + $this->info['LanguageCode'] = new HTMLPurifier_AttrDef_Lang(); + $this->info['Color'] = new HTMLPurifier_AttrDef_HTML_Color(); + $this->info['IAlign'] = self::makeEnum('top,middle,bottom,left,right'); + $this->info['LAlign'] = self::makeEnum('top,bottom,left,right'); + $this->info['FrameTarget'] = new HTMLPurifier_AttrDef_HTML_FrameTarget(); + $this->info['ContentEditable'] = new HTMLPurifier_AttrDef_HTML_ContentEditable(); + + // unimplemented aliases + $this->info['ContentType'] = new HTMLPurifier_AttrDef_Text(); + $this->info['ContentTypes'] = new HTMLPurifier_AttrDef_Text(); + $this->info['Charsets'] = new HTMLPurifier_AttrDef_Text(); + $this->info['Character'] = new HTMLPurifier_AttrDef_Text(); + + // "proprietary" types + $this->info['Class'] = new HTMLPurifier_AttrDef_HTML_Class(); + + // number is really a positive integer (one or more digits) + // FIXME: ^^ not always, see start and value of list items + $this->info['Number'] = new HTMLPurifier_AttrDef_Integer(false, false, true); + } + + private static function makeEnum($in) + { + return new HTMLPurifier_AttrDef_Clone(new HTMLPurifier_AttrDef_Enum(explode(',', $in))); + } + + /** + * Retrieves a type + * @param string $type String type name + * @return HTMLPurifier_AttrDef Object AttrDef for type + */ + public function get($type) + { + // determine if there is any extra info tacked on + if (strpos($type, '#') !== false) { + list($type, $string) = explode('#', $type, 2); + } else { + $string = ''; + } + + if (!isset($this->info[$type])) { + trigger_error('Cannot retrieve undefined attribute type ' . $type, E_USER_ERROR); + return; + } + return $this->info[$type]->make($string); + } + + /** + * Sets a new implementation for a type + * @param string $type String type name + * @param HTMLPurifier_AttrDef $impl Object AttrDef for type + */ + public function set($type, $impl) + { + $this->info[$type] = $impl; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrValidator.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrValidator.php new file mode 100644 index 0000000..f97dc93 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/AttrValidator.php @@ -0,0 +1,178 @@ +getHTMLDefinition(); + $e =& $context->get('ErrorCollector', true); + + // initialize IDAccumulator if necessary + $ok =& $context->get('IDAccumulator', true); + if (!$ok) { + $id_accumulator = HTMLPurifier_IDAccumulator::build($config, $context); + $context->register('IDAccumulator', $id_accumulator); + } + + // initialize CurrentToken if necessary + $current_token =& $context->get('CurrentToken', true); + if (!$current_token) { + $context->register('CurrentToken', $token); + } + + if (!$token instanceof HTMLPurifier_Token_Start && + !$token instanceof HTMLPurifier_Token_Empty + ) { + return; + } + + // create alias to global definition array, see also $defs + // DEFINITION CALL + $d_defs = $definition->info_global_attr; + + // don't update token until the very end, to ensure an atomic update + $attr = $token->attr; + + // do global transformations (pre) + // nothing currently utilizes this + foreach ($definition->info_attr_transform_pre as $transform) { + $attr = $transform->transform($o = $attr, $config, $context); + if ($e) { + if ($attr != $o) { + $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); + } + } + } + + // do local transformations only applicable to this element (pre) + // ex.

to

+ foreach ($definition->info[$token->name]->attr_transform_pre as $transform) { + $attr = $transform->transform($o = $attr, $config, $context); + if ($e) { + if ($attr != $o) { + $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); + } + } + } + + // create alias to this element's attribute definition array, see + // also $d_defs (global attribute definition array) + // DEFINITION CALL + $defs = $definition->info[$token->name]->attr; + + $attr_key = false; + $context->register('CurrentAttr', $attr_key); + + // iterate through all the attribute keypairs + // Watch out for name collisions: $key has previously been used + foreach ($attr as $attr_key => $value) { + + // call the definition + if (isset($defs[$attr_key])) { + // there is a local definition defined + if ($defs[$attr_key] === false) { + // We've explicitly been told not to allow this element. + // This is usually when there's a global definition + // that must be overridden. + // Theoretically speaking, we could have a + // AttrDef_DenyAll, but this is faster! + $result = false; + } else { + // validate according to the element's definition + $result = $defs[$attr_key]->validate( + $value, + $config, + $context + ); + } + } elseif (isset($d_defs[$attr_key])) { + // there is a global definition defined, validate according + // to the global definition + $result = $d_defs[$attr_key]->validate( + $value, + $config, + $context + ); + } else { + // system never heard of the attribute? DELETE! + $result = false; + } + + // put the results into effect + if ($result === false || $result === null) { + // this is a generic error message that should replaced + // with more specific ones when possible + if ($e) { + $e->send(E_ERROR, 'AttrValidator: Attribute removed'); + } + + // remove the attribute + unset($attr[$attr_key]); + } elseif (is_string($result)) { + // generally, if a substitution is happening, there + // was some sort of implicit correction going on. We'll + // delegate it to the attribute classes to say exactly what. + + // simple substitution + $attr[$attr_key] = $result; + } else { + // nothing happens + } + + // we'd also want slightly more complicated substitution + // involving an array as the return value, + // although we're not sure how colliding attributes would + // resolve (certain ones would be completely overriden, + // others would prepend themselves). + } + + $context->destroy('CurrentAttr'); + + // post transforms + + // global (error reporting untested) + foreach ($definition->info_attr_transform_post as $transform) { + $attr = $transform->transform($o = $attr, $config, $context); + if ($e) { + if ($attr != $o) { + $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); + } + } + } + + // local (error reporting untested) + foreach ($definition->info[$token->name]->attr_transform_post as $transform) { + $attr = $transform->transform($o = $attr, $config, $context); + if ($e) { + if ($attr != $o) { + $e->send(E_NOTICE, 'AttrValidator: Attributes transformed', $o, $attr); + } + } + } + + $token->attr = $attr; + + // destroy CurrentToken if we made it ourselves + if (!$current_token) { + $context->destroy('CurrentToken'); + } + + } + + +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Bootstrap.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Bootstrap.php new file mode 100644 index 0000000..bd8f998 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Bootstrap.php @@ -0,0 +1,91 @@ + +if (!defined('PHP_EOL')) { + switch (strtoupper(substr(PHP_OS, 0, 3))) { + case 'WIN': + define('PHP_EOL', "\r\n"); + break; + case 'DAR': + define('PHP_EOL', "\r"); + break; + default: + define('PHP_EOL', "\n"); + } +} + +/** + * Bootstrap class that contains meta-functionality for HTML Purifier such as + * the autoload function. + * + * @note + * This class may be used without any other files from HTML Purifier. + */ +class HTMLPurifier_Bootstrap +{ + + /** + * Autoload function for HTML Purifier + * @param string $class Class to load + * @return bool + */ + public static function autoload($class) + { + $file = HTMLPurifier_Bootstrap::getPath($class); + if (!$file) { + return false; + } + // Technically speaking, it should be ok and more efficient to + // just do 'require', but Antonio Parraga reports that with + // Zend extensions such as Zend debugger and APC, this invariant + // may be broken. Since we have efficient alternatives, pay + // the cost here and avoid the bug. + require_once HTMLPURIFIER_PREFIX . '/' . $file; + return true; + } + + /** + * Returns the path for a specific class. + * @param string $class Class path to get + * @return string + */ + public static function getPath($class) + { + if (strncmp('HTMLPurifier', $class, 12) !== 0) { + return false; + } + // Custom implementations + if (strncmp('HTMLPurifier_Language_', $class, 22) === 0) { + $code = str_replace('_', '-', substr($class, 22)); + $file = 'HTMLPurifier/Language/classes/' . $code . '.php'; + } else { + $file = str_replace('_', '/', $class) . '.php'; + } + if (!file_exists(HTMLPURIFIER_PREFIX . '/' . $file)) { + return false; + } + return $file; + } + + /** + * "Pre-registers" our autoloader on the SPL stack. + */ + public static function registerAutoload() + { + $autoload = array('HTMLPurifier_Bootstrap', 'autoload'); + if (spl_autoload_functions() === false) { + spl_autoload_register($autoload); + } else { + // prepend flag exists, no need for shenanigans + spl_autoload_register($autoload, true, true); + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/CSSDefinition.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/CSSDefinition.php new file mode 100644 index 0000000..3732c07 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/CSSDefinition.php @@ -0,0 +1,565 @@ +info['text-align'] = new HTMLPurifier_AttrDef_Enum( + ['left', 'right', 'center', 'justify'], + false + ); + + $border_style = + $this->info['border-bottom-style'] = + $this->info['border-right-style'] = + $this->info['border-left-style'] = + $this->info['border-top-style'] = new HTMLPurifier_AttrDef_Enum( + [ + 'none', + 'hidden', + 'dotted', + 'dashed', + 'solid', + 'double', + 'groove', + 'ridge', + 'inset', + 'outset' + ], + false + ); + + $this->info['border-style'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_style); + + $this->info['clear'] = new HTMLPurifier_AttrDef_Enum( + ['none', 'left', 'right', 'both'], + false + ); + $this->info['float'] = new HTMLPurifier_AttrDef_Enum( + ['none', 'left', 'right'], + false + ); + $this->info['font-style'] = new HTMLPurifier_AttrDef_Enum( + ['normal', 'italic', 'oblique'], + false + ); + $this->info['font-variant'] = new HTMLPurifier_AttrDef_Enum( + ['normal', 'small-caps'], + false + ); + + $uri_or_none = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum(['none']), + new HTMLPurifier_AttrDef_CSS_URI() + ] + ); + + $this->info['list-style-position'] = new HTMLPurifier_AttrDef_Enum( + ['inside', 'outside'], + false + ); + $this->info['list-style-type'] = new HTMLPurifier_AttrDef_Enum( + [ + 'disc', + 'circle', + 'square', + 'decimal', + 'lower-roman', + 'upper-roman', + 'lower-alpha', + 'upper-alpha', + 'none' + ], + false + ); + $this->info['list-style-image'] = $uri_or_none; + + $this->info['list-style'] = new HTMLPurifier_AttrDef_CSS_ListStyle($config); + + $this->info['text-transform'] = new HTMLPurifier_AttrDef_Enum( + ['capitalize', 'uppercase', 'lowercase', 'none'], + false + ); + $this->info['color'] = new HTMLPurifier_AttrDef_CSS_Color(); + + $this->info['background-image'] = $uri_or_none; + $this->info['background-repeat'] = new HTMLPurifier_AttrDef_Enum( + ['repeat', 'repeat-x', 'repeat-y', 'no-repeat'] + ); + $this->info['background-attachment'] = new HTMLPurifier_AttrDef_Enum( + ['scroll', 'fixed'] + ); + $this->info['background-position'] = new HTMLPurifier_AttrDef_CSS_BackgroundPosition(); + + $this->info['background-size'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum( + [ + 'auto', + 'cover', + 'contain', + ] + ), + new HTMLPurifier_AttrDef_CSS_Percentage(), + new HTMLPurifier_AttrDef_CSS_Length() + ] + ); + + $border_color = + $this->info['border-top-color'] = + $this->info['border-bottom-color'] = + $this->info['border-left-color'] = + $this->info['border-right-color'] = + $this->info['background-color'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum(['transparent']), + new HTMLPurifier_AttrDef_CSS_Color() + ] + ); + + $this->info['background'] = new HTMLPurifier_AttrDef_CSS_Background($config); + + $this->info['border-color'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_color); + + $border_width = + $this->info['border-top-width'] = + $this->info['border-bottom-width'] = + $this->info['border-left-width'] = + $this->info['border-right-width'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum(['thin', 'medium', 'thick']), + new HTMLPurifier_AttrDef_CSS_Length('0') //disallow negative + ] + ); + + $this->info['border-width'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_width); + + $this->info['letter-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum(['normal']), + new HTMLPurifier_AttrDef_CSS_Length() + ] + ); + + $this->info['word-spacing'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum(['normal']), + new HTMLPurifier_AttrDef_CSS_Length() + ] + ); + + $this->info['font-size'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum( + [ + 'xx-small', + 'x-small', + 'small', + 'medium', + 'large', + 'x-large', + 'xx-large', + 'larger', + 'smaller' + ] + ), + new HTMLPurifier_AttrDef_CSS_Percentage(), + new HTMLPurifier_AttrDef_CSS_Length() + ] + ); + + $this->info['line-height'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum(['normal']), + new HTMLPurifier_AttrDef_CSS_Number(true), // no negatives + new HTMLPurifier_AttrDef_CSS_Length('0'), + new HTMLPurifier_AttrDef_CSS_Percentage(true) + ] + ); + + $margin = + $this->info['margin-top'] = + $this->info['margin-bottom'] = + $this->info['margin-left'] = + $this->info['margin-right'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length(), + new HTMLPurifier_AttrDef_CSS_Percentage(), + new HTMLPurifier_AttrDef_Enum(['auto']) + ] + ); + + $this->info['margin'] = new HTMLPurifier_AttrDef_CSS_Multiple($margin); + + // non-negative + $padding = + $this->info['padding-top'] = + $this->info['padding-bottom'] = + $this->info['padding-left'] = + $this->info['padding-right'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length('0'), + new HTMLPurifier_AttrDef_CSS_Percentage(true) + ] + ); + + $this->info['padding'] = new HTMLPurifier_AttrDef_CSS_Multiple($padding); + + $this->info['text-indent'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length(), + new HTMLPurifier_AttrDef_CSS_Percentage() + ] + ); + + $trusted_wh = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length('0'), + new HTMLPurifier_AttrDef_CSS_Percentage(true), + new HTMLPurifier_AttrDef_Enum(['auto']) + ] + ); + $trusted_min_wh = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length('0'), + new HTMLPurifier_AttrDef_CSS_Percentage(true), + ] + ); + $trusted_max_wh = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length('0'), + new HTMLPurifier_AttrDef_CSS_Percentage(true), + new HTMLPurifier_AttrDef_Enum(['none']) + ] + ); + $max = $config->get('CSS.MaxImgLength'); + + $this->info['width'] = + $this->info['height'] = + $max === null ? + $trusted_wh : + new HTMLPurifier_AttrDef_Switch( + 'img', + // For img tags: + new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length('0', $max), + new HTMLPurifier_AttrDef_Enum(['auto']) + ] + ), + // For everyone else: + $trusted_wh + ); + $this->info['min-width'] = + $this->info['min-height'] = + $max === null ? + $trusted_min_wh : + new HTMLPurifier_AttrDef_Switch( + 'img', + // For img tags: + new HTMLPurifier_AttrDef_CSS_Length('0', $max), + // For everyone else: + $trusted_min_wh + ); + $this->info['max-width'] = + $this->info['max-height'] = + $max === null ? + $trusted_max_wh : + new HTMLPurifier_AttrDef_Switch( + 'img', + // For img tags: + new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length('0', $max), + new HTMLPurifier_AttrDef_Enum(['none']) + ] + ), + // For everyone else: + $trusted_max_wh + ); + + $this->info['aspect-ratio'] = new HTMLPurifier_AttrDef_CSS_Multiple( + new HTMLPurifier_AttrDef_CSS_Composite([ + new HTMLPurifier_AttrDef_CSS_Ratio(), + new HTMLPurifier_AttrDef_Enum(['auto']), + ]) + ); + + // text-decoration and related shorthands + $this->info['text-decoration'] = new HTMLPurifier_AttrDef_CSS_TextDecoration(); + + $this->info['text-decoration-line'] = new HTMLPurifier_AttrDef_Enum( + ['none', 'underline', 'overline', 'line-through'] + ); + + $this->info['text-decoration-style'] = new HTMLPurifier_AttrDef_Enum( + ['solid', 'double', 'dotted', 'dashed', 'wavy'] + ); + + $this->info['text-decoration-color'] = new HTMLPurifier_AttrDef_CSS_Color(); + + $this->info['text-decoration-thickness'] = new HTMLPurifier_AttrDef_CSS_Composite([ + new HTMLPurifier_AttrDef_CSS_Length(), + new HTMLPurifier_AttrDef_CSS_Percentage(), + new HTMLPurifier_AttrDef_Enum(['auto', 'from-font']) + ]); + + $this->info['font-family'] = new HTMLPurifier_AttrDef_CSS_FontFamily(); + + // this could use specialized code + $this->info['font-weight'] = new HTMLPurifier_AttrDef_Enum( + [ + 'normal', + 'bold', + 'bolder', + 'lighter', + '100', + '200', + '300', + '400', + '500', + '600', + '700', + '800', + '900' + ], + false + ); + + // MUST be called after other font properties, as it references + // a CSSDefinition object + $this->info['font'] = new HTMLPurifier_AttrDef_CSS_Font($config); + + // same here + $this->info['border'] = + $this->info['border-bottom'] = + $this->info['border-top'] = + $this->info['border-left'] = + $this->info['border-right'] = new HTMLPurifier_AttrDef_CSS_Border($config); + + $this->info['border-collapse'] = new HTMLPurifier_AttrDef_Enum( + ['collapse', 'separate'] + ); + + $this->info['caption-side'] = new HTMLPurifier_AttrDef_Enum( + ['top', 'bottom'] + ); + + $this->info['table-layout'] = new HTMLPurifier_AttrDef_Enum( + ['auto', 'fixed'] + ); + + $this->info['vertical-align'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Enum( + [ + 'baseline', + 'sub', + 'super', + 'top', + 'text-top', + 'middle', + 'bottom', + 'text-bottom' + ] + ), + new HTMLPurifier_AttrDef_CSS_Length(), + new HTMLPurifier_AttrDef_CSS_Percentage() + ] + ); + + $this->info['border-spacing'] = new HTMLPurifier_AttrDef_CSS_Multiple(new HTMLPurifier_AttrDef_CSS_Length(), 2); + + // These CSS properties don't work on many browsers, but we live + // in THE FUTURE! + $this->info['white-space'] = new HTMLPurifier_AttrDef_Enum( + ['nowrap', 'normal', 'pre', 'pre-wrap', 'pre-line'] + ); + + if ($config->get('CSS.Proprietary')) { + $this->doSetupProprietary($config); + } + + if ($config->get('CSS.AllowTricky')) { + $this->doSetupTricky($config); + } + + if ($config->get('CSS.Trusted')) { + $this->doSetupTrusted($config); + } + + $allow_important = $config->get('CSS.AllowImportant'); + // wrap all attr-defs with decorator that handles !important + foreach ($this->info as $k => $v) { + $this->info[$k] = new HTMLPurifier_AttrDef_CSS_ImportantDecorator($v, $allow_important); + } + + $this->setupConfigStuff($config); + } + + /** + * @param HTMLPurifier_Config $config + */ + protected function doSetupProprietary($config) + { + // Internet Explorer only scrollbar colors + $this->info['scrollbar-arrow-color'] = new HTMLPurifier_AttrDef_CSS_Color(); + $this->info['scrollbar-base-color'] = new HTMLPurifier_AttrDef_CSS_Color(); + $this->info['scrollbar-darkshadow-color'] = new HTMLPurifier_AttrDef_CSS_Color(); + $this->info['scrollbar-face-color'] = new HTMLPurifier_AttrDef_CSS_Color(); + $this->info['scrollbar-highlight-color'] = new HTMLPurifier_AttrDef_CSS_Color(); + $this->info['scrollbar-shadow-color'] = new HTMLPurifier_AttrDef_CSS_Color(); + + // vendor specific prefixes of opacity + $this->info['-moz-opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); + $this->info['-khtml-opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); + + // only opacity, for now + $this->info['filter'] = new HTMLPurifier_AttrDef_CSS_Filter(); + + // more CSS3 + $this->info['page-break-after'] = + $this->info['page-break-before'] = new HTMLPurifier_AttrDef_Enum( + [ + 'auto', + 'always', + 'avoid', + 'left', + 'right' + ] + ); + $this->info['page-break-inside'] = new HTMLPurifier_AttrDef_Enum(['auto', 'avoid']); + + $border_radius = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Percentage(true), // disallow negative + new HTMLPurifier_AttrDef_CSS_Length('0') // disallow negative + ]); + + $this->info['border-top-left-radius'] = + $this->info['border-top-right-radius'] = + $this->info['border-bottom-right-radius'] = + $this->info['border-bottom-left-radius'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_radius, 2); + // TODO: support SLASH syntax + $this->info['border-radius'] = new HTMLPurifier_AttrDef_CSS_Multiple($border_radius, 4); + + } + + /** + * @param HTMLPurifier_Config $config + */ + protected function doSetupTricky($config) + { + $this->info['display'] = new HTMLPurifier_AttrDef_Enum( + [ + 'inline', + 'block', + 'list-item', + 'run-in', + 'compact', + 'marker', + 'table', + 'inline-block', + 'inline-table', + 'table-row-group', + 'table-header-group', + 'table-footer-group', + 'table-row', + 'table-column-group', + 'table-column', + 'table-cell', + 'table-caption', + 'none' + ] + ); + $this->info['visibility'] = new HTMLPurifier_AttrDef_Enum( + ['visible', 'hidden', 'collapse'] + ); + $this->info['overflow'] = new HTMLPurifier_AttrDef_Enum(['visible', 'hidden', 'auto', 'scroll']); + $this->info['opacity'] = new HTMLPurifier_AttrDef_CSS_AlphaValue(); + } + + /** + * @param HTMLPurifier_Config $config + */ + protected function doSetupTrusted($config) + { + $this->info['position'] = new HTMLPurifier_AttrDef_Enum( + ['static', 'relative', 'absolute', 'fixed'] + ); + $this->info['top'] = + $this->info['left'] = + $this->info['right'] = + $this->info['bottom'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_CSS_Length(), + new HTMLPurifier_AttrDef_CSS_Percentage(), + new HTMLPurifier_AttrDef_Enum(['auto']), + ] + ); + $this->info['z-index'] = new HTMLPurifier_AttrDef_CSS_Composite( + [ + new HTMLPurifier_AttrDef_Integer(), + new HTMLPurifier_AttrDef_Enum(['auto']), + ] + ); + } + + /** + * Performs extra config-based processing. Based off of + * HTMLPurifier_HTMLDefinition. + * @param HTMLPurifier_Config $config + * @todo Refactor duplicate elements into common class (probably using + * composition, not inheritance). + */ + protected function setupConfigStuff($config) + { + // setup allowed elements + $support = "(for information on implementing this, see the " . + "support forums) "; + $allowed_properties = $config->get('CSS.AllowedProperties'); + if ($allowed_properties !== null) { + foreach ($this->info as $name => $d) { + if (!isset($allowed_properties[$name])) { + unset($this->info[$name]); + } + unset($allowed_properties[$name]); + } + // emit errors + foreach ($allowed_properties as $name => $d) { + // :TODO: Is this htmlspecialchars() call really necessary? + $name = htmlspecialchars($name); + trigger_error("Style attribute '$name' is not supported $support", E_USER_WARNING); + } + } + + $forbidden_properties = $config->get('CSS.ForbiddenProperties'); + if ($forbidden_properties !== null) { + foreach ($this->info as $name => $d) { + if (isset($forbidden_properties[$name])) { + unset($this->info[$name]); + } + } + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef.php new file mode 100644 index 0000000..8eb17b8 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef.php @@ -0,0 +1,52 @@ +elements; + } + + /** + * Validates nodes according to definition and returns modification. + * + * @param HTMLPurifier_Node[] $children Array of HTMLPurifier_Node + * @param HTMLPurifier_Config $config HTMLPurifier_Config object + * @param HTMLPurifier_Context $context HTMLPurifier_Context object + * @return bool|array true to leave nodes as is, false to remove parent node, array of replacement children + */ + abstract public function validateChildren($children, $config, $context); +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Chameleon.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Chameleon.php new file mode 100644 index 0000000..7439be2 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Chameleon.php @@ -0,0 +1,67 @@ +inline = new HTMLPurifier_ChildDef_Optional($inline); + $this->block = new HTMLPurifier_ChildDef_Optional($block); + $this->elements = $this->block->elements; + } + + /** + * @param HTMLPurifier_Node[] $children + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool + */ + public function validateChildren($children, $config, $context) + { + if ($context->get('IsInline') === false) { + return $this->block->validateChildren( + $children, + $config, + $context + ); + } else { + return $this->inline->validateChildren( + $children, + $config, + $context + ); + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Custom.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Custom.php new file mode 100644 index 0000000..f515888 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Custom.php @@ -0,0 +1,102 @@ +dtd_regex = $dtd_regex; + $this->_compileRegex(); + } + + /** + * Compiles the PCRE regex from a DTD regex ($dtd_regex to $_pcre_regex) + */ + protected function _compileRegex() + { + $raw = str_replace(' ', '', $this->dtd_regex); + if ($raw[0] != '(') { + $raw = "($raw)"; + } + $el = '[#a-zA-Z0-9_.-]+'; + $reg = $raw; + + // COMPLICATED! AND MIGHT BE BUGGY! I HAVE NO CLUE WHAT I'M + // DOING! Seriously: if there's problems, please report them. + + // collect all elements into the $elements array + preg_match_all("/$el/", $reg, $matches); + foreach ($matches[0] as $match) { + $this->elements[$match] = true; + } + + // setup all elements as parentheticals with leading commas + $reg = preg_replace("/$el/", '(,\\0)', $reg); + + // remove commas when they were not solicited + $reg = preg_replace("/([^,(|]\(+),/", '\\1', $reg); + + // remove all non-paranthetical commas: they are handled by first regex + $reg = preg_replace("/,\(/", '(', $reg); + + $this->_pcre_regex = $reg; + } + + /** + * @param HTMLPurifier_Node[] $children + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return bool + */ + public function validateChildren($children, $config, $context) + { + $list_of_children = ''; + $nesting = 0; // depth into the nest + foreach ($children as $node) { + if (!empty($node->is_whitespace)) { + continue; + } + $list_of_children .= $node->name . ','; + } + // add leading comma to deal with stray comma declarations + $list_of_children = ',' . rtrim($list_of_children, ','); + $okay = + preg_match( + '/^,?' . $this->_pcre_regex . '$/', + $list_of_children + ); + return (bool)$okay; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Empty.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Empty.php new file mode 100644 index 0000000..a8a6cbd --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Empty.php @@ -0,0 +1,38 @@ + true, 'ul' => true, 'ol' => true); + + public $whitespace; + + /** + * @param array $children + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function validateChildren($children, $config, $context) + { + // Flag for subclasses + $this->whitespace = false; + + // if there are no tokens, delete parent node + if (empty($children)) { + return false; + } + + // if li is not allowed, delete parent node + if (!isset($config->getHTMLDefinition()->info['li'])) { + trigger_error("Cannot allow ul/ol without allowing li", E_USER_WARNING); + return false; + } + + // the new set of children + $result = array(); + + // a little sanity check to make sure it's not ALL whitespace + $all_whitespace = true; + + $current_li = null; + + foreach ($children as $node) { + if (!empty($node->is_whitespace)) { + $result[] = $node; + continue; + } + $all_whitespace = false; // phew, we're not talking about whitespace + + if ($node->name === 'li') { + // good + $current_li = $node; + $result[] = $node; + } else { + // we want to tuck this into the previous li + // Invariant: we expect the node to be ol/ul + // ToDo: Make this more robust in the case of not ol/ul + // by distinguishing between existing li and li created + // to handle non-list elements; non-list elements should + // not be appended to an existing li; only li created + // for non-list. This distinction is not currently made. + if ($current_li === null) { + $current_li = new HTMLPurifier_Node_Element('li'); + $result[] = $current_li; + } + $current_li->children[] = $node; + $current_li->empty = false; // XXX fascinating! Check for this error elsewhere ToDo + } + } + if (empty($result)) { + return false; + } + if ($all_whitespace) { + return false; + } + return $result; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Optional.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Optional.php new file mode 100644 index 0000000..b946806 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Optional.php @@ -0,0 +1,45 @@ +whitespace) { + return $children; + } else { + return array(); + } + } + return $result; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Required.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Required.php new file mode 100644 index 0000000..0d1c8f5 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Required.php @@ -0,0 +1,118 @@ + $x) { + $elements[$i] = true; + if (empty($i)) { + unset($elements[$i]); + } // remove blank + } + } + $this->elements = $elements; + } + + /** + * @type bool + */ + public $allow_empty = false; + + /** + * @type string + */ + public $type = 'required'; + + /** + * @param array $children + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function validateChildren($children, $config, $context) + { + // Flag for subclasses + $this->whitespace = false; + + // if there are no tokens, delete parent node + if (empty($children)) { + return false; + } + + // the new set of children + $result = array(); + + // whether or not parsed character data is allowed + // this controls whether or not we silently drop a tag + // or generate escaped HTML from it + $pcdata_allowed = isset($this->elements['#PCDATA']); + + // a little sanity check to make sure it's not ALL whitespace + $all_whitespace = true; + + $stack = array_reverse($children); + while (!empty($stack)) { + $node = array_pop($stack); + if (!empty($node->is_whitespace)) { + $result[] = $node; + continue; + } + $all_whitespace = false; // phew, we're not talking about whitespace + + if (!isset($this->elements[$node->name])) { + // special case text + // XXX One of these ought to be redundant or something + if ($pcdata_allowed && $node instanceof HTMLPurifier_Node_Text) { + $result[] = $node; + continue; + } + // spill the child contents in + // ToDo: Make configurable + if ($node instanceof HTMLPurifier_Node_Element) { + for ($i = count($node->children) - 1; $i >= 0; $i--) { + $stack[] = $node->children[$i]; + } + continue; + } + continue; + } + $result[] = $node; + } + if (empty($result)) { + return false; + } + if ($all_whitespace) { + $this->whitespace = true; + return false; + } + return $result; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/StrictBlockquote.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/StrictBlockquote.php new file mode 100644 index 0000000..3270a46 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/StrictBlockquote.php @@ -0,0 +1,110 @@ +init($config); + return $this->fake_elements; + } + + /** + * @param array $children + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function validateChildren($children, $config, $context) + { + $this->init($config); + + // trick the parent class into thinking it allows more + $this->elements = $this->fake_elements; + $result = parent::validateChildren($children, $config, $context); + $this->elements = $this->real_elements; + + if ($result === false) { + return array(); + } + if ($result === true) { + $result = $children; + } + + $def = $config->getHTMLDefinition(); + $block_wrap_name = $def->info_block_wrapper; + $block_wrap = false; + $ret = array(); + + foreach ($result as $node) { + if ($block_wrap === false) { + if (($node instanceof HTMLPurifier_Node_Text && !$node->is_whitespace) || + ($node instanceof HTMLPurifier_Node_Element && !isset($this->elements[$node->name]))) { + $block_wrap = new HTMLPurifier_Node_Element($def->info_block_wrapper); + $ret[] = $block_wrap; + } + } else { + if ($node instanceof HTMLPurifier_Node_Element && isset($this->elements[$node->name])) { + $block_wrap = false; + + } + } + if ($block_wrap) { + $block_wrap->children[] = $node; + } else { + $ret[] = $node; + } + } + return $ret; + } + + /** + * @param HTMLPurifier_Config $config + */ + private function init($config) + { + if (!$this->init) { + $def = $config->getHTMLDefinition(); + // allow all inline elements + $this->real_elements = $this->elements; + $this->fake_elements = $def->info_content_sets['Flow']; + $this->fake_elements['#PCDATA'] = true; + $this->init = true; + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Table.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Table.php new file mode 100644 index 0000000..d92205b --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ChildDef/Table.php @@ -0,0 +1,227 @@ + true, + 'tbody' => true, + 'thead' => true, + 'tfoot' => true, + 'caption' => true, + 'colgroup' => true, + 'col' => true + ); + + public function __construct() + { + } + + /** + * @param array $children + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array + */ + public function validateChildren($children, $config, $context) + { + if (empty($children)) { + return false; + } + + // only one of these elements is allowed in a table + $caption = false; + $thead = false; + $tfoot = false; + + // whitespace + $initial_ws = array(); + $after_caption_ws = array(); + $after_thead_ws = array(); + $after_tfoot_ws = array(); + + // as many of these as you want + $cols = array(); + $content = array(); + + $tbody_mode = false; // if true, then we need to wrap any stray + // s with a . + + $ws_accum =& $initial_ws; + + foreach ($children as $node) { + if ($node instanceof HTMLPurifier_Node_Comment) { + $ws_accum[] = $node; + continue; + } + switch ($node->name) { + case 'tbody': + $tbody_mode = true; + // fall through + case 'tr': + $content[] = $node; + $ws_accum =& $content; + break; + case 'caption': + // there can only be one caption! + if ($caption !== false) break; + $caption = $node; + $ws_accum =& $after_caption_ws; + break; + case 'thead': + $tbody_mode = true; + // XXX This breaks rendering properties with + // Firefox, which never floats a to + // the top. Ever. (Our scheme will float the + // first to the top.) So maybe + // s that are not first should be + // turned into ? Very tricky, indeed. + if ($thead === false) { + $thead = $node; + $ws_accum =& $after_thead_ws; + } else { + // Oops, there's a second one! What + // should we do? Current behavior is to + // transmutate the first and last entries into + // tbody tags, and then put into content. + // Maybe a better idea is to *attach + // it* to the existing thead or tfoot? + // We don't do this, because Firefox + // doesn't float an extra tfoot to the + // bottom like it does for the first one. + $node->name = 'tbody'; + $content[] = $node; + $ws_accum =& $content; + } + break; + case 'tfoot': + // see above for some aveats + $tbody_mode = true; + if ($tfoot === false) { + $tfoot = $node; + $ws_accum =& $after_tfoot_ws; + } else { + $node->name = 'tbody'; + $content[] = $node; + $ws_accum =& $content; + } + break; + case 'colgroup': + case 'col': + $cols[] = $node; + $ws_accum =& $cols; + break; + case '#PCDATA': + // How is whitespace handled? We treat is as sticky to + // the *end* of the previous element. So all of the + // nonsense we have worked on is to keep things + // together. + if (!empty($node->is_whitespace)) { + $ws_accum[] = $node; + } + break; + } + } + + if (empty($content) && $thead === false && $tfoot === false) { + return false; + } + + $ret = $initial_ws; + if ($caption !== false) { + $ret[] = $caption; + $ret = array_merge($ret, $after_caption_ws); + } + if ($cols !== false) { + $ret = array_merge($ret, $cols); + } + if ($thead !== false) { + $ret[] = $thead; + $ret = array_merge($ret, $after_thead_ws); + } + if ($tfoot !== false) { + $ret[] = $tfoot; + $ret = array_merge($ret, $after_tfoot_ws); + } + + if ($tbody_mode) { + // we have to shuffle tr into tbody + $current_tr_tbody = null; + + foreach($content as $node) { + if (!isset($node->name)) { + continue; + } + switch ($node->name) { + case 'tbody': + $current_tr_tbody = null; + $ret[] = $node; + break; + case 'tr': + if ($current_tr_tbody === null) { + $current_tr_tbody = new HTMLPurifier_Node_Element('tbody'); + $ret[] = $current_tr_tbody; + } + $current_tr_tbody->children[] = $node; + break; + case '#PCDATA': + //assert($node->is_whitespace); + if ($current_tr_tbody === null) { + $ret[] = $node; + } else { + $current_tr_tbody->children[] = $node; + } + break; + } + } + } else { + $ret = array_merge($ret, $content); + } + + return $ret; + + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Config.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Config.php new file mode 100644 index 0000000..e6566e8 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Config.php @@ -0,0 +1,920 @@ +defaultPlist; + $this->plist = new HTMLPurifier_PropertyList($parent); + $this->def = $definition; // keep a copy around for checking + $this->parser = new HTMLPurifier_VarParser_Flexible(); + } + + /** + * Convenience constructor that creates a config object based on a mixed var + * @param mixed $config Variable that defines the state of the config + * object. Can be: a HTMLPurifier_Config() object, + * an array of directives based on loadArray(), + * or a string filename of an ini file. + * @param HTMLPurifier_ConfigSchema $schema Schema object + * @return HTMLPurifier_Config Configured object + */ + public static function create($config, $schema = null) + { + if ($config instanceof HTMLPurifier_Config) { + // pass-through + return $config; + } + if (!$schema) { + $ret = HTMLPurifier_Config::createDefault(); + } else { + $ret = new HTMLPurifier_Config($schema); + } + if (is_string($config)) { + $ret->loadIni($config); + } elseif (is_array($config)) $ret->loadArray($config); + return $ret; + } + + /** + * Creates a new config object that inherits from a previous one. + * @param HTMLPurifier_Config $config Configuration object to inherit from. + * @return HTMLPurifier_Config object with $config as its parent. + */ + public static function inherit(HTMLPurifier_Config $config) + { + return new HTMLPurifier_Config($config->def, $config->plist); + } + + /** + * Convenience constructor that creates a default configuration object. + * @return HTMLPurifier_Config default object. + */ + public static function createDefault() + { + $definition = HTMLPurifier_ConfigSchema::instance(); + $config = new HTMLPurifier_Config($definition); + return $config; + } + + /** + * Retrieves a value from the configuration. + * + * @param string $key String key + * @param mixed $a + * + * @return mixed + */ + public function get($key, $a = null) + { + if ($a !== null) { + $this->triggerError( + "Using deprecated API: use \$config->get('$key.$a') instead", + E_USER_WARNING + ); + $key = "$key.$a"; + } + if (!$this->finalized) { + $this->autoFinalize(); + } + if (!isset($this->def->info[$key])) { + // can't add % due to SimpleTest bug + $this->triggerError( + 'Cannot retrieve value of undefined directive ' . htmlspecialchars($key), + E_USER_WARNING + ); + return; + } + if (isset($this->def->info[$key]->isAlias)) { + $d = $this->def->info[$key]; + $this->triggerError( + 'Cannot get value from aliased directive, use real name ' . $d->key, + E_USER_ERROR + ); + return; + } + if ($this->lock) { + list($ns) = explode('.', $key); + if ($ns !== $this->lock) { + $this->triggerError( + 'Cannot get value of namespace ' . $ns . ' when lock for ' . + $this->lock . + ' is active, this probably indicates a Definition setup method ' . + 'is accessing directives that are not within its namespace', + E_USER_ERROR + ); + return; + } + } + return $this->plist->get($key); + } + + /** + * Retrieves an array of directives to values from a given namespace + * + * @param string $namespace String namespace + * + * @return array + */ + public function getBatch($namespace) + { + if (!$this->finalized) { + $this->autoFinalize(); + } + $full = $this->getAll(); + if (!isset($full[$namespace])) { + $this->triggerError( + 'Cannot retrieve undefined namespace ' . + htmlspecialchars($namespace), + E_USER_WARNING + ); + return; + } + return $full[$namespace]; + } + + /** + * Returns a SHA-1 signature of a segment of the configuration object + * that uniquely identifies that particular configuration + * + * @param string $namespace Namespace to get serial for + * + * @return string + * @note Revision is handled specially and is removed from the batch + * before processing! + */ + public function getBatchSerial($namespace) + { + if (empty($this->serials[$namespace])) { + $batch = $this->getBatch($namespace); + unset($batch['DefinitionRev']); + $this->serials[$namespace] = sha1(serialize($batch)); + } + return $this->serials[$namespace]; + } + + /** + * Returns a SHA-1 signature for the entire configuration object + * that uniquely identifies that particular configuration + * + * @return string + */ + public function getSerial() + { + if (empty($this->serial)) { + $this->serial = sha1(serialize($this->getAll())); + } + return $this->serial; + } + + /** + * Retrieves all directives, organized by namespace + * + * @warning This is a pretty inefficient function, avoid if you can + */ + public function getAll() + { + if (!$this->finalized) { + $this->autoFinalize(); + } + $ret = array(); + foreach ($this->plist->squash() as $name => $value) { + list($ns, $key) = explode('.', $name, 2); + $ret[$ns][$key] = $value; + } + return $ret; + } + + /** + * Sets a value to configuration. + * + * @param string $key key + * @param mixed $value value + * @param mixed $a + */ + public function set($key, $value, $a = null) + { + if (strpos($key, '.') === false) { + $namespace = $key; + $directive = $value; + $value = $a; + $key = "$key.$directive"; + $this->triggerError("Using deprecated API: use \$config->set('$key', ...) instead", E_USER_NOTICE); + } else { + list($namespace) = explode('.', $key); + } + if ($this->isFinalized('Cannot set directive after finalization')) { + return; + } + if (!isset($this->def->info[$key])) { + $this->triggerError( + 'Cannot set undefined directive ' . htmlspecialchars($key) . ' to value', + E_USER_WARNING + ); + return; + } + $def = $this->def->info[$key]; + + if (isset($def->isAlias)) { + if ($this->aliasMode) { + $this->triggerError( + 'Double-aliases not allowed, please fix '. + 'ConfigSchema bug with' . $key, + E_USER_ERROR + ); + return; + } + $this->aliasMode = true; + $this->set($def->key, $value); + $this->aliasMode = false; + $this->triggerError("$key is an alias, preferred directive name is {$def->key}", E_USER_NOTICE); + return; + } + + // Raw type might be negative when using the fully optimized form + // of stdClass, which indicates allow_null == true + $rtype = is_int($def) ? $def : $def->type; + if ($rtype < 0) { + $type = -$rtype; + $allow_null = true; + } else { + $type = $rtype; + $allow_null = isset($def->allow_null); + } + + try { + $value = $this->parser->parse($value, $type, $allow_null); + } catch (HTMLPurifier_VarParserException $e) { + $this->triggerError( + 'Value for ' . $key . ' is of invalid type, should be ' . + HTMLPurifier_VarParser::getTypeName($type), + E_USER_WARNING + ); + return; + } + if (is_string($value) && is_object($def)) { + // resolve value alias if defined + if (isset($def->aliases[$value])) { + $value = $def->aliases[$value]; + } + // check to see if the value is allowed + if (isset($def->allowed) && !isset($def->allowed[$value])) { + $this->triggerError( + 'Value not supported, valid values are: ' . + $this->_listify($def->allowed), + E_USER_WARNING + ); + return; + } + } + $this->plist->set($key, $value); + + // reset definitions if the directives they depend on changed + // this is a very costly process, so it's discouraged + // with finalization + if ($namespace == 'HTML' || $namespace == 'CSS' || $namespace == 'URI') { + $this->definitions[$namespace] = null; + } + + $this->serials[$namespace] = false; + } + + /** + * Convenience function for error reporting + * + * @param array $lookup + * + * @return string + */ + private function _listify($lookup) + { + $list = array(); + foreach ($lookup as $name => $b) { + $list[] = $name; + } + return implode(', ', $list); + } + + /** + * Retrieves object reference to the HTML definition. + * + * @param bool $raw Return a copy that has not been setup yet. Must be + * called before it's been setup, otherwise won't work. + * @param bool $optimized If true, this method may return null, to + * indicate that a cached version of the modified + * definition object is available and no further edits + * are necessary. Consider using + * maybeGetRawHTMLDefinition, which is more explicitly + * named, instead. + * + * @return HTMLPurifier_HTMLDefinition|null + */ + public function getHTMLDefinition($raw = false, $optimized = false) + { + return $this->getDefinition('HTML', $raw, $optimized); + } + + /** + * Retrieves object reference to the CSS definition + * + * @param bool $raw Return a copy that has not been setup yet. Must be + * called before it's been setup, otherwise won't work. + * @param bool $optimized If true, this method may return null, to + * indicate that a cached version of the modified + * definition object is available and no further edits + * are necessary. Consider using + * maybeGetRawCSSDefinition, which is more explicitly + * named, instead. + * + * @return HTMLPurifier_CSSDefinition|null + */ + public function getCSSDefinition($raw = false, $optimized = false) + { + return $this->getDefinition('CSS', $raw, $optimized); + } + + /** + * Retrieves object reference to the URI definition + * + * @param bool $raw Return a copy that has not been setup yet. Must be + * called before it's been setup, otherwise won't work. + * @param bool $optimized If true, this method may return null, to + * indicate that a cached version of the modified + * definition object is available and no further edits + * are necessary. Consider using + * maybeGetRawURIDefinition, which is more explicitly + * named, instead. + * + * @return HTMLPurifier_URIDefinition|null + */ + public function getURIDefinition($raw = false, $optimized = false) + { + return $this->getDefinition('URI', $raw, $optimized); + } + + /** + * Retrieves a definition + * + * @param string $type Type of definition: HTML, CSS, etc + * @param bool $raw Whether or not definition should be returned raw + * @param bool $optimized Only has an effect when $raw is true. Whether + * or not to return null if the result is already present in + * the cache. This is off by default for backwards + * compatibility reasons, but you need to do things this + * way in order to ensure that caching is done properly. + * Check out enduser-customize.html for more details. + * We probably won't ever change this default, as much as the + * maybe semantics is the "right thing to do." + * + * @throws HTMLPurifier_Exception + * @return HTMLPurifier_Definition|null + */ + public function getDefinition($type, $raw = false, $optimized = false) + { + if ($optimized && !$raw) { + throw new HTMLPurifier_Exception("Cannot set optimized = true when raw = false"); + } + if (!$this->finalized) { + $this->autoFinalize(); + } + // temporarily suspend locks, so we can handle recursive definition calls + $lock = $this->lock; + $this->lock = null; + $factory = HTMLPurifier_DefinitionCacheFactory::instance(); + $cache = $factory->create($type, $this); + $this->lock = $lock; + if (!$raw) { + // full definition + // --------------- + // check if definition is in memory + if (!empty($this->definitions[$type])) { + $def = $this->definitions[$type]; + // check if the definition is setup + if ($def->setup) { + return $def; + } else { + $def->setup($this); + if ($def->optimized) { + $cache->add($def, $this); + } + return $def; + } + } + // check if definition is in cache + $def = $cache->get($this); + if ($def) { + // definition in cache, save to memory and return it + $this->definitions[$type] = $def; + return $def; + } + // initialize it + $def = $this->initDefinition($type); + // set it up + $this->lock = $type; + $def->setup($this); + $this->lock = null; + // save in cache + $cache->add($def, $this); + // return it + return $def; + } else { + // raw definition + // -------------- + // check preconditions + $def = null; + if ($optimized) { + if (is_null($this->get($type . '.DefinitionID'))) { + // fatally error out if definition ID not set + throw new HTMLPurifier_Exception( + "Cannot retrieve raw version without specifying %$type.DefinitionID" + ); + } + } + if (!empty($this->definitions[$type])) { + $def = $this->definitions[$type]; + if ($def->setup && !$optimized) { + $extra = $this->chatty ? + " (try moving this code block earlier in your initialization)" : + ""; + throw new HTMLPurifier_Exception( + "Cannot retrieve raw definition after it has already been setup" . + $extra + ); + } + if ($def->optimized === null) { + $extra = $this->chatty ? " (try flushing your cache)" : ""; + throw new HTMLPurifier_Exception( + "Optimization status of definition is unknown" . $extra + ); + } + if ($def->optimized !== $optimized) { + $msg = $optimized ? "optimized" : "unoptimized"; + $extra = $this->chatty ? + " (this backtrace is for the first inconsistent call, which was for a $msg raw definition)" + : ""; + throw new HTMLPurifier_Exception( + "Inconsistent use of optimized and unoptimized raw definition retrievals" . $extra + ); + } + } + // check if definition was in memory + if ($def) { + if ($def->setup) { + // invariant: $optimized === true (checked above) + return null; + } else { + return $def; + } + } + // if optimized, check if definition was in cache + // (because we do the memory check first, this formulation + // is prone to cache slamming, but I think + // guaranteeing that either /all/ of the raw + // setup code or /none/ of it is run is more important.) + if ($optimized) { + // This code path only gets run once; once we put + // something in $definitions (which is guaranteed by the + // trailing code), we always short-circuit above. + $def = $cache->get($this); + if ($def) { + // save the full definition for later, but don't + // return it yet + $this->definitions[$type] = $def; + return null; + } + } + // check invariants for creation + if (!$optimized) { + if (!is_null($this->get($type . '.DefinitionID'))) { + if ($this->chatty) { + $this->triggerError( + 'Due to a documentation error in previous version of HTML Purifier, your ' . + 'definitions are not being cached. If this is OK, you can remove the ' . + '%$type.DefinitionRev and %$type.DefinitionID declaration. Otherwise, ' . + 'modify your code to use maybeGetRawDefinition, and test if the returned ' . + 'value is null before making any edits (if it is null, that means that a ' . + 'cached version is available, and no raw operations are necessary). See ' . + '' . + 'Customize for more details', + E_USER_WARNING + ); + } else { + $this->triggerError( + "Useless DefinitionID declaration", + E_USER_WARNING + ); + } + } + } + // initialize it + $def = $this->initDefinition($type); + $def->optimized = $optimized; + return $def; + } + throw new HTMLPurifier_Exception("The impossible happened!"); + } + + /** + * Initialise definition + * + * @param string $type What type of definition to create + * + * @return HTMLPurifier_CSSDefinition|HTMLPurifier_HTMLDefinition|HTMLPurifier_URIDefinition + * @throws HTMLPurifier_Exception + */ + private function initDefinition($type) + { + // quick checks failed, let's create the object + if ($type == 'HTML') { + $def = new HTMLPurifier_HTMLDefinition(); + } elseif ($type == 'CSS') { + $def = new HTMLPurifier_CSSDefinition(); + } elseif ($type == 'URI') { + $def = new HTMLPurifier_URIDefinition(); + } else { + throw new HTMLPurifier_Exception( + "Definition of $type type not supported" + ); + } + $this->definitions[$type] = $def; + return $def; + } + + public function maybeGetRawDefinition($name) + { + return $this->getDefinition($name, true, true); + } + + /** + * @return HTMLPurifier_HTMLDefinition|null + */ + public function maybeGetRawHTMLDefinition() + { + return $this->getDefinition('HTML', true, true); + } + + /** + * @return HTMLPurifier_CSSDefinition|null + */ + public function maybeGetRawCSSDefinition() + { + return $this->getDefinition('CSS', true, true); + } + + /** + * @return HTMLPurifier_URIDefinition|null + */ + public function maybeGetRawURIDefinition() + { + return $this->getDefinition('URI', true, true); + } + + /** + * Loads configuration values from an array with the following structure: + * Namespace.Directive => Value + * + * @param array $config_array Configuration associative array + */ + public function loadArray($config_array) + { + if ($this->isFinalized('Cannot load directives after finalization')) { + return; + } + foreach ($config_array as $key => $value) { + $key = str_replace('_', '.', $key); + if (strpos($key, '.') !== false) { + $this->set($key, $value); + } else { + $namespace = $key; + $namespace_values = $value; + foreach ($namespace_values as $directive => $value2) { + $this->set($namespace .'.'. $directive, $value2); + } + } + } + } + + /** + * Returns a list of array(namespace, directive) for all directives + * that are allowed in a web-form context as per an allowed + * namespaces/directives list. + * + * @param array $allowed List of allowed namespaces/directives + * @param HTMLPurifier_ConfigSchema $schema Schema to use, if not global copy + * + * @return array + */ + public static function getAllowedDirectivesForForm($allowed, $schema = null) + { + if (!$schema) { + $schema = HTMLPurifier_ConfigSchema::instance(); + } + if ($allowed !== true) { + if (is_string($allowed)) { + $allowed = array($allowed); + } + $allowed_ns = array(); + $allowed_directives = array(); + $blacklisted_directives = array(); + foreach ($allowed as $ns_or_directive) { + if (strpos($ns_or_directive, '.') !== false) { + // directive + if ($ns_or_directive[0] == '-') { + $blacklisted_directives[substr($ns_or_directive, 1)] = true; + } else { + $allowed_directives[$ns_or_directive] = true; + } + } else { + // namespace + $allowed_ns[$ns_or_directive] = true; + } + } + } + $ret = array(); + foreach ($schema->info as $key => $def) { + list($ns, $directive) = explode('.', $key, 2); + if ($allowed !== true) { + if (isset($blacklisted_directives["$ns.$directive"])) { + continue; + } + if (!isset($allowed_directives["$ns.$directive"]) && !isset($allowed_ns[$ns])) { + continue; + } + } + if (isset($def->isAlias)) { + continue; + } + if ($directive == 'DefinitionID' || $directive == 'DefinitionRev') { + continue; + } + $ret[] = array($ns, $directive); + } + return $ret; + } + + /** + * Loads configuration values from $_GET/$_POST that were posted + * via ConfigForm + * + * @param array $array $_GET or $_POST array to import + * @param string|bool $index Index/name that the config variables are in + * @param array|bool $allowed List of allowed namespaces/directives + * @param bool $mq_fix Boolean whether or not to enable magic quotes fix + * @param HTMLPurifier_ConfigSchema $schema Schema to use, if not global copy + * + * @return mixed + */ + public static function loadArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null) + { + $ret = HTMLPurifier_Config::prepareArrayFromForm($array, $index, $allowed, $mq_fix, $schema); + $config = HTMLPurifier_Config::create($ret, $schema); + return $config; + } + + /** + * Merges in configuration values from $_GET/$_POST to object. NOT STATIC. + * + * @param array $array $_GET or $_POST array to import + * @param string|bool $index Index/name that the config variables are in + * @param array|bool $allowed List of allowed namespaces/directives + * @param bool $mq_fix Boolean whether or not to enable magic quotes fix + */ + public function mergeArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true) + { + $ret = HTMLPurifier_Config::prepareArrayFromForm($array, $index, $allowed, $mq_fix, $this->def); + $this->loadArray($ret); + } + + /** + * Prepares an array from a form into something usable for the more + * strict parts of HTMLPurifier_Config + * + * @param array $array $_GET or $_POST array to import + * @param string|bool $index Index/name that the config variables are in + * @param array|bool $allowed List of allowed namespaces/directives + * @param bool $mq_fix Boolean whether or not to enable magic quotes fix + * @param HTMLPurifier_ConfigSchema $schema Schema to use, if not global copy + * + * @return array + */ + public static function prepareArrayFromForm($array, $index = false, $allowed = true, $mq_fix = true, $schema = null) + { + if ($index !== false) { + $array = (isset($array[$index]) && is_array($array[$index])) ? $array[$index] : array(); + } + $mq = $mq_fix && version_compare(PHP_VERSION, '7.4.0', '<') && function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc(); + + $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $schema); + $ret = array(); + foreach ($allowed as $key) { + list($ns, $directive) = $key; + $skey = "$ns.$directive"; + if (!empty($array["Null_$skey"])) { + $ret[$ns][$directive] = null; + continue; + } + if (!isset($array[$skey])) { + continue; + } + $value = $mq ? stripslashes($array[$skey]) : $array[$skey]; + $ret[$ns][$directive] = $value; + } + return $ret; + } + + /** + * Loads configuration values from an ini file + * + * @param string $filename Name of ini file + */ + public function loadIni($filename) + { + if ($this->isFinalized('Cannot load directives after finalization')) { + return; + } + $array = parse_ini_file($filename, true); + $this->loadArray($array); + } + + /** + * Checks whether or not the configuration object is finalized. + * + * @param string|bool $error String error message, or false for no error + * + * @return bool + */ + public function isFinalized($error = false) + { + if ($this->finalized && $error) { + $this->triggerError($error, E_USER_ERROR); + } + return $this->finalized; + } + + /** + * Finalizes configuration only if auto finalize is on and not + * already finalized + */ + public function autoFinalize() + { + if ($this->autoFinalize) { + $this->finalize(); + } else { + $this->plist->squash(true); + } + } + + /** + * Finalizes a configuration object, prohibiting further change + */ + public function finalize() + { + $this->finalized = true; + $this->parser = null; + } + + /** + * Produces a nicely formatted error message by supplying the + * stack frame information OUTSIDE of HTMLPurifier_Config. + * + * @param string $msg An error message + * @param int $no An error number + */ + protected function triggerError($msg, $no) + { + // determine previous stack frame + $extra = ''; + if ($this->chatty) { + $trace = debug_backtrace(); + // zip(tail(trace), trace) -- but PHP is not Haskell har har + for ($i = 0, $c = count($trace); $i < $c - 1; $i++) { + // XXX this is not correct on some versions of HTML Purifier + if (isset($trace[$i + 1]['class']) && $trace[$i + 1]['class'] === 'HTMLPurifier_Config') { + continue; + } + $frame = $trace[$i]; + $extra = " invoked on line {$frame['line']} in file {$frame['file']}"; + break; + } + } + trigger_error($msg . $extra, $no); + } + + /** + * Returns a serialized form of the configuration object that can + * be reconstituted. + * + * @return string + */ + public function serialize() + { + $this->getDefinition('HTML'); + $this->getDefinition('CSS'); + $this->getDefinition('URI'); + return serialize($this); + } + +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema.php new file mode 100644 index 0000000..c3fe8cd --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema.php @@ -0,0 +1,176 @@ + array( + * 'Directive' => new stdClass(), + * ) + * ) + * + * The stdClass may have the following properties: + * + * - If isAlias isn't set: + * - type: Integer type of directive, see HTMLPurifier_VarParser for definitions + * - allow_null: If set, this directive allows null values + * - aliases: If set, an associative array of value aliases to real values + * - allowed: If set, a lookup array of allowed (string) values + * - If isAlias is set: + * - namespace: Namespace this directive aliases to + * - name: Directive name this directive aliases to + * + * In certain degenerate cases, stdClass will actually be an integer. In + * that case, the value is equivalent to an stdClass with the type + * property set to the integer. If the integer is negative, type is + * equal to the absolute value of integer, and allow_null is true. + * + * This class is friendly with HTMLPurifier_Config. If you need introspection + * about the schema, you're better of using the ConfigSchema_Interchange, + * which uses more memory but has much richer information. + * @type array + */ + public $info = array(); + + /** + * Application-wide singleton + * @type HTMLPurifier_ConfigSchema + */ + protected static $singleton; + + public function __construct() + { + $this->defaultPlist = new HTMLPurifier_PropertyList(); + } + + /** + * Unserializes the default ConfigSchema. + * @return HTMLPurifier_ConfigSchema + */ + public static function makeFromSerial() + { + $contents = file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/ConfigSchema/schema.ser'); + $r = unserialize($contents); + if (!$r) { + $hash = sha1($contents); + trigger_error("Unserialization of configuration schema failed, sha1 of file was $hash", E_USER_ERROR); + } + return $r; + } + + /** + * Retrieves an instance of the application-wide configuration definition. + * @param HTMLPurifier_ConfigSchema $prototype + * @return HTMLPurifier_ConfigSchema + */ + public static function instance($prototype = null) + { + if ($prototype !== null) { + HTMLPurifier_ConfigSchema::$singleton = $prototype; + } elseif (HTMLPurifier_ConfigSchema::$singleton === null || $prototype === true) { + HTMLPurifier_ConfigSchema::$singleton = HTMLPurifier_ConfigSchema::makeFromSerial(); + } + return HTMLPurifier_ConfigSchema::$singleton; + } + + /** + * Defines a directive for configuration + * @warning Will fail of directive's namespace is defined. + * @warning This method's signature is slightly different from the legacy + * define() static method! Beware! + * @param string $key Name of directive + * @param mixed $default Default value of directive + * @param string $type Allowed type of the directive. See + * HTMLPurifier_VarParser::$types for allowed values + * @param bool $allow_null Whether or not to allow null values + */ + public function add($key, $default, $type, $allow_null) + { + $obj = new stdClass(); + $obj->type = is_int($type) ? $type : HTMLPurifier_VarParser::$types[$type]; + if ($allow_null) { + $obj->allow_null = true; + } + $this->info[$key] = $obj; + $this->defaults[$key] = $default; + $this->defaultPlist->set($key, $default); + } + + /** + * Defines a directive value alias. + * + * Directive value aliases are convenient for developers because it lets + * them set a directive to several values and get the same result. + * @param string $key Name of Directive + * @param array $aliases Hash of aliased values to the real alias + */ + public function addValueAliases($key, $aliases) + { + if (!isset($this->info[$key]->aliases)) { + $this->info[$key]->aliases = array(); + } + foreach ($aliases as $alias => $real) { + $this->info[$key]->aliases[$alias] = $real; + } + } + + /** + * Defines a set of allowed values for a directive. + * @warning This is slightly different from the corresponding static + * method definition. + * @param string $key Name of directive + * @param array $allowed Lookup array of allowed values + */ + public function addAllowedValues($key, $allowed) + { + $this->info[$key]->allowed = $allowed; + } + + /** + * Defines a directive alias for backwards compatibility + * @param string $key Directive that will be aliased + * @param string $new_key Directive that the alias will be to + */ + public function addAlias($key, $new_key) + { + $obj = new stdClass; + $obj->key = $new_key; + $obj->isAlias = true; + $this->info[$key] = $obj; + } + + /** + * Replaces any stdClass that only has the type property with type integer. + */ + public function postProcess() + { + foreach ($this->info as $key => $v) { + if (count((array) $v) == 1) { + $this->info[$key] = $v->type; + } elseif (count((array) $v) == 2 && isset($v->allow_null)) { + $this->info[$key] = -$v->type; + } + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php new file mode 100644 index 0000000..d5906cd --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/ConfigSchema.php @@ -0,0 +1,48 @@ +directives as $d) { + $schema->add( + $d->id->key, + $d->default, + $d->type, + $d->typeAllowsNull + ); + if ($d->allowed !== null) { + $schema->addAllowedValues( + $d->id->key, + $d->allowed + ); + } + foreach ($d->aliases as $alias) { + $schema->addAlias( + $alias->key, + $d->id->key + ); + } + if ($d->valueAliases !== null) { + $schema->addValueAliases( + $d->id->key, + $d->valueAliases + ); + } + } + $schema->postProcess(); + return $schema; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/Xml.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/Xml.php new file mode 100644 index 0000000..5fa56f7 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Builder/Xml.php @@ -0,0 +1,144 @@ +startElement('div'); + + $purifier = HTMLPurifier::getInstance(); + $html = $purifier->purify($html); + $this->writeAttribute('xmlns', 'http://www.w3.org/1999/xhtml'); + $this->writeRaw($html); + + $this->endElement(); // div + } + + /** + * @param mixed $var + * @return string + */ + protected function export($var) + { + if ($var === array()) { + return 'array()'; + } + return var_export($var, true); + } + + /** + * @param HTMLPurifier_ConfigSchema_Interchange $interchange + */ + public function build($interchange) + { + // global access, only use as last resort + $this->interchange = $interchange; + + $this->setIndent(true); + $this->startDocument('1.0', 'UTF-8'); + $this->startElement('configdoc'); + $this->writeElement('title', $interchange->name); + + foreach ($interchange->directives as $directive) { + $this->buildDirective($directive); + } + + if ($this->namespace) { + $this->endElement(); + } // namespace + + $this->endElement(); // configdoc + $this->flush(); + } + + /** + * @param HTMLPurifier_ConfigSchema_Interchange_Directive $directive + */ + public function buildDirective($directive) + { + // Kludge, although I suppose having a notion of a "root namespace" + // certainly makes things look nicer when documentation is built. + // Depends on things being sorted. + if (!$this->namespace || $this->namespace !== $directive->id->getRootNamespace()) { + if ($this->namespace) { + $this->endElement(); + } // namespace + $this->namespace = $directive->id->getRootNamespace(); + $this->startElement('namespace'); + $this->writeAttribute('id', $this->namespace); + $this->writeElement('name', $this->namespace); + } + + $this->startElement('directive'); + $this->writeAttribute('id', $directive->id->toString()); + + $this->writeElement('name', $directive->id->getDirective()); + + $this->startElement('aliases'); + foreach ($directive->aliases as $alias) { + $this->writeElement('alias', $alias->toString()); + } + $this->endElement(); // aliases + + $this->startElement('constraints'); + if ($directive->version) { + $this->writeElement('version', $directive->version); + } + $this->startElement('type'); + if ($directive->typeAllowsNull) { + $this->writeAttribute('allow-null', 'yes'); + } + $this->text($directive->type); + $this->endElement(); // type + if ($directive->allowed) { + $this->startElement('allowed'); + foreach ($directive->allowed as $value => $x) { + $this->writeElement('value', $value); + } + $this->endElement(); // allowed + } + $this->writeElement('default', $this->export($directive->default)); + $this->writeAttribute('xml:space', 'preserve'); + if ($directive->external) { + $this->startElement('external'); + foreach ($directive->external as $project) { + $this->writeElement('project', $project); + } + $this->endElement(); + } + $this->endElement(); // constraints + + if ($directive->deprecatedVersion) { + $this->startElement('deprecated'); + $this->writeElement('version', $directive->deprecatedVersion); + $this->writeElement('use', $directive->deprecatedUse->toString()); + $this->endElement(); // deprecated + } + + $this->startElement('description'); + $this->writeHTMLDiv($directive->description); + $this->endElement(); // description + + $this->endElement(); // directive + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Exception.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Exception.php new file mode 100644 index 0000000..2671516 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Exception.php @@ -0,0 +1,11 @@ + array(directive info) + * @type HTMLPurifier_ConfigSchema_Interchange_Directive[] + */ + public $directives = array(); + + /** + * Adds a directive array to $directives + * @param HTMLPurifier_ConfigSchema_Interchange_Directive $directive + * @throws HTMLPurifier_ConfigSchema_Exception + */ + public function addDirective($directive) + { + if (isset($this->directives[$i = $directive->id->toString()])) { + throw new HTMLPurifier_ConfigSchema_Exception("Cannot redefine directive '$i'"); + } + $this->directives[$i] = $directive; + } + + /** + * Convenience function to perform standard validation. Throws exception + * on failed validation. + */ + public function validate() + { + $validator = new HTMLPurifier_ConfigSchema_Validator(); + return $validator->validate($this); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange/Directive.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange/Directive.php new file mode 100644 index 0000000..127a39a --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange/Directive.php @@ -0,0 +1,89 @@ + true). + * Null if all values are allowed. + * @type array + */ + public $allowed; + + /** + * List of aliases for the directive. + * e.g. array(new HTMLPurifier_ConfigSchema_Interchange_Id('Ns', 'Dir'))). + * @type HTMLPurifier_ConfigSchema_Interchange_Id[] + */ + public $aliases = array(); + + /** + * Hash of value aliases, e.g. array('alt' => 'real'). Null if value + * aliasing is disabled (necessary for non-scalar types). + * @type array + */ + public $valueAliases; + + /** + * Version of HTML Purifier the directive was introduced, e.g. '1.3.1'. + * Null if the directive has always existed. + * @type string + */ + public $version; + + /** + * ID of directive that supercedes this old directive. + * Null if not deprecated. + * @type HTMLPurifier_ConfigSchema_Interchange_Id + */ + public $deprecatedUse; + + /** + * Version of HTML Purifier this directive was deprecated. Null if not + * deprecated. + * @type string + */ + public $deprecatedVersion; + + /** + * List of external projects this directive depends on, e.g. array('CSSTidy'). + * @type array + */ + public $external = array(); +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange/Id.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange/Id.php new file mode 100644 index 0000000..126f09d --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Interchange/Id.php @@ -0,0 +1,58 @@ +key = $key; + } + + /** + * @return string + * @warning This is NOT magic, to ensure that people don't abuse SPL and + * cause problems for PHP 5.0 support. + */ + public function toString() + { + return $this->key; + } + + /** + * @return string + */ + public function getRootNamespace() + { + return substr($this->key, 0, strpos($this->key, ".")); + } + + /** + * @return string + */ + public function getDirective() + { + return substr($this->key, strpos($this->key, ".") + 1); + } + + /** + * @param string $id + * @return HTMLPurifier_ConfigSchema_Interchange_Id + */ + public static function make($id) + { + return new HTMLPurifier_ConfigSchema_Interchange_Id($id); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/InterchangeBuilder.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/InterchangeBuilder.php new file mode 100644 index 0000000..655e6dd --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/InterchangeBuilder.php @@ -0,0 +1,226 @@ +varParser = $varParser ? $varParser : new HTMLPurifier_VarParser_Native(); + } + + /** + * @param string $dir + * @return HTMLPurifier_ConfigSchema_Interchange + */ + public static function buildFromDirectory($dir = null) + { + $builder = new HTMLPurifier_ConfigSchema_InterchangeBuilder(); + $interchange = new HTMLPurifier_ConfigSchema_Interchange(); + return $builder->buildDir($interchange, $dir); + } + + /** + * @param HTMLPurifier_ConfigSchema_Interchange $interchange + * @param string $dir + * @return HTMLPurifier_ConfigSchema_Interchange + */ + public function buildDir($interchange, $dir = null) + { + if (!$dir) { + $dir = HTMLPURIFIER_PREFIX . '/HTMLPurifier/ConfigSchema/schema'; + } + if (file_exists($dir . '/info.ini')) { + $info = parse_ini_file($dir . '/info.ini'); + $interchange->name = $info['name']; + } + + $files = array(); + $dh = opendir($dir); + while (false !== ($file = readdir($dh))) { + if (!$file || $file[0] == '.' || strrchr($file, '.') !== '.txt') { + continue; + } + $files[] = $file; + } + closedir($dh); + + sort($files); + foreach ($files as $file) { + $this->buildFile($interchange, $dir . '/' . $file); + } + return $interchange; + } + + /** + * @param HTMLPurifier_ConfigSchema_Interchange $interchange + * @param string $file + */ + public function buildFile($interchange, $file) + { + $parser = new HTMLPurifier_StringHashParser(); + $this->build( + $interchange, + new HTMLPurifier_StringHash($parser->parseFile($file)) + ); + } + + /** + * Builds an interchange object based on a hash. + * @param HTMLPurifier_ConfigSchema_Interchange $interchange HTMLPurifier_ConfigSchema_Interchange object to build + * @param HTMLPurifier_StringHash $hash source data + * @throws HTMLPurifier_ConfigSchema_Exception + */ + public function build($interchange, $hash) + { + if (!$hash instanceof HTMLPurifier_StringHash) { + $hash = new HTMLPurifier_StringHash($hash); + } + if (!isset($hash['ID'])) { + throw new HTMLPurifier_ConfigSchema_Exception('Hash does not have any ID'); + } + if (strpos($hash['ID'], '.') === false) { + if (count($hash) == 2 && isset($hash['DESCRIPTION'])) { + $hash->offsetGet('DESCRIPTION'); // prevent complaining + } else { + throw new HTMLPurifier_ConfigSchema_Exception('All directives must have a namespace'); + } + } else { + $this->buildDirective($interchange, $hash); + } + $this->_findUnused($hash); + } + + /** + * @param HTMLPurifier_ConfigSchema_Interchange $interchange + * @param HTMLPurifier_StringHash $hash + * @throws HTMLPurifier_ConfigSchema_Exception + */ + public function buildDirective($interchange, $hash) + { + $directive = new HTMLPurifier_ConfigSchema_Interchange_Directive(); + + // These are required elements: + $directive->id = $this->id($hash->offsetGet('ID')); + $id = $directive->id->toString(); // convenience + + if (isset($hash['TYPE'])) { + $type = explode('/', $hash->offsetGet('TYPE')); + if (isset($type[1])) { + $directive->typeAllowsNull = true; + } + $directive->type = $type[0]; + } else { + throw new HTMLPurifier_ConfigSchema_Exception("TYPE in directive hash '$id' not defined"); + } + + if (isset($hash['DEFAULT'])) { + try { + $directive->default = $this->varParser->parse( + $hash->offsetGet('DEFAULT'), + $directive->type, + $directive->typeAllowsNull + ); + } catch (HTMLPurifier_VarParserException $e) { + throw new HTMLPurifier_ConfigSchema_Exception($e->getMessage() . " in DEFAULT in directive hash '$id'"); + } + } + + if (isset($hash['DESCRIPTION'])) { + $directive->description = $hash->offsetGet('DESCRIPTION'); + } + + if (isset($hash['ALLOWED'])) { + $directive->allowed = $this->lookup($this->evalArray($hash->offsetGet('ALLOWED'))); + } + + if (isset($hash['VALUE-ALIASES'])) { + $directive->valueAliases = $this->evalArray($hash->offsetGet('VALUE-ALIASES')); + } + + if (isset($hash['ALIASES'])) { + $raw_aliases = trim($hash->offsetGet('ALIASES')); + $aliases = preg_split('/\s*,\s*/', $raw_aliases); + foreach ($aliases as $alias) { + $directive->aliases[] = $this->id($alias); + } + } + + if (isset($hash['VERSION'])) { + $directive->version = $hash->offsetGet('VERSION'); + } + + if (isset($hash['DEPRECATED-USE'])) { + $directive->deprecatedUse = $this->id($hash->offsetGet('DEPRECATED-USE')); + } + + if (isset($hash['DEPRECATED-VERSION'])) { + $directive->deprecatedVersion = $hash->offsetGet('DEPRECATED-VERSION'); + } + + if (isset($hash['EXTERNAL'])) { + $directive->external = preg_split('/\s*,\s*/', trim($hash->offsetGet('EXTERNAL'))); + } + + $interchange->addDirective($directive); + } + + /** + * Evaluates an array PHP code string without array() wrapper + * @param string $contents + */ + protected function evalArray($contents) + { + return eval('return array(' . $contents . ');'); + } + + /** + * Converts an array list into a lookup array. + * @param array $array + * @return array + */ + protected function lookup($array) + { + $ret = array(); + foreach ($array as $val) { + $ret[$val] = true; + } + return $ret; + } + + /** + * Convenience function that creates an HTMLPurifier_ConfigSchema_Interchange_Id + * object based on a string Id. + * @param string $id + * @return HTMLPurifier_ConfigSchema_Interchange_Id + */ + protected function id($id) + { + return HTMLPurifier_ConfigSchema_Interchange_Id::make($id); + } + + /** + * Triggers errors for any unused keys passed in the hash; such keys + * may indicate typos, missing values, etc. + * @param HTMLPurifier_StringHash $hash Hash to check. + */ + protected function _findUnused($hash) + { + $accessed = $hash->getAccessed(); + foreach ($hash as $k => $v) { + if (!isset($accessed[$k])) { + trigger_error("String hash key '$k' not used by builder", E_USER_NOTICE); + } + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Validator.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Validator.php new file mode 100644 index 0000000..fb31277 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/Validator.php @@ -0,0 +1,248 @@ +parser = new HTMLPurifier_VarParser(); + } + + /** + * Validates a fully-formed interchange object. + * @param HTMLPurifier_ConfigSchema_Interchange $interchange + * @return bool + */ + public function validate($interchange) + { + $this->interchange = $interchange; + $this->aliases = array(); + // PHP is a bit lax with integer <=> string conversions in + // arrays, so we don't use the identical !== comparison + foreach ($interchange->directives as $i => $directive) { + $id = $directive->id->toString(); + if ($i != $id) { + $this->error(false, "Integrity violation: key '$i' does not match internal id '$id'"); + } + $this->validateDirective($directive); + } + return true; + } + + /** + * Validates a HTMLPurifier_ConfigSchema_Interchange_Id object. + * @param HTMLPurifier_ConfigSchema_Interchange_Id $id + */ + public function validateId($id) + { + $id_string = $id->toString(); + $this->context[] = "id '$id_string'"; + if (!$id instanceof HTMLPurifier_ConfigSchema_Interchange_Id) { + // handled by InterchangeBuilder + $this->error(false, 'is not an instance of HTMLPurifier_ConfigSchema_Interchange_Id'); + } + // keys are now unconstrained (we might want to narrow down to A-Za-z0-9.) + // we probably should check that it has at least one namespace + $this->with($id, 'key') + ->assertNotEmpty() + ->assertIsString(); // implicit assertIsString handled by InterchangeBuilder + array_pop($this->context); + } + + /** + * Validates a HTMLPurifier_ConfigSchema_Interchange_Directive object. + * @param HTMLPurifier_ConfigSchema_Interchange_Directive $d + */ + public function validateDirective($d) + { + $id = $d->id->toString(); + $this->context[] = "directive '$id'"; + $this->validateId($d->id); + + $this->with($d, 'description') + ->assertNotEmpty(); + + // BEGIN - handled by InterchangeBuilder + $this->with($d, 'type') + ->assertNotEmpty(); + $this->with($d, 'typeAllowsNull') + ->assertIsBool(); + try { + // This also tests validity of $d->type + $this->parser->parse($d->default, $d->type, $d->typeAllowsNull); + } catch (HTMLPurifier_VarParserException $e) { + $this->error('default', 'had error: ' . $e->getMessage()); + } + // END - handled by InterchangeBuilder + + if (!is_null($d->allowed) || !empty($d->valueAliases)) { + // allowed and valueAliases require that we be dealing with + // strings, so check for that early. + $d_int = HTMLPurifier_VarParser::$types[$d->type]; + if (!isset(HTMLPurifier_VarParser::$stringTypes[$d_int])) { + $this->error('type', 'must be a string type when used with allowed or value aliases'); + } + } + + $this->validateDirectiveAllowed($d); + $this->validateDirectiveValueAliases($d); + $this->validateDirectiveAliases($d); + + array_pop($this->context); + } + + /** + * Extra validation if $allowed member variable of + * HTMLPurifier_ConfigSchema_Interchange_Directive is defined. + * @param HTMLPurifier_ConfigSchema_Interchange_Directive $d + */ + public function validateDirectiveAllowed($d) + { + if (is_null($d->allowed)) { + return; + } + $this->with($d, 'allowed') + ->assertNotEmpty() + ->assertIsLookup(); // handled by InterchangeBuilder + if (is_string($d->default) && !isset($d->allowed[$d->default])) { + $this->error('default', 'must be an allowed value'); + } + $this->context[] = 'allowed'; + foreach ($d->allowed as $val => $x) { + if (!is_string($val)) { + $this->error("value $val", 'must be a string'); + } + } + array_pop($this->context); + } + + /** + * Extra validation if $valueAliases member variable of + * HTMLPurifier_ConfigSchema_Interchange_Directive is defined. + * @param HTMLPurifier_ConfigSchema_Interchange_Directive $d + */ + public function validateDirectiveValueAliases($d) + { + if (is_null($d->valueAliases)) { + return; + } + $this->with($d, 'valueAliases') + ->assertIsArray(); // handled by InterchangeBuilder + $this->context[] = 'valueAliases'; + foreach ($d->valueAliases as $alias => $real) { + if (!is_string($alias)) { + $this->error("alias $alias", 'must be a string'); + } + if (!is_string($real)) { + $this->error("alias target $real from alias '$alias'", 'must be a string'); + } + if ($alias === $real) { + $this->error("alias '$alias'", "must not be an alias to itself"); + } + } + if (!is_null($d->allowed)) { + foreach ($d->valueAliases as $alias => $real) { + if (isset($d->allowed[$alias])) { + $this->error("alias '$alias'", 'must not be an allowed value'); + } elseif (!isset($d->allowed[$real])) { + $this->error("alias '$alias'", 'must be an alias to an allowed value'); + } + } + } + array_pop($this->context); + } + + /** + * Extra validation if $aliases member variable of + * HTMLPurifier_ConfigSchema_Interchange_Directive is defined. + * @param HTMLPurifier_ConfigSchema_Interchange_Directive $d + */ + public function validateDirectiveAliases($d) + { + $this->with($d, 'aliases') + ->assertIsArray(); // handled by InterchangeBuilder + $this->context[] = 'aliases'; + foreach ($d->aliases as $alias) { + $this->validateId($alias); + $s = $alias->toString(); + if (isset($this->interchange->directives[$s])) { + $this->error("alias '$s'", 'collides with another directive'); + } + if (isset($this->aliases[$s])) { + $other_directive = $this->aliases[$s]; + $this->error("alias '$s'", "collides with alias for directive '$other_directive'"); + } + $this->aliases[$s] = $d->id->toString(); + } + array_pop($this->context); + } + + // protected helper functions + + /** + * Convenience function for generating HTMLPurifier_ConfigSchema_ValidatorAtom + * for validating simple member variables of objects. + * @param $obj + * @param $member + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + protected function with($obj, $member) + { + return new HTMLPurifier_ConfigSchema_ValidatorAtom($this->getFormattedContext(), $obj, $member); + } + + /** + * Emits an error, providing helpful context. + * @throws HTMLPurifier_ConfigSchema_Exception + */ + protected function error($target, $msg) + { + if ($target !== false) { + $prefix = ucfirst($target) . ' in ' . $this->getFormattedContext(); + } else { + $prefix = ucfirst($this->getFormattedContext()); + } + throw new HTMLPurifier_ConfigSchema_Exception(trim($prefix . ' ' . $msg)); + } + + /** + * Returns a formatted context string. + * @return string + */ + protected function getFormattedContext() + { + return implode(' in ', array_reverse($this->context)); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/ValidatorAtom.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/ValidatorAtom.php new file mode 100644 index 0000000..c9aa364 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/ValidatorAtom.php @@ -0,0 +1,130 @@ +context = $context; + $this->obj = $obj; + $this->member = $member; + $this->contents =& $obj->$member; + } + + /** + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + public function assertIsString() + { + if (!is_string($this->contents)) { + $this->error('must be a string'); + } + return $this; + } + + /** + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + public function assertIsBool() + { + if (!is_bool($this->contents)) { + $this->error('must be a boolean'); + } + return $this; + } + + /** + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + public function assertIsArray() + { + if (!is_array($this->contents)) { + $this->error('must be an array'); + } + return $this; + } + + /** + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + public function assertNotNull() + { + if ($this->contents === null) { + $this->error('must not be null'); + } + return $this; + } + + /** + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + public function assertAlnum() + { + $this->assertIsString(); + if (!ctype_alnum($this->contents)) { + $this->error('must be alphanumeric'); + } + return $this; + } + + /** + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + public function assertNotEmpty() + { + if (empty($this->contents)) { + $this->error('must not be empty'); + } + return $this; + } + + /** + * @return HTMLPurifier_ConfigSchema_ValidatorAtom + */ + public function assertIsLookup() + { + $this->assertIsArray(); + foreach ($this->contents as $v) { + if ($v !== true) { + $this->error('must be a lookup array'); + } + } + return $this; + } + + /** + * @param string $msg + * @throws HTMLPurifier_ConfigSchema_Exception + */ + protected function error($msg) + { + throw new HTMLPurifier_ConfigSchema_Exception(ucfirst($this->member) . ' in ' . $this->context . ' ' . $msg); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema.ser b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema.ser new file mode 100644 index 0000000..3cd756b --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema.ser @@ -0,0 +1 @@ +O:25:"HTMLPurifier_ConfigSchema":3:{s:8:"defaults";a:128:{s:19:"Attr.AllowedClasses";N;s:24:"Attr.AllowedFrameTargets";a:0:{}s:15:"Attr.AllowedRel";a:0:{}s:15:"Attr.AllowedRev";a:0:{}s:18:"Attr.ClassUseCDATA";N;s:20:"Attr.DefaultImageAlt";N;s:24:"Attr.DefaultInvalidImage";s:0:"";s:27:"Attr.DefaultInvalidImageAlt";s:13:"Invalid image";s:19:"Attr.DefaultTextDir";s:3:"ltr";s:13:"Attr.EnableID";b:0;s:21:"Attr.ForbiddenClasses";a:0:{}s:13:"Attr.ID.HTML5";N;s:16:"Attr.IDBlacklist";a:0:{}s:22:"Attr.IDBlacklistRegexp";N;s:13:"Attr.IDPrefix";s:0:"";s:18:"Attr.IDPrefixLocal";s:0:"";s:24:"AutoFormat.AutoParagraph";b:0;s:17:"AutoFormat.Custom";a:0:{}s:25:"AutoFormat.DisplayLinkURI";b:0;s:18:"AutoFormat.Linkify";b:0;s:33:"AutoFormat.PurifierLinkify.DocURL";s:3:"#%s";s:26:"AutoFormat.PurifierLinkify";b:0;s:32:"AutoFormat.RemoveEmpty.Predicate";a:4:{s:8:"colgroup";a:0:{}s:2:"th";a:0:{}s:2:"td";a:0:{}s:6:"iframe";a:1:{i:0;s:3:"src";}}s:44:"AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions";a:2:{s:2:"td";b:1;s:2:"th";b:1;}s:33:"AutoFormat.RemoveEmpty.RemoveNbsp";b:0;s:22:"AutoFormat.RemoveEmpty";b:0;s:39:"AutoFormat.RemoveSpansWithoutAttributes";b:0;s:19:"CSS.AllowDuplicates";b:0;s:18:"CSS.AllowImportant";b:0;s:15:"CSS.AllowTricky";b:0;s:16:"CSS.AllowedFonts";N;s:21:"CSS.AllowedProperties";N;s:17:"CSS.DefinitionRev";i:1;s:23:"CSS.ForbiddenProperties";a:0:{}s:16:"CSS.MaxImgLength";s:6:"1200px";s:15:"CSS.Proprietary";b:0;s:11:"CSS.Trusted";b:0;s:20:"Cache.DefinitionImpl";s:10:"Serializer";s:20:"Cache.SerializerPath";N;s:27:"Cache.SerializerPermissions";i:493;s:22:"Core.AggressivelyFixLt";b:1;s:29:"Core.AggressivelyRemoveScript";b:1;s:28:"Core.AllowHostnameUnderscore";b:0;s:23:"Core.AllowParseManyTags";b:0;s:18:"Core.CollectErrors";b:0;s:18:"Core.ColorKeywords";a:148:{s:9:"aliceblue";s:7:"#F0F8FF";s:12:"antiquewhite";s:7:"#FAEBD7";s:4:"aqua";s:7:"#00FFFF";s:10:"aquamarine";s:7:"#7FFFD4";s:5:"azure";s:7:"#F0FFFF";s:5:"beige";s:7:"#F5F5DC";s:6:"bisque";s:7:"#FFE4C4";s:5:"black";s:7:"#000000";s:14:"blanchedalmond";s:7:"#FFEBCD";s:4:"blue";s:7:"#0000FF";s:10:"blueviolet";s:7:"#8A2BE2";s:5:"brown";s:7:"#A52A2A";s:9:"burlywood";s:7:"#DEB887";s:9:"cadetblue";s:7:"#5F9EA0";s:10:"chartreuse";s:7:"#7FFF00";s:9:"chocolate";s:7:"#D2691E";s:5:"coral";s:7:"#FF7F50";s:14:"cornflowerblue";s:7:"#6495ED";s:8:"cornsilk";s:7:"#FFF8DC";s:7:"crimson";s:7:"#DC143C";s:4:"cyan";s:7:"#00FFFF";s:8:"darkblue";s:7:"#00008B";s:8:"darkcyan";s:7:"#008B8B";s:13:"darkgoldenrod";s:7:"#B8860B";s:8:"darkgray";s:7:"#A9A9A9";s:8:"darkgrey";s:7:"#A9A9A9";s:9:"darkgreen";s:7:"#006400";s:9:"darkkhaki";s:7:"#BDB76B";s:11:"darkmagenta";s:7:"#8B008B";s:14:"darkolivegreen";s:7:"#556B2F";s:10:"darkorange";s:7:"#FF8C00";s:10:"darkorchid";s:7:"#9932CC";s:7:"darkred";s:7:"#8B0000";s:10:"darksalmon";s:7:"#E9967A";s:12:"darkseagreen";s:7:"#8FBC8F";s:13:"darkslateblue";s:7:"#483D8B";s:13:"darkslategray";s:7:"#2F4F4F";s:13:"darkslategrey";s:7:"#2F4F4F";s:13:"darkturquoise";s:7:"#00CED1";s:10:"darkviolet";s:7:"#9400D3";s:8:"deeppink";s:7:"#FF1493";s:11:"deepskyblue";s:7:"#00BFFF";s:7:"dimgray";s:7:"#696969";s:7:"dimgrey";s:7:"#696969";s:10:"dodgerblue";s:7:"#1E90FF";s:9:"firebrick";s:7:"#B22222";s:11:"floralwhite";s:7:"#FFFAF0";s:11:"forestgreen";s:7:"#228B22";s:7:"fuchsia";s:7:"#FF00FF";s:9:"gainsboro";s:7:"#DCDCDC";s:10:"ghostwhite";s:7:"#F8F8FF";s:4:"gold";s:7:"#FFD700";s:9:"goldenrod";s:7:"#DAA520";s:4:"gray";s:7:"#808080";s:4:"grey";s:7:"#808080";s:5:"green";s:7:"#008000";s:11:"greenyellow";s:7:"#ADFF2F";s:8:"honeydew";s:7:"#F0FFF0";s:7:"hotpink";s:7:"#FF69B4";s:9:"indianred";s:7:"#CD5C5C";s:6:"indigo";s:7:"#4B0082";s:5:"ivory";s:7:"#FFFFF0";s:5:"khaki";s:7:"#F0E68C";s:8:"lavender";s:7:"#E6E6FA";s:13:"lavenderblush";s:7:"#FFF0F5";s:9:"lawngreen";s:7:"#7CFC00";s:12:"lemonchiffon";s:7:"#FFFACD";s:9:"lightblue";s:7:"#ADD8E6";s:10:"lightcoral";s:7:"#F08080";s:9:"lightcyan";s:7:"#E0FFFF";s:20:"lightgoldenrodyellow";s:7:"#FAFAD2";s:9:"lightgray";s:7:"#D3D3D3";s:9:"lightgrey";s:7:"#D3D3D3";s:10:"lightgreen";s:7:"#90EE90";s:9:"lightpink";s:7:"#FFB6C1";s:11:"lightsalmon";s:7:"#FFA07A";s:13:"lightseagreen";s:7:"#20B2AA";s:12:"lightskyblue";s:7:"#87CEFA";s:14:"lightslategray";s:7:"#778899";s:14:"lightslategrey";s:7:"#778899";s:14:"lightsteelblue";s:7:"#B0C4DE";s:11:"lightyellow";s:7:"#FFFFE0";s:4:"lime";s:7:"#00FF00";s:9:"limegreen";s:7:"#32CD32";s:5:"linen";s:7:"#FAF0E6";s:7:"magenta";s:7:"#FF00FF";s:6:"maroon";s:7:"#800000";s:16:"mediumaquamarine";s:7:"#66CDAA";s:10:"mediumblue";s:7:"#0000CD";s:12:"mediumorchid";s:7:"#BA55D3";s:12:"mediumpurple";s:7:"#9370DB";s:14:"mediumseagreen";s:7:"#3CB371";s:15:"mediumslateblue";s:7:"#7B68EE";s:17:"mediumspringgreen";s:7:"#00FA9A";s:15:"mediumturquoise";s:7:"#48D1CC";s:15:"mediumvioletred";s:7:"#C71585";s:12:"midnightblue";s:7:"#191970";s:9:"mintcream";s:7:"#F5FFFA";s:9:"mistyrose";s:7:"#FFE4E1";s:8:"moccasin";s:7:"#FFE4B5";s:11:"navajowhite";s:7:"#FFDEAD";s:4:"navy";s:7:"#000080";s:7:"oldlace";s:7:"#FDF5E6";s:5:"olive";s:7:"#808000";s:9:"olivedrab";s:7:"#6B8E23";s:6:"orange";s:7:"#FFA500";s:9:"orangered";s:7:"#FF4500";s:6:"orchid";s:7:"#DA70D6";s:13:"palegoldenrod";s:7:"#EEE8AA";s:9:"palegreen";s:7:"#98FB98";s:13:"paleturquoise";s:7:"#AFEEEE";s:13:"palevioletred";s:7:"#DB7093";s:10:"papayawhip";s:7:"#FFEFD5";s:9:"peachpuff";s:7:"#FFDAB9";s:4:"peru";s:7:"#CD853F";s:4:"pink";s:7:"#FFC0CB";s:4:"plum";s:7:"#DDA0DD";s:10:"powderblue";s:7:"#B0E0E6";s:6:"purple";s:7:"#800080";s:13:"rebeccapurple";s:7:"#663399";s:3:"red";s:7:"#FF0000";s:9:"rosybrown";s:7:"#BC8F8F";s:9:"royalblue";s:7:"#4169E1";s:11:"saddlebrown";s:7:"#8B4513";s:6:"salmon";s:7:"#FA8072";s:10:"sandybrown";s:7:"#F4A460";s:8:"seagreen";s:7:"#2E8B57";s:8:"seashell";s:7:"#FFF5EE";s:6:"sienna";s:7:"#A0522D";s:6:"silver";s:7:"#C0C0C0";s:7:"skyblue";s:7:"#87CEEB";s:9:"slateblue";s:7:"#6A5ACD";s:9:"slategray";s:7:"#708090";s:9:"slategrey";s:7:"#708090";s:4:"snow";s:7:"#FFFAFA";s:11:"springgreen";s:7:"#00FF7F";s:9:"steelblue";s:7:"#4682B4";s:3:"tan";s:7:"#D2B48C";s:4:"teal";s:7:"#008080";s:7:"thistle";s:7:"#D8BFD8";s:6:"tomato";s:7:"#FF6347";s:9:"turquoise";s:7:"#40E0D0";s:6:"violet";s:7:"#EE82EE";s:5:"wheat";s:7:"#F5DEB3";s:5:"white";s:7:"#FFFFFF";s:10:"whitesmoke";s:7:"#F5F5F5";s:6:"yellow";s:7:"#FFFF00";s:11:"yellowgreen";s:7:"#9ACD32";}s:30:"Core.ConvertDocumentToFragment";b:1;s:36:"Core.DirectLexLineNumberSyncInterval";i:0;s:20:"Core.DisableExcludes";b:0;s:15:"Core.EnableIDNA";b:0;s:13:"Core.Encoding";s:5:"utf-8";s:26:"Core.EscapeInvalidChildren";b:0;s:22:"Core.EscapeInvalidTags";b:0;s:29:"Core.EscapeNonASCIICharacters";b:0;s:19:"Core.HiddenElements";a:2:{s:6:"script";b:1;s:5:"style";b:1;}s:13:"Core.Language";s:2:"en";s:24:"Core.LegacyEntityDecoder";b:0;s:14:"Core.LexerImpl";N;s:24:"Core.MaintainLineNumbers";N;s:22:"Core.NormalizeNewlines";b:1;s:17:"Core.RemoveBlanks";b:0;s:21:"Core.RemoveInvalidImg";b:1;s:33:"Core.RemoveProcessingInstructions";b:0;s:25:"Core.RemoveScriptContents";N;s:13:"Filter.Custom";a:0:{}s:34:"Filter.ExtractStyleBlocks.Escaping";b:1;s:31:"Filter.ExtractStyleBlocks.Scope";N;s:34:"Filter.ExtractStyleBlocks.TidyImpl";N;s:25:"Filter.ExtractStyleBlocks";b:0;s:14:"Filter.YouTube";b:0;s:12:"HTML.Allowed";N;s:22:"HTML.AllowedAttributes";N;s:20:"HTML.AllowedComments";a:0:{}s:26:"HTML.AllowedCommentsRegexp";N;s:20:"HTML.AllowedElements";N;s:19:"HTML.AllowedModules";N;s:23:"HTML.Attr.Name.UseCDATA";b:0;s:17:"HTML.BlockWrapper";s:1:"p";s:16:"HTML.CoreModules";a:7:{s:9:"Structure";b:1;s:4:"Text";b:1;s:9:"Hypertext";b:1;s:4:"List";b:1;s:22:"NonXMLCommonAttributes";b:1;s:19:"XMLCommonAttributes";b:1;s:16:"CommonAttributes";b:1;}s:18:"HTML.CustomDoctype";N;s:17:"HTML.DefinitionID";N;s:18:"HTML.DefinitionRev";i:1;s:12:"HTML.Doctype";N;s:25:"HTML.FlashAllowFullScreen";b:0;s:24:"HTML.ForbiddenAttributes";a:0:{}s:22:"HTML.ForbiddenElements";a:0:{}s:10:"HTML.Forms";b:0;s:17:"HTML.MaxImgLength";i:1200;s:13:"HTML.Nofollow";b:0;s:11:"HTML.Parent";s:3:"div";s:16:"HTML.Proprietary";b:0;s:14:"HTML.SafeEmbed";b:0;s:15:"HTML.SafeIframe";b:0;s:15:"HTML.SafeObject";b:0;s:18:"HTML.SafeScripting";a:0:{}s:11:"HTML.Strict";b:0;s:16:"HTML.TargetBlank";b:0;s:19:"HTML.TargetNoopener";b:1;s:21:"HTML.TargetNoreferrer";b:1;s:12:"HTML.TidyAdd";a:0:{}s:14:"HTML.TidyLevel";s:6:"medium";s:15:"HTML.TidyRemove";a:0:{}s:12:"HTML.Trusted";b:0;s:10:"HTML.XHTML";b:1;s:28:"Output.CommentScriptContents";b:1;s:19:"Output.FixInnerHTML";b:1;s:18:"Output.FlashCompat";b:0;s:14:"Output.Newline";N;s:15:"Output.SortAttr";b:0;s:17:"Output.TidyFormat";b:0;s:17:"Test.ForceNoIconv";b:0;s:18:"URI.AllowedSchemes";a:7:{s:4:"http";b:1;s:5:"https";b:1;s:6:"mailto";b:1;s:3:"ftp";b:1;s:4:"nntp";b:1;s:4:"news";b:1;s:3:"tel";b:1;}s:8:"URI.Base";N;s:17:"URI.DefaultScheme";s:4:"http";s:16:"URI.DefinitionID";N;s:17:"URI.DefinitionRev";i:1;s:11:"URI.Disable";b:0;s:19:"URI.DisableExternal";b:0;s:28:"URI.DisableExternalResources";b:0;s:20:"URI.DisableResources";b:0;s:8:"URI.Host";N;s:17:"URI.HostBlacklist";a:0:{}s:16:"URI.MakeAbsolute";b:0;s:9:"URI.Munge";N;s:18:"URI.MungeResources";b:0;s:18:"URI.MungeSecretKey";N;s:26:"URI.OverrideAllowedSchemes";b:1;s:20:"URI.SafeIframeRegexp";N;}s:12:"defaultPlist";O:25:"HTMLPurifier_PropertyList":3:{s:7:"*data";a:128:{s:19:"Attr.AllowedClasses";N;s:24:"Attr.AllowedFrameTargets";a:0:{}s:15:"Attr.AllowedRel";a:0:{}s:15:"Attr.AllowedRev";a:0:{}s:18:"Attr.ClassUseCDATA";N;s:20:"Attr.DefaultImageAlt";N;s:24:"Attr.DefaultInvalidImage";s:0:"";s:27:"Attr.DefaultInvalidImageAlt";s:13:"Invalid image";s:19:"Attr.DefaultTextDir";s:3:"ltr";s:13:"Attr.EnableID";b:0;s:21:"Attr.ForbiddenClasses";a:0:{}s:13:"Attr.ID.HTML5";N;s:16:"Attr.IDBlacklist";a:0:{}s:22:"Attr.IDBlacklistRegexp";N;s:13:"Attr.IDPrefix";s:0:"";s:18:"Attr.IDPrefixLocal";s:0:"";s:24:"AutoFormat.AutoParagraph";b:0;s:17:"AutoFormat.Custom";a:0:{}s:25:"AutoFormat.DisplayLinkURI";b:0;s:18:"AutoFormat.Linkify";b:0;s:33:"AutoFormat.PurifierLinkify.DocURL";s:3:"#%s";s:26:"AutoFormat.PurifierLinkify";b:0;s:32:"AutoFormat.RemoveEmpty.Predicate";a:4:{s:8:"colgroup";a:0:{}s:2:"th";a:0:{}s:2:"td";a:0:{}s:6:"iframe";a:1:{i:0;s:3:"src";}}s:44:"AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions";a:2:{s:2:"td";b:1;s:2:"th";b:1;}s:33:"AutoFormat.RemoveEmpty.RemoveNbsp";b:0;s:22:"AutoFormat.RemoveEmpty";b:0;s:39:"AutoFormat.RemoveSpansWithoutAttributes";b:0;s:19:"CSS.AllowDuplicates";b:0;s:18:"CSS.AllowImportant";b:0;s:15:"CSS.AllowTricky";b:0;s:16:"CSS.AllowedFonts";N;s:21:"CSS.AllowedProperties";N;s:17:"CSS.DefinitionRev";i:1;s:23:"CSS.ForbiddenProperties";a:0:{}s:16:"CSS.MaxImgLength";s:6:"1200px";s:15:"CSS.Proprietary";b:0;s:11:"CSS.Trusted";b:0;s:20:"Cache.DefinitionImpl";s:10:"Serializer";s:20:"Cache.SerializerPath";N;s:27:"Cache.SerializerPermissions";i:493;s:22:"Core.AggressivelyFixLt";b:1;s:29:"Core.AggressivelyRemoveScript";b:1;s:28:"Core.AllowHostnameUnderscore";b:0;s:23:"Core.AllowParseManyTags";b:0;s:18:"Core.CollectErrors";b:0;s:18:"Core.ColorKeywords";a:148:{s:9:"aliceblue";s:7:"#F0F8FF";s:12:"antiquewhite";s:7:"#FAEBD7";s:4:"aqua";s:7:"#00FFFF";s:10:"aquamarine";s:7:"#7FFFD4";s:5:"azure";s:7:"#F0FFFF";s:5:"beige";s:7:"#F5F5DC";s:6:"bisque";s:7:"#FFE4C4";s:5:"black";s:7:"#000000";s:14:"blanchedalmond";s:7:"#FFEBCD";s:4:"blue";s:7:"#0000FF";s:10:"blueviolet";s:7:"#8A2BE2";s:5:"brown";s:7:"#A52A2A";s:9:"burlywood";s:7:"#DEB887";s:9:"cadetblue";s:7:"#5F9EA0";s:10:"chartreuse";s:7:"#7FFF00";s:9:"chocolate";s:7:"#D2691E";s:5:"coral";s:7:"#FF7F50";s:14:"cornflowerblue";s:7:"#6495ED";s:8:"cornsilk";s:7:"#FFF8DC";s:7:"crimson";s:7:"#DC143C";s:4:"cyan";s:7:"#00FFFF";s:8:"darkblue";s:7:"#00008B";s:8:"darkcyan";s:7:"#008B8B";s:13:"darkgoldenrod";s:7:"#B8860B";s:8:"darkgray";s:7:"#A9A9A9";s:8:"darkgrey";s:7:"#A9A9A9";s:9:"darkgreen";s:7:"#006400";s:9:"darkkhaki";s:7:"#BDB76B";s:11:"darkmagenta";s:7:"#8B008B";s:14:"darkolivegreen";s:7:"#556B2F";s:10:"darkorange";s:7:"#FF8C00";s:10:"darkorchid";s:7:"#9932CC";s:7:"darkred";s:7:"#8B0000";s:10:"darksalmon";s:7:"#E9967A";s:12:"darkseagreen";s:7:"#8FBC8F";s:13:"darkslateblue";s:7:"#483D8B";s:13:"darkslategray";s:7:"#2F4F4F";s:13:"darkslategrey";s:7:"#2F4F4F";s:13:"darkturquoise";s:7:"#00CED1";s:10:"darkviolet";s:7:"#9400D3";s:8:"deeppink";s:7:"#FF1493";s:11:"deepskyblue";s:7:"#00BFFF";s:7:"dimgray";s:7:"#696969";s:7:"dimgrey";s:7:"#696969";s:10:"dodgerblue";s:7:"#1E90FF";s:9:"firebrick";s:7:"#B22222";s:11:"floralwhite";s:7:"#FFFAF0";s:11:"forestgreen";s:7:"#228B22";s:7:"fuchsia";s:7:"#FF00FF";s:9:"gainsboro";s:7:"#DCDCDC";s:10:"ghostwhite";s:7:"#F8F8FF";s:4:"gold";s:7:"#FFD700";s:9:"goldenrod";s:7:"#DAA520";s:4:"gray";s:7:"#808080";s:4:"grey";s:7:"#808080";s:5:"green";s:7:"#008000";s:11:"greenyellow";s:7:"#ADFF2F";s:8:"honeydew";s:7:"#F0FFF0";s:7:"hotpink";s:7:"#FF69B4";s:9:"indianred";s:7:"#CD5C5C";s:6:"indigo";s:7:"#4B0082";s:5:"ivory";s:7:"#FFFFF0";s:5:"khaki";s:7:"#F0E68C";s:8:"lavender";s:7:"#E6E6FA";s:13:"lavenderblush";s:7:"#FFF0F5";s:9:"lawngreen";s:7:"#7CFC00";s:12:"lemonchiffon";s:7:"#FFFACD";s:9:"lightblue";s:7:"#ADD8E6";s:10:"lightcoral";s:7:"#F08080";s:9:"lightcyan";s:7:"#E0FFFF";s:20:"lightgoldenrodyellow";s:7:"#FAFAD2";s:9:"lightgray";s:7:"#D3D3D3";s:9:"lightgrey";s:7:"#D3D3D3";s:10:"lightgreen";s:7:"#90EE90";s:9:"lightpink";s:7:"#FFB6C1";s:11:"lightsalmon";s:7:"#FFA07A";s:13:"lightseagreen";s:7:"#20B2AA";s:12:"lightskyblue";s:7:"#87CEFA";s:14:"lightslategray";s:7:"#778899";s:14:"lightslategrey";s:7:"#778899";s:14:"lightsteelblue";s:7:"#B0C4DE";s:11:"lightyellow";s:7:"#FFFFE0";s:4:"lime";s:7:"#00FF00";s:9:"limegreen";s:7:"#32CD32";s:5:"linen";s:7:"#FAF0E6";s:7:"magenta";s:7:"#FF00FF";s:6:"maroon";s:7:"#800000";s:16:"mediumaquamarine";s:7:"#66CDAA";s:10:"mediumblue";s:7:"#0000CD";s:12:"mediumorchid";s:7:"#BA55D3";s:12:"mediumpurple";s:7:"#9370DB";s:14:"mediumseagreen";s:7:"#3CB371";s:15:"mediumslateblue";s:7:"#7B68EE";s:17:"mediumspringgreen";s:7:"#00FA9A";s:15:"mediumturquoise";s:7:"#48D1CC";s:15:"mediumvioletred";s:7:"#C71585";s:12:"midnightblue";s:7:"#191970";s:9:"mintcream";s:7:"#F5FFFA";s:9:"mistyrose";s:7:"#FFE4E1";s:8:"moccasin";s:7:"#FFE4B5";s:11:"navajowhite";s:7:"#FFDEAD";s:4:"navy";s:7:"#000080";s:7:"oldlace";s:7:"#FDF5E6";s:5:"olive";s:7:"#808000";s:9:"olivedrab";s:7:"#6B8E23";s:6:"orange";s:7:"#FFA500";s:9:"orangered";s:7:"#FF4500";s:6:"orchid";s:7:"#DA70D6";s:13:"palegoldenrod";s:7:"#EEE8AA";s:9:"palegreen";s:7:"#98FB98";s:13:"paleturquoise";s:7:"#AFEEEE";s:13:"palevioletred";s:7:"#DB7093";s:10:"papayawhip";s:7:"#FFEFD5";s:9:"peachpuff";s:7:"#FFDAB9";s:4:"peru";s:7:"#CD853F";s:4:"pink";s:7:"#FFC0CB";s:4:"plum";s:7:"#DDA0DD";s:10:"powderblue";s:7:"#B0E0E6";s:6:"purple";s:7:"#800080";s:13:"rebeccapurple";s:7:"#663399";s:3:"red";s:7:"#FF0000";s:9:"rosybrown";s:7:"#BC8F8F";s:9:"royalblue";s:7:"#4169E1";s:11:"saddlebrown";s:7:"#8B4513";s:6:"salmon";s:7:"#FA8072";s:10:"sandybrown";s:7:"#F4A460";s:8:"seagreen";s:7:"#2E8B57";s:8:"seashell";s:7:"#FFF5EE";s:6:"sienna";s:7:"#A0522D";s:6:"silver";s:7:"#C0C0C0";s:7:"skyblue";s:7:"#87CEEB";s:9:"slateblue";s:7:"#6A5ACD";s:9:"slategray";s:7:"#708090";s:9:"slategrey";s:7:"#708090";s:4:"snow";s:7:"#FFFAFA";s:11:"springgreen";s:7:"#00FF7F";s:9:"steelblue";s:7:"#4682B4";s:3:"tan";s:7:"#D2B48C";s:4:"teal";s:7:"#008080";s:7:"thistle";s:7:"#D8BFD8";s:6:"tomato";s:7:"#FF6347";s:9:"turquoise";s:7:"#40E0D0";s:6:"violet";s:7:"#EE82EE";s:5:"wheat";s:7:"#F5DEB3";s:5:"white";s:7:"#FFFFFF";s:10:"whitesmoke";s:7:"#F5F5F5";s:6:"yellow";s:7:"#FFFF00";s:11:"yellowgreen";s:7:"#9ACD32";}s:30:"Core.ConvertDocumentToFragment";b:1;s:36:"Core.DirectLexLineNumberSyncInterval";i:0;s:20:"Core.DisableExcludes";b:0;s:15:"Core.EnableIDNA";b:0;s:13:"Core.Encoding";s:5:"utf-8";s:26:"Core.EscapeInvalidChildren";b:0;s:22:"Core.EscapeInvalidTags";b:0;s:29:"Core.EscapeNonASCIICharacters";b:0;s:19:"Core.HiddenElements";a:2:{s:6:"script";b:1;s:5:"style";b:1;}s:13:"Core.Language";s:2:"en";s:24:"Core.LegacyEntityDecoder";b:0;s:14:"Core.LexerImpl";N;s:24:"Core.MaintainLineNumbers";N;s:22:"Core.NormalizeNewlines";b:1;s:17:"Core.RemoveBlanks";b:0;s:21:"Core.RemoveInvalidImg";b:1;s:33:"Core.RemoveProcessingInstructions";b:0;s:25:"Core.RemoveScriptContents";N;s:13:"Filter.Custom";a:0:{}s:34:"Filter.ExtractStyleBlocks.Escaping";b:1;s:31:"Filter.ExtractStyleBlocks.Scope";N;s:34:"Filter.ExtractStyleBlocks.TidyImpl";N;s:25:"Filter.ExtractStyleBlocks";b:0;s:14:"Filter.YouTube";b:0;s:12:"HTML.Allowed";N;s:22:"HTML.AllowedAttributes";N;s:20:"HTML.AllowedComments";a:0:{}s:26:"HTML.AllowedCommentsRegexp";N;s:20:"HTML.AllowedElements";N;s:19:"HTML.AllowedModules";N;s:23:"HTML.Attr.Name.UseCDATA";b:0;s:17:"HTML.BlockWrapper";s:1:"p";s:16:"HTML.CoreModules";a:7:{s:9:"Structure";b:1;s:4:"Text";b:1;s:9:"Hypertext";b:1;s:4:"List";b:1;s:22:"NonXMLCommonAttributes";b:1;s:19:"XMLCommonAttributes";b:1;s:16:"CommonAttributes";b:1;}s:18:"HTML.CustomDoctype";N;s:17:"HTML.DefinitionID";N;s:18:"HTML.DefinitionRev";i:1;s:12:"HTML.Doctype";N;s:25:"HTML.FlashAllowFullScreen";b:0;s:24:"HTML.ForbiddenAttributes";a:0:{}s:22:"HTML.ForbiddenElements";a:0:{}s:10:"HTML.Forms";b:0;s:17:"HTML.MaxImgLength";i:1200;s:13:"HTML.Nofollow";b:0;s:11:"HTML.Parent";s:3:"div";s:16:"HTML.Proprietary";b:0;s:14:"HTML.SafeEmbed";b:0;s:15:"HTML.SafeIframe";b:0;s:15:"HTML.SafeObject";b:0;s:18:"HTML.SafeScripting";a:0:{}s:11:"HTML.Strict";b:0;s:16:"HTML.TargetBlank";b:0;s:19:"HTML.TargetNoopener";b:1;s:21:"HTML.TargetNoreferrer";b:1;s:12:"HTML.TidyAdd";a:0:{}s:14:"HTML.TidyLevel";s:6:"medium";s:15:"HTML.TidyRemove";a:0:{}s:12:"HTML.Trusted";b:0;s:10:"HTML.XHTML";b:1;s:28:"Output.CommentScriptContents";b:1;s:19:"Output.FixInnerHTML";b:1;s:18:"Output.FlashCompat";b:0;s:14:"Output.Newline";N;s:15:"Output.SortAttr";b:0;s:17:"Output.TidyFormat";b:0;s:17:"Test.ForceNoIconv";b:0;s:18:"URI.AllowedSchemes";a:7:{s:4:"http";b:1;s:5:"https";b:1;s:6:"mailto";b:1;s:3:"ftp";b:1;s:4:"nntp";b:1;s:4:"news";b:1;s:3:"tel";b:1;}s:8:"URI.Base";N;s:17:"URI.DefaultScheme";s:4:"http";s:16:"URI.DefinitionID";N;s:17:"URI.DefinitionRev";i:1;s:11:"URI.Disable";b:0;s:19:"URI.DisableExternal";b:0;s:28:"URI.DisableExternalResources";b:0;s:20:"URI.DisableResources";b:0;s:8:"URI.Host";N;s:17:"URI.HostBlacklist";a:0:{}s:16:"URI.MakeAbsolute";b:0;s:9:"URI.Munge";N;s:18:"URI.MungeResources";b:0;s:18:"URI.MungeSecretKey";N;s:26:"URI.OverrideAllowedSchemes";b:1;s:20:"URI.SafeIframeRegexp";N;}s:9:"*parent";N;s:8:"*cache";N;}s:4:"info";a:141:{s:19:"Attr.AllowedClasses";i:-8;s:24:"Attr.AllowedFrameTargets";i:8;s:15:"Attr.AllowedRel";i:8;s:15:"Attr.AllowedRev";i:8;s:18:"Attr.ClassUseCDATA";i:-7;s:20:"Attr.DefaultImageAlt";i:-1;s:24:"Attr.DefaultInvalidImage";i:1;s:27:"Attr.DefaultInvalidImageAlt";i:1;s:19:"Attr.DefaultTextDir";O:8:"stdClass":2:{s:4:"type";i:1;s:7:"allowed";a:2:{s:3:"ltr";b:1;s:3:"rtl";b:1;}}s:13:"Attr.EnableID";i:7;s:17:"HTML.EnableAttrID";O:8:"stdClass":2:{s:3:"key";s:13:"Attr.EnableID";s:7:"isAlias";b:1;}s:21:"Attr.ForbiddenClasses";i:8;s:13:"Attr.ID.HTML5";i:-7;s:16:"Attr.IDBlacklist";i:9;s:22:"Attr.IDBlacklistRegexp";i:-1;s:13:"Attr.IDPrefix";i:1;s:18:"Attr.IDPrefixLocal";i:1;s:24:"AutoFormat.AutoParagraph";i:7;s:17:"AutoFormat.Custom";i:9;s:25:"AutoFormat.DisplayLinkURI";i:7;s:18:"AutoFormat.Linkify";i:7;s:33:"AutoFormat.PurifierLinkify.DocURL";i:1;s:37:"AutoFormatParam.PurifierLinkifyDocURL";O:8:"stdClass":2:{s:3:"key";s:33:"AutoFormat.PurifierLinkify.DocURL";s:7:"isAlias";b:1;}s:26:"AutoFormat.PurifierLinkify";i:7;s:32:"AutoFormat.RemoveEmpty.Predicate";i:10;s:44:"AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions";i:8;s:33:"AutoFormat.RemoveEmpty.RemoveNbsp";i:7;s:22:"AutoFormat.RemoveEmpty";i:7;s:39:"AutoFormat.RemoveSpansWithoutAttributes";i:7;s:19:"CSS.AllowDuplicates";i:7;s:18:"CSS.AllowImportant";i:7;s:15:"CSS.AllowTricky";i:7;s:16:"CSS.AllowedFonts";i:-8;s:21:"CSS.AllowedProperties";i:-8;s:17:"CSS.DefinitionRev";i:5;s:23:"CSS.ForbiddenProperties";i:8;s:16:"CSS.MaxImgLength";i:-1;s:15:"CSS.Proprietary";i:7;s:11:"CSS.Trusted";i:7;s:20:"Cache.DefinitionImpl";i:-1;s:20:"Core.DefinitionCache";O:8:"stdClass":2:{s:3:"key";s:20:"Cache.DefinitionImpl";s:7:"isAlias";b:1;}s:20:"Cache.SerializerPath";i:-1;s:27:"Cache.SerializerPermissions";i:-5;s:22:"Core.AggressivelyFixLt";i:7;s:29:"Core.AggressivelyRemoveScript";i:7;s:28:"Core.AllowHostnameUnderscore";i:7;s:23:"Core.AllowParseManyTags";i:7;s:18:"Core.CollectErrors";i:7;s:18:"Core.ColorKeywords";i:10;s:30:"Core.ConvertDocumentToFragment";i:7;s:24:"Core.AcceptFullDocuments";O:8:"stdClass":2:{s:3:"key";s:30:"Core.ConvertDocumentToFragment";s:7:"isAlias";b:1;}s:36:"Core.DirectLexLineNumberSyncInterval";i:5;s:20:"Core.DisableExcludes";i:7;s:15:"Core.EnableIDNA";i:7;s:13:"Core.Encoding";i:2;s:26:"Core.EscapeInvalidChildren";i:7;s:22:"Core.EscapeInvalidTags";i:7;s:29:"Core.EscapeNonASCIICharacters";i:7;s:19:"Core.HiddenElements";i:8;s:13:"Core.Language";i:1;s:24:"Core.LegacyEntityDecoder";i:7;s:14:"Core.LexerImpl";i:-11;s:24:"Core.MaintainLineNumbers";i:-7;s:22:"Core.NormalizeNewlines";i:7;s:17:"Core.RemoveBlanks";i:7;s:21:"Core.RemoveInvalidImg";i:7;s:33:"Core.RemoveProcessingInstructions";i:7;s:25:"Core.RemoveScriptContents";i:-7;s:13:"Filter.Custom";i:9;s:34:"Filter.ExtractStyleBlocks.Escaping";i:7;s:33:"Filter.ExtractStyleBlocksEscaping";O:8:"stdClass":2:{s:3:"key";s:34:"Filter.ExtractStyleBlocks.Escaping";s:7:"isAlias";b:1;}s:38:"FilterParam.ExtractStyleBlocksEscaping";O:8:"stdClass":2:{s:3:"key";s:34:"Filter.ExtractStyleBlocks.Escaping";s:7:"isAlias";b:1;}s:31:"Filter.ExtractStyleBlocks.Scope";i:-1;s:30:"Filter.ExtractStyleBlocksScope";O:8:"stdClass":2:{s:3:"key";s:31:"Filter.ExtractStyleBlocks.Scope";s:7:"isAlias";b:1;}s:35:"FilterParam.ExtractStyleBlocksScope";O:8:"stdClass":2:{s:3:"key";s:31:"Filter.ExtractStyleBlocks.Scope";s:7:"isAlias";b:1;}s:34:"Filter.ExtractStyleBlocks.TidyImpl";i:-11;s:38:"FilterParam.ExtractStyleBlocksTidyImpl";O:8:"stdClass":2:{s:3:"key";s:34:"Filter.ExtractStyleBlocks.TidyImpl";s:7:"isAlias";b:1;}s:25:"Filter.ExtractStyleBlocks";i:7;s:14:"Filter.YouTube";i:7;s:12:"HTML.Allowed";i:-4;s:22:"HTML.AllowedAttributes";i:-8;s:20:"HTML.AllowedComments";i:8;s:26:"HTML.AllowedCommentsRegexp";i:-1;s:20:"HTML.AllowedElements";i:-8;s:19:"HTML.AllowedModules";i:-8;s:23:"HTML.Attr.Name.UseCDATA";i:7;s:17:"HTML.BlockWrapper";i:1;s:16:"HTML.CoreModules";i:8;s:18:"HTML.CustomDoctype";i:-1;s:17:"HTML.DefinitionID";i:-1;s:18:"HTML.DefinitionRev";i:5;s:12:"HTML.Doctype";O:8:"stdClass":3:{s:4:"type";i:1;s:10:"allow_null";b:1;s:7:"allowed";a:5:{s:22:"HTML 4.01 Transitional";b:1;s:16:"HTML 4.01 Strict";b:1;s:22:"XHTML 1.0 Transitional";b:1;s:16:"XHTML 1.0 Strict";b:1;s:9:"XHTML 1.1";b:1;}}s:25:"HTML.FlashAllowFullScreen";i:7;s:24:"HTML.ForbiddenAttributes";i:8;s:22:"HTML.ForbiddenElements";i:8;s:10:"HTML.Forms";i:7;s:17:"HTML.MaxImgLength";i:-5;s:13:"HTML.Nofollow";i:7;s:11:"HTML.Parent";i:1;s:16:"HTML.Proprietary";i:7;s:14:"HTML.SafeEmbed";i:7;s:15:"HTML.SafeIframe";i:7;s:15:"HTML.SafeObject";i:7;s:18:"HTML.SafeScripting";i:8;s:11:"HTML.Strict";i:7;s:16:"HTML.TargetBlank";i:7;s:19:"HTML.TargetNoopener";i:7;s:21:"HTML.TargetNoreferrer";i:7;s:12:"HTML.TidyAdd";i:8;s:14:"HTML.TidyLevel";O:8:"stdClass":2:{s:4:"type";i:1;s:7:"allowed";a:4:{s:4:"none";b:1;s:5:"light";b:1;s:6:"medium";b:1;s:5:"heavy";b:1;}}s:15:"HTML.TidyRemove";i:8;s:12:"HTML.Trusted";i:7;s:10:"HTML.XHTML";i:7;s:10:"Core.XHTML";O:8:"stdClass":2:{s:3:"key";s:10:"HTML.XHTML";s:7:"isAlias";b:1;}s:28:"Output.CommentScriptContents";i:7;s:26:"Core.CommentScriptContents";O:8:"stdClass":2:{s:3:"key";s:28:"Output.CommentScriptContents";s:7:"isAlias";b:1;}s:19:"Output.FixInnerHTML";i:7;s:18:"Output.FlashCompat";i:7;s:14:"Output.Newline";i:-1;s:15:"Output.SortAttr";i:7;s:17:"Output.TidyFormat";i:7;s:15:"Core.TidyFormat";O:8:"stdClass":2:{s:3:"key";s:17:"Output.TidyFormat";s:7:"isAlias";b:1;}s:17:"Test.ForceNoIconv";i:7;s:18:"URI.AllowedSchemes";i:8;s:8:"URI.Base";i:-1;s:17:"URI.DefaultScheme";i:-1;s:16:"URI.DefinitionID";i:-1;s:17:"URI.DefinitionRev";i:5;s:11:"URI.Disable";i:7;s:15:"Attr.DisableURI";O:8:"stdClass":2:{s:3:"key";s:11:"URI.Disable";s:7:"isAlias";b:1;}s:19:"URI.DisableExternal";i:7;s:28:"URI.DisableExternalResources";i:7;s:20:"URI.DisableResources";i:7;s:8:"URI.Host";i:-1;s:17:"URI.HostBlacklist";i:9;s:16:"URI.MakeAbsolute";i:7;s:9:"URI.Munge";i:-1;s:18:"URI.MungeResources";i:7;s:18:"URI.MungeSecretKey";i:-1;s:26:"URI.OverrideAllowedSchemes";i:7;s:20:"URI.SafeIframeRegexp";i:-1;}} \ No newline at end of file diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedClasses.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedClasses.txt new file mode 100644 index 0000000..0517fed --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedClasses.txt @@ -0,0 +1,8 @@ +Attr.AllowedClasses +TYPE: lookup/null +VERSION: 4.0.0 +DEFAULT: null +--DESCRIPTION-- +List of allowed class values in the class attribute. By default, this is null, +which means all classes are allowed. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedFrameTargets.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedFrameTargets.txt new file mode 100644 index 0000000..249edd6 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedFrameTargets.txt @@ -0,0 +1,12 @@ +Attr.AllowedFrameTargets +TYPE: lookup +DEFAULT: array() +--DESCRIPTION-- +Lookup table of all allowed link frame targets. Some commonly used link +targets include _blank, _self, _parent and _top. Values should be +lowercase, as validation will be done in a case-sensitive manner despite +W3C's recommendation. XHTML 1.0 Strict does not permit the target attribute +so this directive will have no effect in that doctype. XHTML 1.1 does not +enable the Target module by default, you will have to manually enable it +(see the module documentation for more details.) +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRel.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRel.txt new file mode 100644 index 0000000..9a8fa6a --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRel.txt @@ -0,0 +1,9 @@ +Attr.AllowedRel +TYPE: lookup +VERSION: 1.6.0 +DEFAULT: array() +--DESCRIPTION-- +List of allowed forward document relationships in the rel attribute. Common +values may be nofollow or print. By default, this is empty, meaning that no +document relationships are allowed. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRev.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRev.txt new file mode 100644 index 0000000..b017883 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.AllowedRev.txt @@ -0,0 +1,9 @@ +Attr.AllowedRev +TYPE: lookup +VERSION: 1.6.0 +DEFAULT: array() +--DESCRIPTION-- +List of allowed reverse document relationships in the rev attribute. This +attribute is a bit of an edge-case; if you don't know what it is for, stay +away. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ClassUseCDATA.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ClassUseCDATA.txt new file mode 100644 index 0000000..e774b82 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ClassUseCDATA.txt @@ -0,0 +1,19 @@ +Attr.ClassUseCDATA +TYPE: bool/null +DEFAULT: null +VERSION: 4.0.0 +--DESCRIPTION-- +If null, class will auto-detect the doctype and, if matching XHTML 1.1 or +XHTML 2.0, will use the restrictive NMTOKENS specification of class. Otherwise, +it will use a relaxed CDATA definition. If true, the relaxed CDATA definition +is forced; if false, the NMTOKENS definition is forced. To get behavior +of HTML Purifier prior to 4.0.0, set this directive to false. + +Some rational behind the auto-detection: +in previous versions of HTML Purifier, it was assumed that the form of +class was NMTOKENS, as specified by the XHTML Modularization (representing +XHTML 1.1 and XHTML 2.0). The DTDs for HTML 4.01 and XHTML 1.0, however +specify class as CDATA. HTML 5 effectively defines it as CDATA, but +with the additional constraint that each name should be unique (this is not +explicitly outlined in previous specifications). +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultImageAlt.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultImageAlt.txt new file mode 100644 index 0000000..533165e --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultImageAlt.txt @@ -0,0 +1,11 @@ +Attr.DefaultImageAlt +TYPE: string/null +DEFAULT: null +VERSION: 3.2.0 +--DESCRIPTION-- +This is the content of the alt tag of an image if the user had not +previously specified an alt attribute. This applies to all images without +a valid alt attribute, as opposed to %Attr.DefaultInvalidImageAlt, which +only applies to invalid images, and overrides in the case of an invalid image. +Default behavior with null is to use the basename of the src tag for the alt. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImage.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImage.txt new file mode 100644 index 0000000..9eb7e38 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImage.txt @@ -0,0 +1,9 @@ +Attr.DefaultInvalidImage +TYPE: string +DEFAULT: '' +--DESCRIPTION-- +This is the default image an img tag will be pointed to if it does not have +a valid src attribute. In future versions, we may allow the image tag to +be removed completely, but due to design issues, this is not possible right +now. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImageAlt.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImageAlt.txt new file mode 100644 index 0000000..2f17bf4 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultInvalidImageAlt.txt @@ -0,0 +1,8 @@ +Attr.DefaultInvalidImageAlt +TYPE: string +DEFAULT: 'Invalid image' +--DESCRIPTION-- +This is the content of the alt tag of an invalid image if the user had not +previously specified an alt attribute. It has no effect when the image is +valid but there was no alt attribute present. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultTextDir.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultTextDir.txt new file mode 100644 index 0000000..52654b5 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.DefaultTextDir.txt @@ -0,0 +1,10 @@ +Attr.DefaultTextDir +TYPE: string +DEFAULT: 'ltr' +--DESCRIPTION-- +Defines the default text direction (ltr or rtl) of the document being +parsed. This generally is the same as the value of the dir attribute in +HTML, or ltr if that is not specified. +--ALLOWED-- +'ltr', 'rtl' +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.EnableID.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.EnableID.txt new file mode 100644 index 0000000..6440d21 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.EnableID.txt @@ -0,0 +1,16 @@ +Attr.EnableID +TYPE: bool +DEFAULT: false +VERSION: 1.2.0 +--DESCRIPTION-- +Allows the ID attribute in HTML. This is disabled by default due to the +fact that without proper configuration user input can easily break the +validation of a webpage by specifying an ID that is already on the +surrounding HTML. If you don't mind throwing caution to the wind, enable +this directive, but I strongly recommend you also consider blacklisting IDs +you use (%Attr.IDBlacklist) or prefixing all user supplied IDs +(%Attr.IDPrefix). When set to true HTML Purifier reverts to the behavior of +pre-1.2.0 versions. +--ALIASES-- +HTML.EnableAttrID +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ForbiddenClasses.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ForbiddenClasses.txt new file mode 100644 index 0000000..f31d226 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ForbiddenClasses.txt @@ -0,0 +1,8 @@ +Attr.ForbiddenClasses +TYPE: lookup +VERSION: 4.0.0 +DEFAULT: array() +--DESCRIPTION-- +List of forbidden class values in the class attribute. By default, this is +empty, which means that no classes are forbidden. See also %Attr.AllowedClasses. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ID.HTML5.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ID.HTML5.txt new file mode 100644 index 0000000..735d4b7 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.ID.HTML5.txt @@ -0,0 +1,10 @@ +Attr.ID.HTML5 +TYPE: bool/null +DEFAULT: null +VERSION: 4.8.0 +--DESCRIPTION-- +In HTML5, restrictions on the format of the id attribute have been significantly +relaxed, such that any string is valid so long as it contains no spaces and +is at least one character. In lieu of a general HTML5 compatibility flag, +set this configuration directive to true to use the relaxed rules. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklist.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklist.txt new file mode 100644 index 0000000..5f2b5e3 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklist.txt @@ -0,0 +1,5 @@ +Attr.IDBlacklist +TYPE: list +DEFAULT: array() +DESCRIPTION: Array of IDs not allowed in the document. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklistRegexp.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklistRegexp.txt new file mode 100644 index 0000000..6f58245 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDBlacklistRegexp.txt @@ -0,0 +1,9 @@ +Attr.IDBlacklistRegexp +TYPE: string/null +VERSION: 1.6.0 +DEFAULT: NULL +--DESCRIPTION-- +PCRE regular expression to be matched against all IDs. If the expression is +matches, the ID is rejected. Use this with care: may cause significant +degradation. ID matching is done after all other validation. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefix.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefix.txt new file mode 100644 index 0000000..cc49d43 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefix.txt @@ -0,0 +1,12 @@ +Attr.IDPrefix +TYPE: string +VERSION: 1.2.0 +DEFAULT: '' +--DESCRIPTION-- +String to prefix to IDs. If you have no idea what IDs your pages may use, +you may opt to simply add a prefix to all user-submitted ID attributes so +that they are still usable, but will not conflict with core page IDs. +Example: setting the directive to 'user_' will result in a user submitted +'foo' to become 'user_foo' Be sure to set %HTML.EnableAttrID to true +before using this. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefixLocal.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefixLocal.txt new file mode 100644 index 0000000..2c5924a --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Attr.IDPrefixLocal.txt @@ -0,0 +1,14 @@ +Attr.IDPrefixLocal +TYPE: string +VERSION: 1.2.0 +DEFAULT: '' +--DESCRIPTION-- +Temporary prefix for IDs used in conjunction with %Attr.IDPrefix. If you +need to allow multiple sets of user content on web page, you may need to +have a seperate prefix that changes with each iteration. This way, +seperately submitted user content displayed on the same page doesn't +clobber each other. Ideal values are unique identifiers for the content it +represents (i.e. the id of the row in the database). Be sure to add a +seperator (like an underscore) at the end. Warning: this directive will +not work unless %Attr.IDPrefix is set to a non-empty value! +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.AutoParagraph.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.AutoParagraph.txt new file mode 100644 index 0000000..d5caa1b --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.AutoParagraph.txt @@ -0,0 +1,31 @@ +AutoFormat.AutoParagraph +TYPE: bool +VERSION: 2.0.1 +DEFAULT: false +--DESCRIPTION-- + +

+ This directive turns on auto-paragraphing, where double newlines are + converted in to paragraphs whenever possible. Auto-paragraphing: +

+
    +
  • Always applies to inline elements or text in the root node,
  • +
  • Applies to inline elements or text with double newlines in nodes + that allow paragraph tags,
  • +
  • Applies to double newlines in paragraph tags
  • +
+

+ p tags must be allowed for this directive to take effect. + We do not use br tags for paragraphing, as that is + semantically incorrect. +

+

+ To prevent auto-paragraphing as a content-producer, refrain from using + double-newlines except to specify a new paragraph or in contexts where + it has special meaning (whitespace usually has no meaning except in + tags like pre, so this should not be difficult.) To prevent + the paragraphing of inline text adjacent to block elements, wrap them + in div tags (the behavior is slightly different outside of + the root node.) +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Custom.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Custom.txt new file mode 100644 index 0000000..2a47648 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Custom.txt @@ -0,0 +1,12 @@ +AutoFormat.Custom +TYPE: list +VERSION: 2.0.1 +DEFAULT: array() +--DESCRIPTION-- + +

+ This directive can be used to add custom auto-format injectors. + Specify an array of injector names (class name minus the prefix) + or concrete implementations. Injector class must exist. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.DisplayLinkURI.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.DisplayLinkURI.txt new file mode 100644 index 0000000..663064a --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.DisplayLinkURI.txt @@ -0,0 +1,11 @@ +AutoFormat.DisplayLinkURI +TYPE: bool +VERSION: 3.2.0 +DEFAULT: false +--DESCRIPTION-- +

+ This directive turns on the in-text display of URIs in <a> tags, and disables + those links. For example, example becomes + example (http://example.com). +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt new file mode 100644 index 0000000..3a48ba9 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.Linkify.txt @@ -0,0 +1,12 @@ +AutoFormat.Linkify +TYPE: bool +VERSION: 2.0.1 +DEFAULT: false +--DESCRIPTION-- + +

+ This directive turns on linkification, auto-linking http, ftp and + https URLs. a tags with the href attribute + must be allowed. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.DocURL.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.DocURL.txt new file mode 100644 index 0000000..db58b13 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.DocURL.txt @@ -0,0 +1,12 @@ +AutoFormat.PurifierLinkify.DocURL +TYPE: string +VERSION: 2.0.1 +DEFAULT: '#%s' +ALIASES: AutoFormatParam.PurifierLinkifyDocURL +--DESCRIPTION-- +

+ Location of configuration documentation to link to, let %s substitute + into the configuration's namespace and directive names sans the percent + sign. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.txt new file mode 100644 index 0000000..7996488 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.PurifierLinkify.txt @@ -0,0 +1,12 @@ +AutoFormat.PurifierLinkify +TYPE: bool +VERSION: 2.0.1 +DEFAULT: false +--DESCRIPTION-- + +

+ Internal auto-formatter that converts configuration directives in + syntax %Namespace.Directive to links. a tags + with the href attribute must be allowed. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.Predicate.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.Predicate.txt new file mode 100644 index 0000000..6367fe2 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.Predicate.txt @@ -0,0 +1,14 @@ +AutoFormat.RemoveEmpty.Predicate +TYPE: hash +VERSION: 4.7.0 +DEFAULT: array('colgroup' => array(), 'th' => array(), 'td' => array(), 'iframe' => array('src')) +--DESCRIPTION-- +

+ Given that an element has no contents, it will be removed by default, unless + this predicate dictates otherwise. The predicate can either be an associative + map from tag name to list of attributes that must be present for the element + to be considered preserved: thus, the default always preserves colgroup, + th and td, and also iframe if it + has a src. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions.txt new file mode 100644 index 0000000..35c393b --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions.txt @@ -0,0 +1,11 @@ +AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions +TYPE: lookup +VERSION: 4.0.0 +DEFAULT: array('td' => true, 'th' => true) +--DESCRIPTION-- +

+ When %AutoFormat.RemoveEmpty and %AutoFormat.RemoveEmpty.RemoveNbsp + are enabled, this directive defines what HTML elements should not be + removede if they have only a non-breaking space in them. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.txt new file mode 100644 index 0000000..9228dee --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.RemoveNbsp.txt @@ -0,0 +1,15 @@ +AutoFormat.RemoveEmpty.RemoveNbsp +TYPE: bool +VERSION: 4.0.0 +DEFAULT: false +--DESCRIPTION-- +

+ When enabled, HTML Purifier will treat any elements that contain only + non-breaking spaces as well as regular whitespace as empty, and remove + them when %AutoFormat.RemoveEmpty is enabled. +

+

+ See %AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions for a list of elements + that don't have this behavior applied to them. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.txt new file mode 100644 index 0000000..34657ba --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveEmpty.txt @@ -0,0 +1,46 @@ +AutoFormat.RemoveEmpty +TYPE: bool +VERSION: 3.2.0 +DEFAULT: false +--DESCRIPTION-- +

+ When enabled, HTML Purifier will attempt to remove empty elements that + contribute no semantic information to the document. The following types + of nodes will be removed: +

+
  • + Tags with no attributes and no content, and that are not empty + elements (remove <a></a> but not + <br />), and +
  • +
  • + Tags with no content, except for:
      +
    • The colgroup element, or
    • +
    • + Elements with the id or name attribute, + when those attributes are permitted on those elements. +
    • +
  • +
+

+ Please be very careful when using this functionality; while it may not + seem that empty elements contain useful information, they can alter the + layout of a document given appropriate styling. This directive is most + useful when you are processing machine-generated HTML, please avoid using + it on regular user HTML. +

+

+ Elements that contain only whitespace will be treated as empty. Non-breaking + spaces, however, do not count as whitespace. See + %AutoFormat.RemoveEmpty.RemoveNbsp for alternate behavior. +

+

+ This algorithm is not perfect; you may still notice some empty tags, + particularly if a node had elements, but those elements were later removed + because they were not permitted in that context, or tags that, after + being auto-closed by another tag, where empty. This is for safety reasons + to prevent clever code from breaking validation. The general rule of thumb: + if a tag looked empty on the way in, it will get removed; if HTML Purifier + made it empty, it will stay. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveSpansWithoutAttributes.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveSpansWithoutAttributes.txt new file mode 100644 index 0000000..dde990a --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/AutoFormat.RemoveSpansWithoutAttributes.txt @@ -0,0 +1,11 @@ +AutoFormat.RemoveSpansWithoutAttributes +TYPE: bool +VERSION: 4.0.1 +DEFAULT: false +--DESCRIPTION-- +

+ This directive causes span tags without any attributes + to be removed. It will also remove spans that had all attributes + removed during processing. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowDuplicates.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowDuplicates.txt new file mode 100644 index 0000000..4d054b1 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowDuplicates.txt @@ -0,0 +1,11 @@ +CSS.AllowDuplicates +TYPE: bool +DEFAULT: false +VERSION: 4.8.0 +--DESCRIPTION-- +

+ By default, HTML Purifier removes duplicate CSS properties, + like color:red; color:blue. If this is set to + true, duplicate properties are allowed. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowImportant.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowImportant.txt new file mode 100644 index 0000000..b324608 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowImportant.txt @@ -0,0 +1,8 @@ +CSS.AllowImportant +TYPE: bool +DEFAULT: false +VERSION: 3.1.0 +--DESCRIPTION-- +This parameter determines whether or not !important cascade modifiers should +be allowed in user CSS. If false, !important will stripped. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowTricky.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowTricky.txt new file mode 100644 index 0000000..748be0e --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowTricky.txt @@ -0,0 +1,11 @@ +CSS.AllowTricky +TYPE: bool +DEFAULT: false +VERSION: 3.1.0 +--DESCRIPTION-- +This parameter determines whether or not to allow "tricky" CSS properties and +values. Tricky CSS properties/values can drastically modify page layout or +be used for deceptive practices but do not directly constitute a security risk. +For example, display:none; is considered a tricky property that +will only be allowed if this directive is set to true. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedFonts.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedFonts.txt new file mode 100644 index 0000000..3fd4654 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedFonts.txt @@ -0,0 +1,12 @@ +CSS.AllowedFonts +TYPE: lookup/null +VERSION: 4.3.0 +DEFAULT: NULL +--DESCRIPTION-- +

+ Allows you to manually specify a set of allowed fonts. If + NULL, all fonts are allowed. This directive + affects generic names (serif, sans-serif, monospace, cursive, + fantasy) as well as specific font families. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedProperties.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedProperties.txt new file mode 100644 index 0000000..460112e --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.AllowedProperties.txt @@ -0,0 +1,18 @@ +CSS.AllowedProperties +TYPE: lookup/null +VERSION: 3.1.0 +DEFAULT: NULL +--DESCRIPTION-- + +

+ If HTML Purifier's style attributes set is unsatisfactory for your needs, + you can overload it with your own list of tags to allow. Note that this + method is subtractive: it does its job by taking away from HTML Purifier + usual feature set, so you cannot add an attribute that HTML Purifier never + supported in the first place. +

+

+ Warning: If another directive conflicts with the + elements here, that directive will win and override. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt new file mode 100644 index 0000000..5cb7dda --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.DefinitionRev.txt @@ -0,0 +1,11 @@ +CSS.DefinitionRev +TYPE: int +VERSION: 2.0.0 +DEFAULT: 1 +--DESCRIPTION-- + +

+ Revision identifier for your custom definition. See + %HTML.DefinitionRev for details. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.ForbiddenProperties.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.ForbiddenProperties.txt new file mode 100644 index 0000000..f1f5c5f --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.ForbiddenProperties.txt @@ -0,0 +1,13 @@ +CSS.ForbiddenProperties +TYPE: lookup +VERSION: 4.2.0 +DEFAULT: array() +--DESCRIPTION-- +

+ This is the logical inverse of %CSS.AllowedProperties, and it will + override that directive or any other directive. If possible, + %CSS.AllowedProperties is recommended over this directive, + because it can sometimes be difficult to tell whether or not you've + forbidden all of the CSS properties you truly would like to disallow. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.MaxImgLength.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.MaxImgLength.txt new file mode 100644 index 0000000..7a32914 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.MaxImgLength.txt @@ -0,0 +1,16 @@ +CSS.MaxImgLength +TYPE: string/null +DEFAULT: '1200px' +VERSION: 3.1.1 +--DESCRIPTION-- +

+ This parameter sets the maximum allowed length on img tags, + effectively the width and height properties. + Only absolute units of measurement (in, pt, pc, mm, cm) and pixels (px) are allowed. This is + in place to prevent imagecrash attacks, disable with null at your own risk. + This directive is similar to %HTML.MaxImgLength, and both should be + concurrently edited, although there are + subtle differences in the input format (the CSS max is a number with + a unit). +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.Proprietary.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.Proprietary.txt new file mode 100644 index 0000000..148eedb --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.Proprietary.txt @@ -0,0 +1,10 @@ +CSS.Proprietary +TYPE: bool +VERSION: 3.0.0 +DEFAULT: false +--DESCRIPTION-- + +

+ Whether or not to allow safe, proprietary CSS values. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.Trusted.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.Trusted.txt new file mode 100644 index 0000000..e733a61 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/CSS.Trusted.txt @@ -0,0 +1,9 @@ +CSS.Trusted +TYPE: bool +VERSION: 4.2.1 +DEFAULT: false +--DESCRIPTION-- +Indicates whether or not the user's CSS input is trusted or not. If the +input is trusted, a more expansive set of allowed properties. See +also %HTML.Trusted. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt new file mode 100644 index 0000000..c486724 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.DefinitionImpl.txt @@ -0,0 +1,14 @@ +Cache.DefinitionImpl +TYPE: string/null +VERSION: 2.0.0 +DEFAULT: 'Serializer' +--DESCRIPTION-- + +This directive defines which method to use when caching definitions, +the complex data-type that makes HTML Purifier tick. Set to null +to disable caching (not recommended, as you will see a definite +performance degradation). + +--ALIASES-- +Core.DefinitionCache +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt new file mode 100644 index 0000000..5403650 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPath.txt @@ -0,0 +1,13 @@ +Cache.SerializerPath +TYPE: string/null +VERSION: 2.0.0 +DEFAULT: NULL +--DESCRIPTION-- + +

+ Absolute path with no trailing slash to store serialized definitions in. + Default is within the + HTML Purifier library inside DefinitionCache/Serializer. This + path must be writable by the webserver. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPermissions.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPermissions.txt new file mode 100644 index 0000000..2e0cc81 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Cache.SerializerPermissions.txt @@ -0,0 +1,16 @@ +Cache.SerializerPermissions +TYPE: int/null +VERSION: 4.3.0 +DEFAULT: 0755 +--DESCRIPTION-- + +

+ Directory permissions of the files and directories created inside + the DefinitionCache/Serializer or other custom serializer path. +

+

+ In HTML Purifier 4.8.0, this also supports NULL, + which means that no chmod'ing or directory creation shall + occur. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyFixLt.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyFixLt.txt new file mode 100644 index 0000000..568cbf3 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyFixLt.txt @@ -0,0 +1,18 @@ +Core.AggressivelyFixLt +TYPE: bool +VERSION: 2.1.0 +DEFAULT: true +--DESCRIPTION-- +

+ This directive enables aggressive pre-filter fixes HTML Purifier can + perform in order to ensure that open angled-brackets do not get killed + during parsing stage. Enabling this will result in two preg_replace_callback + calls and at least two preg_replace calls for every HTML document parsed; + if your users make very well-formed HTML, you can set this directive false. + This has no effect when DirectLex is used. +

+

+ Notice: This directive's default turned from false to true + in HTML Purifier 3.2.0. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyRemoveScript.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyRemoveScript.txt new file mode 100644 index 0000000..b2b6ab1 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AggressivelyRemoveScript.txt @@ -0,0 +1,16 @@ +Core.AggressivelyRemoveScript +TYPE: bool +VERSION: 4.9.0 +DEFAULT: true +--DESCRIPTION-- +

+ This directive enables aggressive pre-filter removal of + script tags. This is not necessary for security, + but it can help work around a bug in libxml where embedded + HTML elements inside script sections cause the parser to + choke. To revert to pre-4.9.0 behavior, set this to false. + This directive has no effect if %Core.Trusted is true, + %Core.RemoveScriptContents is false, or %Core.HiddenElements + does not contain script. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AllowHostnameUnderscore.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AllowHostnameUnderscore.txt new file mode 100644 index 0000000..2c910cc --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AllowHostnameUnderscore.txt @@ -0,0 +1,16 @@ +Core.AllowHostnameUnderscore +TYPE: bool +VERSION: 4.6.0 +DEFAULT: false +--DESCRIPTION-- +

+ By RFC 1123, underscores are not permitted in host names. + (This is in contrast to the specification for DNS, RFC + 2181, which allows underscores.) + However, most browsers do the right thing when faced with + an underscore in the host name, and so some poorly written + websites are written with the expectation this should work. + Setting this parameter to true relaxes our allowed character + check so that underscores are permitted. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AllowParseManyTags.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AllowParseManyTags.txt new file mode 100644 index 0000000..06278f8 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.AllowParseManyTags.txt @@ -0,0 +1,12 @@ +Core.AllowParseManyTags +TYPE: bool +DEFAULT: false +VERSION: 4.10.1 +--DESCRIPTION-- +

+ This directive allows parsing of many nested tags. + If you set true, relaxes any hardcoded limit from the parser. + However, in that case it may cause a Dos attack. + Be careful when enabling it. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt new file mode 100644 index 0000000..d731791 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.CollectErrors.txt @@ -0,0 +1,12 @@ +Core.CollectErrors +TYPE: bool +VERSION: 2.0.0 +DEFAULT: false +--DESCRIPTION-- + +Whether or not to collect errors found while filtering the document. This +is a useful way to give feedback to your users. Warning: +Currently this feature is very patchy and experimental, with lots of +possible error messages not yet implemented. It will not cause any +problems, but it may not help your users either. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.ColorKeywords.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.ColorKeywords.txt new file mode 100644 index 0000000..a75844c --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.ColorKeywords.txt @@ -0,0 +1,160 @@ +Core.ColorKeywords +TYPE: hash +VERSION: 2.0.0 +--DEFAULT-- +array ( + 'aliceblue' => '#F0F8FF', + 'antiquewhite' => '#FAEBD7', + 'aqua' => '#00FFFF', + 'aquamarine' => '#7FFFD4', + 'azure' => '#F0FFFF', + 'beige' => '#F5F5DC', + 'bisque' => '#FFE4C4', + 'black' => '#000000', + 'blanchedalmond' => '#FFEBCD', + 'blue' => '#0000FF', + 'blueviolet' => '#8A2BE2', + 'brown' => '#A52A2A', + 'burlywood' => '#DEB887', + 'cadetblue' => '#5F9EA0', + 'chartreuse' => '#7FFF00', + 'chocolate' => '#D2691E', + 'coral' => '#FF7F50', + 'cornflowerblue' => '#6495ED', + 'cornsilk' => '#FFF8DC', + 'crimson' => '#DC143C', + 'cyan' => '#00FFFF', + 'darkblue' => '#00008B', + 'darkcyan' => '#008B8B', + 'darkgoldenrod' => '#B8860B', + 'darkgray' => '#A9A9A9', + 'darkgrey' => '#A9A9A9', + 'darkgreen' => '#006400', + 'darkkhaki' => '#BDB76B', + 'darkmagenta' => '#8B008B', + 'darkolivegreen' => '#556B2F', + 'darkorange' => '#FF8C00', + 'darkorchid' => '#9932CC', + 'darkred' => '#8B0000', + 'darksalmon' => '#E9967A', + 'darkseagreen' => '#8FBC8F', + 'darkslateblue' => '#483D8B', + 'darkslategray' => '#2F4F4F', + 'darkslategrey' => '#2F4F4F', + 'darkturquoise' => '#00CED1', + 'darkviolet' => '#9400D3', + 'deeppink' => '#FF1493', + 'deepskyblue' => '#00BFFF', + 'dimgray' => '#696969', + 'dimgrey' => '#696969', + 'dodgerblue' => '#1E90FF', + 'firebrick' => '#B22222', + 'floralwhite' => '#FFFAF0', + 'forestgreen' => '#228B22', + 'fuchsia' => '#FF00FF', + 'gainsboro' => '#DCDCDC', + 'ghostwhite' => '#F8F8FF', + 'gold' => '#FFD700', + 'goldenrod' => '#DAA520', + 'gray' => '#808080', + 'grey' => '#808080', + 'green' => '#008000', + 'greenyellow' => '#ADFF2F', + 'honeydew' => '#F0FFF0', + 'hotpink' => '#FF69B4', + 'indianred' => '#CD5C5C', + 'indigo' => '#4B0082', + 'ivory' => '#FFFFF0', + 'khaki' => '#F0E68C', + 'lavender' => '#E6E6FA', + 'lavenderblush' => '#FFF0F5', + 'lawngreen' => '#7CFC00', + 'lemonchiffon' => '#FFFACD', + 'lightblue' => '#ADD8E6', + 'lightcoral' => '#F08080', + 'lightcyan' => '#E0FFFF', + 'lightgoldenrodyellow' => '#FAFAD2', + 'lightgray' => '#D3D3D3', + 'lightgrey' => '#D3D3D3', + 'lightgreen' => '#90EE90', + 'lightpink' => '#FFB6C1', + 'lightsalmon' => '#FFA07A', + 'lightseagreen' => '#20B2AA', + 'lightskyblue' => '#87CEFA', + 'lightslategray' => '#778899', + 'lightslategrey' => '#778899', + 'lightsteelblue' => '#B0C4DE', + 'lightyellow' => '#FFFFE0', + 'lime' => '#00FF00', + 'limegreen' => '#32CD32', + 'linen' => '#FAF0E6', + 'magenta' => '#FF00FF', + 'maroon' => '#800000', + 'mediumaquamarine' => '#66CDAA', + 'mediumblue' => '#0000CD', + 'mediumorchid' => '#BA55D3', + 'mediumpurple' => '#9370DB', + 'mediumseagreen' => '#3CB371', + 'mediumslateblue' => '#7B68EE', + 'mediumspringgreen' => '#00FA9A', + 'mediumturquoise' => '#48D1CC', + 'mediumvioletred' => '#C71585', + 'midnightblue' => '#191970', + 'mintcream' => '#F5FFFA', + 'mistyrose' => '#FFE4E1', + 'moccasin' => '#FFE4B5', + 'navajowhite' => '#FFDEAD', + 'navy' => '#000080', + 'oldlace' => '#FDF5E6', + 'olive' => '#808000', + 'olivedrab' => '#6B8E23', + 'orange' => '#FFA500', + 'orangered' => '#FF4500', + 'orchid' => '#DA70D6', + 'palegoldenrod' => '#EEE8AA', + 'palegreen' => '#98FB98', + 'paleturquoise' => '#AFEEEE', + 'palevioletred' => '#DB7093', + 'papayawhip' => '#FFEFD5', + 'peachpuff' => '#FFDAB9', + 'peru' => '#CD853F', + 'pink' => '#FFC0CB', + 'plum' => '#DDA0DD', + 'powderblue' => '#B0E0E6', + 'purple' => '#800080', + 'rebeccapurple' => '#663399', + 'red' => '#FF0000', + 'rosybrown' => '#BC8F8F', + 'royalblue' => '#4169E1', + 'saddlebrown' => '#8B4513', + 'salmon' => '#FA8072', + 'sandybrown' => '#F4A460', + 'seagreen' => '#2E8B57', + 'seashell' => '#FFF5EE', + 'sienna' => '#A0522D', + 'silver' => '#C0C0C0', + 'skyblue' => '#87CEEB', + 'slateblue' => '#6A5ACD', + 'slategray' => '#708090', + 'slategrey' => '#708090', + 'snow' => '#FFFAFA', + 'springgreen' => '#00FF7F', + 'steelblue' => '#4682B4', + 'tan' => '#D2B48C', + 'teal' => '#008080', + 'thistle' => '#D8BFD8', + 'tomato' => '#FF6347', + 'turquoise' => '#40E0D0', + 'violet' => '#EE82EE', + 'wheat' => '#F5DEB3', + 'white' => '#FFFFFF', + 'whitesmoke' => '#F5F5F5', + 'yellow' => '#FFFF00', + 'yellowgreen' => '#9ACD32' +) +--DESCRIPTION-- + +Lookup array of color names to six digit hexadecimal number corresponding +to color, with preceding hash mark. Used when parsing colors. The lookup +is done in a case-insensitive manner. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.ConvertDocumentToFragment.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.ConvertDocumentToFragment.txt new file mode 100644 index 0000000..64b114f --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.ConvertDocumentToFragment.txt @@ -0,0 +1,14 @@ +Core.ConvertDocumentToFragment +TYPE: bool +DEFAULT: true +--DESCRIPTION-- + +This parameter determines whether or not the filter should convert +input that is a full document with html and body tags to a fragment +of just the contents of a body tag. This parameter is simply something +HTML Purifier can do during an edge-case: for most inputs, this +processing is not necessary. + +--ALIASES-- +Core.AcceptFullDocuments +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt new file mode 100644 index 0000000..36f16e0 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.DirectLexLineNumberSyncInterval.txt @@ -0,0 +1,17 @@ +Core.DirectLexLineNumberSyncInterval +TYPE: int +VERSION: 2.0.0 +DEFAULT: 0 +--DESCRIPTION-- + +

+ Specifies the number of tokens the DirectLex line number tracking + implementations should process before attempting to resyncronize the + current line count by manually counting all previous new-lines. When + at 0, this functionality is disabled. Lower values will decrease + performance, and this is only strictly necessary if the counting + algorithm is buggy (in which case you should report it as a bug). + This has no effect when %Core.MaintainLineNumbers is disabled or DirectLex is + not being used. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.DisableExcludes.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.DisableExcludes.txt new file mode 100644 index 0000000..1cd4c2c --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.DisableExcludes.txt @@ -0,0 +1,14 @@ +Core.DisableExcludes +TYPE: bool +DEFAULT: false +VERSION: 4.5.0 +--DESCRIPTION-- +

+ This directive disables SGML-style exclusions, e.g. the exclusion of + <object> in any descendant of a + <pre> tag. Disabling excludes will allow some + invalid documents to pass through HTML Purifier, but HTML Purifier + will also be less likely to accidentally remove large documents during + processing. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EnableIDNA.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EnableIDNA.txt new file mode 100644 index 0000000..ce243c3 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EnableIDNA.txt @@ -0,0 +1,9 @@ +Core.EnableIDNA +TYPE: bool +DEFAULT: false +VERSION: 4.4.0 +--DESCRIPTION-- +Allows international domain names in URLs. This configuration option +requires the PEAR Net_IDNA2 module to be installed. It operates by +punycoding any internationalized host names for maximum portability. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.Encoding.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.Encoding.txt new file mode 100644 index 0000000..8bfb47c --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.Encoding.txt @@ -0,0 +1,15 @@ +Core.Encoding +TYPE: istring +DEFAULT: 'utf-8' +--DESCRIPTION-- +If for some reason you are unable to convert all webpages to UTF-8, you can +use this directive as a stop-gap compatibility change to let HTML Purifier +deal with non UTF-8 input. This technique has notable deficiencies: +absolutely no characters outside of the selected character encoding will be +preserved, not even the ones that have been ampersand escaped (this is due +to a UTF-8 specific feature that automatically resolves all +entities), making it pretty useless for anything except the most I18N-blind +applications, although %Core.EscapeNonASCIICharacters offers fixes this +trouble with another tradeoff. This directive only accepts ISO-8859-1 if +iconv is not enabled. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidChildren.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidChildren.txt new file mode 100644 index 0000000..a3881be --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidChildren.txt @@ -0,0 +1,12 @@ +Core.EscapeInvalidChildren +TYPE: bool +DEFAULT: false +--DESCRIPTION-- +

Warning: this configuration option is no longer does anything as of 4.6.0.

+ +

When true, a child is found that is not allowed in the context of the +parent element will be transformed into text as if it were ASCII. When +false, that element and all internal tags will be dropped, though text will +be preserved. There is no option for dropping the element but preserving +child nodes.

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidTags.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidTags.txt new file mode 100644 index 0000000..a7a5b24 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeInvalidTags.txt @@ -0,0 +1,7 @@ +Core.EscapeInvalidTags +TYPE: bool +DEFAULT: false +--DESCRIPTION-- +When true, invalid tags will be written back to the document as plain text. +Otherwise, they are silently dropped. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt new file mode 100644 index 0000000..abb4999 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.EscapeNonASCIICharacters.txt @@ -0,0 +1,13 @@ +Core.EscapeNonASCIICharacters +TYPE: bool +VERSION: 1.4.0 +DEFAULT: false +--DESCRIPTION-- +This directive overcomes a deficiency in %Core.Encoding by blindly +converting all non-ASCII characters into decimal numeric entities before +converting it to its native encoding. This means that even characters that +can be expressed in the non-UTF-8 encoding will be entity-ized, which can +be a real downer for encodings like Big5. It also assumes that the ASCII +repetoire is available, although this is the case for almost all encodings. +Anyway, use UTF-8! +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt new file mode 100644 index 0000000..915391e --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.HiddenElements.txt @@ -0,0 +1,19 @@ +Core.HiddenElements +TYPE: lookup +--DEFAULT-- +array ( + 'script' => true, + 'style' => true, +) +--DESCRIPTION-- + +

+ This directive is a lookup array of elements which should have their + contents removed when they are not allowed by the HTML definition. + For example, the contents of a script tag are not + normally shown in a document, so if script tags are to be removed, + their contents should be removed to. This is opposed to a b + tag, which defines some presentational changes but does not hide its + contents. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.Language.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.Language.txt new file mode 100644 index 0000000..233fca1 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.Language.txt @@ -0,0 +1,10 @@ +Core.Language +TYPE: string +VERSION: 2.0.0 +DEFAULT: 'en' +--DESCRIPTION-- + +ISO 639 language code for localizable things in HTML Purifier to use, +which is mainly error reporting. There is currently only an English (en) +translation, so this directive is currently useless. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.LegacyEntityDecoder.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.LegacyEntityDecoder.txt new file mode 100644 index 0000000..392b436 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.LegacyEntityDecoder.txt @@ -0,0 +1,36 @@ +Core.LegacyEntityDecoder +TYPE: bool +VERSION: 4.9.0 +DEFAULT: false +--DESCRIPTION-- +

+ Prior to HTML Purifier 4.9.0, entities were decoded by performing + a global search replace for all entities whose decoded versions + did not have special meanings under HTML, and replaced them with + their decoded versions. We would match all entities, even if they did + not have a trailing semicolon, but only if there weren't any trailing + alphanumeric characters. +

+ + + + + + +
OriginalTextAttribute
&yen;¥¥
&yen¥¥
&yena&yena&yena
&yen=¥=¥=
+

+ In HTML Purifier 4.9.0, we changed the behavior of entity parsing + to match entities that had missing trailing semicolons in less + cases, to more closely match HTML5 parsing behavior: +

+ + + + + + +
OriginalTextAttribute
&yen;¥¥
&yen¥¥
&yena¥a&yena
&yen=¥=&yen=
+

+ This flag reverts back to pre-HTML Purifier 4.9.0 behavior. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.LexerImpl.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.LexerImpl.txt new file mode 100644 index 0000000..8983e2c --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.LexerImpl.txt @@ -0,0 +1,34 @@ +Core.LexerImpl +TYPE: mixed/null +VERSION: 2.0.0 +DEFAULT: NULL +--DESCRIPTION-- + +

+ This parameter determines what lexer implementation can be used. The + valid values are: +

+
+
null
+
+ Recommended, the lexer implementation will be auto-detected based on + your PHP-version and configuration. +
+
string lexer identifier
+
+ This is a slim way of manually overridding the implementation. + Currently recognized values are: DOMLex (the default PHP5 +implementation) + and DirectLex (the default PHP4 implementation). Only use this if + you know what you are doing: usually, the auto-detection will + manage things for cases you aren't even aware of. +
+
object lexer instance
+
+ Super-advanced: you can specify your own, custom, implementation that + implements the interface defined by HTMLPurifier_Lexer. + I may remove this option simply because I don't expect anyone + to use it. +
+
+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.MaintainLineNumbers.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.MaintainLineNumbers.txt new file mode 100644 index 0000000..eb841a7 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.MaintainLineNumbers.txt @@ -0,0 +1,16 @@ +Core.MaintainLineNumbers +TYPE: bool/null +VERSION: 2.0.0 +DEFAULT: NULL +--DESCRIPTION-- + +

+ If true, HTML Purifier will add line number information to all tokens. + This is useful when error reporting is turned on, but can result in + significant performance degradation and should not be used when + unnecessary. This directive must be used with the DirectLex lexer, + as the DOMLex lexer does not (yet) support this functionality. + If the value is null, an appropriate value will be selected based + on other configuration. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.NormalizeNewlines.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.NormalizeNewlines.txt new file mode 100644 index 0000000..d77f536 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.NormalizeNewlines.txt @@ -0,0 +1,11 @@ +Core.NormalizeNewlines +TYPE: bool +VERSION: 4.2.0 +DEFAULT: true +--DESCRIPTION-- +

+ Whether or not to normalize newlines to the operating + system default. When false, HTML Purifier + will attempt to preserve mixed newline files. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveBlanks.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveBlanks.txt new file mode 100644 index 0000000..95e5285 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveBlanks.txt @@ -0,0 +1,10 @@ +Core.RemoveBlanks +TYPE: bool +DEFAULT: false +VERSION: 4.18 +--DESCRIPTION-- +

+ If set to true, blank nodes will be removed. This can be useful for maintaining + backwards compatibility when upgrading from previous versions of PHP. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveInvalidImg.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveInvalidImg.txt new file mode 100644 index 0000000..4070c2a --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveInvalidImg.txt @@ -0,0 +1,12 @@ +Core.RemoveInvalidImg +TYPE: bool +DEFAULT: true +VERSION: 1.3.0 +--DESCRIPTION-- + +

+ This directive enables pre-emptive URI checking in img + tags, as the attribute validation strategy is not authorized to + remove elements from the document. Revert to pre-1.3.0 behavior by setting to false. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveProcessingInstructions.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveProcessingInstructions.txt new file mode 100644 index 0000000..3397d9f --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveProcessingInstructions.txt @@ -0,0 +1,11 @@ +Core.RemoveProcessingInstructions +TYPE: bool +VERSION: 4.2.0 +DEFAULT: false +--DESCRIPTION-- +Instead of escaping processing instructions in the form <? ... +?>, remove it out-right. This may be useful if the HTML +you are validating contains XML processing instruction gunk, however, +it can also be user-unfriendly for people attempting to post PHP +snippets. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveScriptContents.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveScriptContents.txt new file mode 100644 index 0000000..a4cd966 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Core.RemoveScriptContents.txt @@ -0,0 +1,12 @@ +Core.RemoveScriptContents +TYPE: bool/null +DEFAULT: NULL +VERSION: 2.0.0 +DEPRECATED-VERSION: 2.1.0 +DEPRECATED-USE: Core.HiddenElements +--DESCRIPTION-- +

+ This directive enables HTML Purifier to remove not only script tags + but all of their contents. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.Custom.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.Custom.txt new file mode 100644 index 0000000..3db50ef --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.Custom.txt @@ -0,0 +1,11 @@ +Filter.Custom +TYPE: list +VERSION: 3.1.0 +DEFAULT: array() +--DESCRIPTION-- +

+ This directive can be used to add custom filters; it is nearly the + equivalent of the now deprecated HTMLPurifier->addFilter() + method. Specify an array of concrete implementations. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Escaping.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Escaping.txt new file mode 100644 index 0000000..16829bc --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Escaping.txt @@ -0,0 +1,14 @@ +Filter.ExtractStyleBlocks.Escaping +TYPE: bool +VERSION: 3.0.0 +DEFAULT: true +ALIASES: Filter.ExtractStyleBlocksEscaping, FilterParam.ExtractStyleBlocksEscaping +--DESCRIPTION-- + +

+ Whether or not to escape the dangerous characters <, > and & + as \3C, \3E and \26, respectively. This is can be safely set to false + if the contents of StyleBlocks will be placed in an external stylesheet, + where there is no risk of it being interpreted as HTML. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Scope.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Scope.txt new file mode 100644 index 0000000..7f95f54 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.Scope.txt @@ -0,0 +1,29 @@ +Filter.ExtractStyleBlocks.Scope +TYPE: string/null +VERSION: 3.0.0 +DEFAULT: NULL +ALIASES: Filter.ExtractStyleBlocksScope, FilterParam.ExtractStyleBlocksScope +--DESCRIPTION-- + +

+ If you would like users to be able to define external stylesheets, but + only allow them to specify CSS declarations for a specific node and + prevent them from fiddling with other elements, use this directive. + It accepts any valid CSS selector, and will prepend this to any + CSS declaration extracted from the document. For example, if this + directive is set to #user-content and a user uses the + selector a:hover, the final selector will be + #user-content a:hover. +

+

+ The comma shorthand may be used; consider the above example, with + #user-content, #user-content2, the final selector will + be #user-content a:hover, #user-content2 a:hover. +

+

+ Warning: It is possible for users to bypass this measure + using a naughty + selector. This is a bug in CSS Tidy 1.3, not HTML + Purifier, and I am working to get it fixed. Until then, HTML Purifier + performs a basic check to prevent this. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.TidyImpl.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.TidyImpl.txt new file mode 100644 index 0000000..6c231b2 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.TidyImpl.txt @@ -0,0 +1,16 @@ +Filter.ExtractStyleBlocks.TidyImpl +TYPE: mixed/null +VERSION: 3.1.0 +DEFAULT: NULL +ALIASES: FilterParam.ExtractStyleBlocksTidyImpl +--DESCRIPTION-- +

+ If left NULL, HTML Purifier will attempt to instantiate a csstidy + class to use for internal cleaning. This will usually be good enough. +

+

+ However, for trusted user input, you can set this to false to + disable cleaning. In addition, you can supply your own concrete implementation + of Tidy's interface to use, although I don't know why you'd want to do that. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.txt new file mode 100644 index 0000000..078d087 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.ExtractStyleBlocks.txt @@ -0,0 +1,74 @@ +Filter.ExtractStyleBlocks +TYPE: bool +VERSION: 3.1.0 +DEFAULT: false +EXTERNAL: CSSTidy +--DESCRIPTION-- +

+ This directive turns on the style block extraction filter, which removes + style blocks from input HTML, cleans them up with CSSTidy, + and places them in the StyleBlocks context variable, for further + use by you, usually to be placed in an external stylesheet, or a + style block in the head of your document. +

+

+ Sample usage: +

+
';
+?>
+
+
+
+  Filter.ExtractStyleBlocks
+body {color:#F00;} Some text';
+
+    $config = HTMLPurifier_Config::createDefault();
+    $config->set('Filter', 'ExtractStyleBlocks', true);
+    $purifier = new HTMLPurifier($config);
+
+    $html = $purifier->purify($dirty);
+
+    // This implementation writes the stylesheets to the styles/ directory.
+    // You can also echo the styles inside the document, but it's a bit
+    // more difficult to make sure they get interpreted properly by
+    // browsers; try the usual CSS armoring techniques.
+    $styles = $purifier->context->get('StyleBlocks');
+    $dir = 'styles/';
+    if (!is_dir($dir)) mkdir($dir);
+    $hash = sha1($_GET['html']);
+    foreach ($styles as $i => $style) {
+        file_put_contents($name = $dir . $hash . "_$i");
+        echo '';
+    }
+?>
+
+
+  
+ +
+ + +]]>
+

+ Warning: It is possible for a user to mount an + imagecrash attack using this CSS. Counter-measures are difficult; + it is not simply enough to limit the range of CSS lengths (using + relative lengths with many nesting levels allows for large values + to be attained without actually specifying them in the stylesheet), + and the flexible nature of selectors makes it difficult to selectively + disable lengths on image tags (HTML Purifier, however, does disable + CSS width and height in inline styling). There are probably two effective + counter measures: an explicit width and height set to auto in all + images in your document (unlikely) or the disabling of width and + height (somewhat reasonable). Whether or not these measures should be + used is left to the reader. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt new file mode 100644 index 0000000..321eaa2 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Filter.YouTube.txt @@ -0,0 +1,16 @@ +Filter.YouTube +TYPE: bool +VERSION: 3.1.0 +DEFAULT: false +--DESCRIPTION-- +

+ Warning: Deprecated in favor of %HTML.SafeObject and + %Output.FlashCompat (turn both on to allow YouTube videos and other + Flash content). +

+

+ This directive enables YouTube video embedding in HTML Purifier. Check + this document + on embedding videos for more information on what this filter does. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Allowed.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Allowed.txt new file mode 100644 index 0000000..0b2c106 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Allowed.txt @@ -0,0 +1,25 @@ +HTML.Allowed +TYPE: itext/null +VERSION: 2.0.0 +DEFAULT: NULL +--DESCRIPTION-- + +

+ This is a preferred convenience directive that combines + %HTML.AllowedElements and %HTML.AllowedAttributes. + Specify elements and attributes that are allowed using: + element1[attr1|attr2],element2.... For example, + if you would like to only allow paragraphs and links, specify + a[href],p. You can specify attributes that apply + to all elements using an asterisk, e.g. *[lang]. + You can also use newlines instead of commas to separate elements. +

+

+ Warning: + All of the constraints on the component directives are still enforced. + The syntax is a subset of TinyMCE's valid_elements + whitelist: directly copy-pasting it here will probably result in + broken whitelists. If %HTML.AllowedElements or %HTML.AllowedAttributes + are set, this directive has no effect. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedAttributes.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedAttributes.txt new file mode 100644 index 0000000..fcf093f --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedAttributes.txt @@ -0,0 +1,19 @@ +HTML.AllowedAttributes +TYPE: lookup/null +VERSION: 1.3.0 +DEFAULT: NULL +--DESCRIPTION-- + +

+ If HTML Purifier's attribute set is unsatisfactory, overload it! + The syntax is "tag.attr" or "*.attr" for the global attributes + (style, id, class, dir, lang, xml:lang). +

+

+ Warning: If another directive conflicts with the + elements here, that directive will win and override. For + example, %HTML.EnableAttrID will take precedence over *.id in this + directive. You must set that directive to true before you can use + IDs at all. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedComments.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedComments.txt new file mode 100644 index 0000000..140e214 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedComments.txt @@ -0,0 +1,10 @@ +HTML.AllowedComments +TYPE: lookup +VERSION: 4.4.0 +DEFAULT: array() +--DESCRIPTION-- +A whitelist which indicates what explicit comment bodies should be +allowed, modulo leading and trailing whitespace. See also %HTML.AllowedCommentsRegexp +(these directives are union'ed together, so a comment is considered +valid if any directive deems it valid.) +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedCommentsRegexp.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedCommentsRegexp.txt new file mode 100644 index 0000000..f22e977 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedCommentsRegexp.txt @@ -0,0 +1,15 @@ +HTML.AllowedCommentsRegexp +TYPE: string/null +VERSION: 4.4.0 +DEFAULT: NULL +--DESCRIPTION-- +A regexp, which if it matches the body of a comment, indicates that +it should be allowed. Trailing and leading spaces are removed prior +to running this regular expression. +Warning: Make sure you specify +correct anchor metacharacters ^regex$, otherwise you may accept +comments that you did not mean to! In particular, the regex /foo|bar/ +is probably not sufficiently strict, since it also allows foobar. +See also %HTML.AllowedComments (these directives are union'ed together, +so a comment is considered valid if any directive deems it valid.) +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt new file mode 100644 index 0000000..1d3fa79 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedElements.txt @@ -0,0 +1,23 @@ +HTML.AllowedElements +TYPE: lookup/null +VERSION: 1.3.0 +DEFAULT: NULL +--DESCRIPTION-- +

+ If HTML Purifier's tag set is unsatisfactory for your needs, you can + overload it with your own list of tags to allow. If you change + this, you probably also want to change %HTML.AllowedAttributes; see + also %HTML.Allowed which lets you set allowed elements and + attributes at the same time. +

+

+ If you attempt to allow an element that HTML Purifier does not know + about, HTML Purifier will raise an error. You will need to manually + tell HTML Purifier about this element by using the + advanced customization features. +

+

+ Warning: If another directive conflicts with the + elements here, that directive will win and override. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt new file mode 100644 index 0000000..5a59a55 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.AllowedModules.txt @@ -0,0 +1,20 @@ +HTML.AllowedModules +TYPE: lookup/null +VERSION: 2.0.0 +DEFAULT: NULL +--DESCRIPTION-- + +

+ A doctype comes with a set of usual modules to use. Without having + to mucking about with the doctypes, you can quickly activate or + disable these modules by specifying which modules you wish to allow + with this directive. This is most useful for unit testing specific + modules, although end users may find it useful for their own ends. +

+

+ If you specify a module that does not exist, the manager will silently + fail to use it, so be careful! User-defined modules are not affected + by this directive. Modules defined in %HTML.CoreModules are not + affected by this directive. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Attr.Name.UseCDATA.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Attr.Name.UseCDATA.txt new file mode 100644 index 0000000..151fb7b --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Attr.Name.UseCDATA.txt @@ -0,0 +1,11 @@ +HTML.Attr.Name.UseCDATA +TYPE: bool +DEFAULT: false +VERSION: 4.0.0 +--DESCRIPTION-- +The W3C specification DTD defines the name attribute to be CDATA, not ID, due +to limitations of DTD. In certain documents, this relaxed behavior is desired, +whether it is to specify duplicate names, or to specify names that would be +illegal IDs (for example, names that begin with a digit.) Set this configuration +directive to true to use the relaxed parsing rules. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt new file mode 100644 index 0000000..45ae469 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.BlockWrapper.txt @@ -0,0 +1,18 @@ +HTML.BlockWrapper +TYPE: string +VERSION: 1.3.0 +DEFAULT: 'p' +--DESCRIPTION-- + +

+ String name of element to wrap inline elements that are inside a block + context. This only occurs in the children of blockquote in strict mode. +

+

+ Example: by default value, + <blockquote>Foo</blockquote> would become + <blockquote><p>Foo</p></blockquote>. + The <p> tags can be replaced with whatever you desire, + as long as it is a block level element. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.CoreModules.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.CoreModules.txt new file mode 100644 index 0000000..5246188 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.CoreModules.txt @@ -0,0 +1,23 @@ +HTML.CoreModules +TYPE: lookup +VERSION: 2.0.0 +--DEFAULT-- +array ( + 'Structure' => true, + 'Text' => true, + 'Hypertext' => true, + 'List' => true, + 'NonXMLCommonAttributes' => true, + 'XMLCommonAttributes' => true, + 'CommonAttributes' => true, +) +--DESCRIPTION-- + +

+ Certain modularized doctypes (XHTML, namely), have certain modules + that must be included for the doctype to be an conforming document + type: put those modules here. By default, XHTML's core modules + are used. You can set this to a blank array to disable core module + protection, but this is not recommended. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.CustomDoctype.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.CustomDoctype.txt new file mode 100644 index 0000000..6ed70b5 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.CustomDoctype.txt @@ -0,0 +1,9 @@ +HTML.CustomDoctype +TYPE: string/null +VERSION: 2.0.1 +DEFAULT: NULL +--DESCRIPTION-- + +A custom doctype for power-users who defined their own document +type. This directive only applies when %HTML.Doctype is blank. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionID.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionID.txt new file mode 100644 index 0000000..103db75 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionID.txt @@ -0,0 +1,33 @@ +HTML.DefinitionID +TYPE: string/null +DEFAULT: NULL +VERSION: 2.0.0 +--DESCRIPTION-- + +

+ Unique identifier for a custom-built HTML definition. If you edit + the raw version of the HTMLDefinition, introducing changes that the + configuration object does not reflect, you must specify this variable. + If you change your custom edits, you should change this directive, or + clear your cache. Example: +

+
+$config = HTMLPurifier_Config::createDefault();
+$config->set('HTML', 'DefinitionID', '1');
+$def = $config->getHTMLDefinition();
+$def->addAttribute('a', 'tabindex', 'Number');
+
+

+ In the above example, the configuration is still at the defaults, but + using the advanced API, an extra attribute has been added. The + configuration object normally has no way of knowing that this change + has taken place, so it needs an extra directive: %HTML.DefinitionID. + If someone else attempts to use the default configuration, these two + pieces of code will not clobber each other in the cache, since one has + an extra directive attached to it. +

+

+ You must specify a value to this directive to use the + advanced API features. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt new file mode 100644 index 0000000..229ae02 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.DefinitionRev.txt @@ -0,0 +1,16 @@ +HTML.DefinitionRev +TYPE: int +VERSION: 2.0.0 +DEFAULT: 1 +--DESCRIPTION-- + +

+ Revision identifier for your custom definition specified in + %HTML.DefinitionID. This serves the same purpose: uniquely identifying + your custom definition, but this one does so in a chronological + context: revision 3 is more up-to-date then revision 2. Thus, when + this gets incremented, the cache handling is smart enough to clean + up any older revisions of your definition as well as flush the + cache. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Doctype.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Doctype.txt new file mode 100644 index 0000000..9dab497 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Doctype.txt @@ -0,0 +1,11 @@ +HTML.Doctype +TYPE: string/null +DEFAULT: NULL +--DESCRIPTION-- +Doctype to use during filtering. Technically speaking this is not actually +a doctype (as it does not identify a corresponding DTD), but we are using +this name for sake of simplicity. When non-blank, this will override any +older directives like %HTML.XHTML or %HTML.Strict. +--ALLOWED-- +'HTML 4.01 Transitional', 'HTML 4.01 Strict', 'XHTML 1.0 Transitional', 'XHTML 1.0 Strict', 'XHTML 1.1' +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt new file mode 100644 index 0000000..7878dc0 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.FlashAllowFullScreen.txt @@ -0,0 +1,11 @@ +HTML.FlashAllowFullScreen +TYPE: bool +VERSION: 4.2.0 +DEFAULT: false +--DESCRIPTION-- +

+ Whether or not to permit embedded Flash content from + %HTML.SafeObject to expand to the full screen. Corresponds to + the allowFullScreen parameter. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenAttributes.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenAttributes.txt new file mode 100644 index 0000000..57358f9 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenAttributes.txt @@ -0,0 +1,21 @@ +HTML.ForbiddenAttributes +TYPE: lookup +VERSION: 3.1.0 +DEFAULT: array() +--DESCRIPTION-- +

+ While this directive is similar to %HTML.AllowedAttributes, for + forwards-compatibility with XML, this attribute has a different syntax. Instead of + tag.attr, use tag@attr. To disallow href + attributes in a tags, set this directive to + a@href. You can also disallow an attribute globally with + attr or *@attr (either syntax is fine; the latter + is provided for consistency with %HTML.AllowedAttributes). +

+

+ Warning: This directive complements %HTML.ForbiddenElements, + accordingly, check + out that directive for a discussion of why you + should think twice before using this directive. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenElements.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenElements.txt new file mode 100644 index 0000000..93a53e1 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.ForbiddenElements.txt @@ -0,0 +1,20 @@ +HTML.ForbiddenElements +TYPE: lookup +VERSION: 3.1.0 +DEFAULT: array() +--DESCRIPTION-- +

+ This was, perhaps, the most requested feature ever in HTML + Purifier. Please don't abuse it! This is the logical inverse of + %HTML.AllowedElements, and it will override that directive, or any + other directive. +

+

+ If possible, %HTML.Allowed is recommended over this directive, because it + can sometimes be difficult to tell whether or not you've forbidden all of + the behavior you would like to disallow. If you forbid img + with the expectation of preventing images on your site, you'll be in for + a nasty surprise when people start using the background-image + CSS property. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Forms.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Forms.txt new file mode 100644 index 0000000..4a432d8 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Forms.txt @@ -0,0 +1,11 @@ +HTML.Forms +TYPE: bool +VERSION: 4.13.0 +DEFAULT: false +--DESCRIPTION-- +

+ Whether or not to permit form elements in the user input, regardless of + %HTML.Trusted value. Please be very careful when using this functionality, as + enabling forms in untrusted documents may allow for phishing attacks. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.MaxImgLength.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.MaxImgLength.txt new file mode 100644 index 0000000..e424c38 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.MaxImgLength.txt @@ -0,0 +1,14 @@ +HTML.MaxImgLength +TYPE: int/null +DEFAULT: 1200 +VERSION: 3.1.1 +--DESCRIPTION-- +

+ This directive controls the maximum number of pixels in the width and + height attributes in img tags. This is + in place to prevent imagecrash attacks, disable with null at your own risk. + This directive is similar to %CSS.MaxImgLength, and both should be + concurrently edited, although there are + subtle differences in the input format (the HTML max is an integer). +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Nofollow.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Nofollow.txt new file mode 100644 index 0000000..700b309 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Nofollow.txt @@ -0,0 +1,7 @@ +HTML.Nofollow +TYPE: bool +VERSION: 4.3.0 +DEFAULT: FALSE +--DESCRIPTION-- +If enabled, nofollow rel attributes are added to all outgoing links. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Parent.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Parent.txt new file mode 100644 index 0000000..62e8e16 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Parent.txt @@ -0,0 +1,12 @@ +HTML.Parent +TYPE: string +VERSION: 1.3.0 +DEFAULT: 'div' +--DESCRIPTION-- + +

+ String name of element that HTML fragment passed to library will be + inserted in. An interesting variation would be using span as the + parent element, meaning that only inline tags would be allowed. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Proprietary.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Proprietary.txt new file mode 100644 index 0000000..dfb7204 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Proprietary.txt @@ -0,0 +1,12 @@ +HTML.Proprietary +TYPE: bool +VERSION: 3.1.0 +DEFAULT: false +--DESCRIPTION-- +

+ Whether or not to allow proprietary elements and attributes in your + documents, as per HTMLPurifier_HTMLModule_Proprietary. + Warning: This can cause your documents to stop + validating! +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeEmbed.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeEmbed.txt new file mode 100644 index 0000000..cdda09a --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeEmbed.txt @@ -0,0 +1,13 @@ +HTML.SafeEmbed +TYPE: bool +VERSION: 3.1.1 +DEFAULT: false +--DESCRIPTION-- +

+ Whether or not to permit embed tags in documents, with a number of extra + security features added to prevent script execution. This is similar to + what websites like MySpace do to embed tags. Embed is a proprietary + element and will cause your website to stop validating; you should + see if you can use %Output.FlashCompat with %HTML.SafeObject instead + first.

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeIframe.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeIframe.txt new file mode 100644 index 0000000..5eb6ec2 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeIframe.txt @@ -0,0 +1,13 @@ +HTML.SafeIframe +TYPE: bool +VERSION: 4.4.0 +DEFAULT: false +--DESCRIPTION-- +

+ Whether or not to permit iframe tags in untrusted documents. This + directive must be accompanied by a whitelist of permitted iframes, + such as %URI.SafeIframeRegexp, otherwise it will fatally error. + This directive has no effect on strict doctypes, as iframes are not + valid. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt new file mode 100644 index 0000000..ceb342e --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeObject.txt @@ -0,0 +1,13 @@ +HTML.SafeObject +TYPE: bool +VERSION: 3.1.1 +DEFAULT: false +--DESCRIPTION-- +

+ Whether or not to permit object tags in documents, with a number of extra + security features added to prevent script execution. This is similar to + what websites like MySpace do to object tags. You should also enable + %Output.FlashCompat in order to generate Internet Explorer + compatibility code for your object tags. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeScripting.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeScripting.txt new file mode 100644 index 0000000..5ebc7a1 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.SafeScripting.txt @@ -0,0 +1,10 @@ +HTML.SafeScripting +TYPE: lookup +VERSION: 4.5.0 +DEFAULT: array() +--DESCRIPTION-- +

+ Whether or not to permit script tags to external scripts in documents. + Inline scripting is not allowed, and the script must match an explicit whitelist. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Strict.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Strict.txt new file mode 100644 index 0000000..a8b1de5 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Strict.txt @@ -0,0 +1,9 @@ +HTML.Strict +TYPE: bool +VERSION: 1.3.0 +DEFAULT: false +DEPRECATED-VERSION: 1.7.0 +DEPRECATED-USE: HTML.Doctype +--DESCRIPTION-- +Determines whether or not to use Transitional (loose) or Strict rulesets. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetBlank.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetBlank.txt new file mode 100644 index 0000000..587a167 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetBlank.txt @@ -0,0 +1,8 @@ +HTML.TargetBlank +TYPE: bool +VERSION: 4.4.0 +DEFAULT: FALSE +--DESCRIPTION-- +If enabled, target=blank attributes are added to all outgoing links. +(This includes links from an HTTPS version of a page to an HTTP version.) +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoopener.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoopener.txt new file mode 100644 index 0000000..dd514c0 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoopener.txt @@ -0,0 +1,10 @@ +--# vim: et sw=4 sts=4 +HTML.TargetNoopener +TYPE: bool +VERSION: 4.8.0 +DEFAULT: TRUE +--DESCRIPTION-- +If enabled, noopener rel attributes are added to links which have +a target attribute associated with them. This prevents malicious +destinations from overwriting the original window. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoreferrer.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoreferrer.txt new file mode 100644 index 0000000..cb5a0b0 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TargetNoreferrer.txt @@ -0,0 +1,9 @@ +HTML.TargetNoreferrer +TYPE: bool +VERSION: 4.8.0 +DEFAULT: TRUE +--DESCRIPTION-- +If enabled, noreferrer rel attributes are added to links which have +a target attribute associated with them. This prevents malicious +destinations from overwriting the original window. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt new file mode 100644 index 0000000..b4c271b --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyAdd.txt @@ -0,0 +1,8 @@ +HTML.TidyAdd +TYPE: lookup +VERSION: 2.0.0 +DEFAULT: array() +--DESCRIPTION-- + +Fixes to add to the default set of Tidy fixes as per your level. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyLevel.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyLevel.txt new file mode 100644 index 0000000..4186ccd --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyLevel.txt @@ -0,0 +1,24 @@ +HTML.TidyLevel +TYPE: string +VERSION: 2.0.0 +DEFAULT: 'medium' +--DESCRIPTION-- + +

General level of cleanliness the Tidy module should enforce. +There are four allowed values:

+
+
none
+
No extra tidying should be done
+
light
+
Only fix elements that would be discarded otherwise due to + lack of support in doctype
+
medium
+
Enforce best practices
+
heavy
+
Transform all deprecated elements and attributes to standards + compliant equivalents
+
+ +--ALLOWED-- +'none', 'light', 'medium', 'heavy' +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyRemove.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyRemove.txt new file mode 100644 index 0000000..996762b --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.TidyRemove.txt @@ -0,0 +1,8 @@ +HTML.TidyRemove +TYPE: lookup +VERSION: 2.0.0 +DEFAULT: array() +--DESCRIPTION-- + +Fixes to remove from the default set of Tidy fixes as per your level. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Trusted.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Trusted.txt new file mode 100644 index 0000000..1db9237 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.Trusted.txt @@ -0,0 +1,9 @@ +HTML.Trusted +TYPE: bool +VERSION: 2.0.0 +DEFAULT: false +--DESCRIPTION-- +Indicates whether or not the user input is trusted or not. If the input is +trusted, a more expansive set of allowed tags and attributes will be used. +See also %CSS.Trusted. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.XHTML.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.XHTML.txt new file mode 100644 index 0000000..2a47e38 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/HTML.XHTML.txt @@ -0,0 +1,11 @@ +HTML.XHTML +TYPE: bool +DEFAULT: true +VERSION: 1.1.0 +DEPRECATED-VERSION: 1.7.0 +DEPRECATED-USE: HTML.Doctype +--DESCRIPTION-- +Determines whether or not output is XHTML 1.0 or HTML 4.01 flavor. +--ALIASES-- +Core.XHTML +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.CommentScriptContents.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.CommentScriptContents.txt new file mode 100644 index 0000000..08921fd --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.CommentScriptContents.txt @@ -0,0 +1,10 @@ +Output.CommentScriptContents +TYPE: bool +VERSION: 2.0.0 +DEFAULT: true +--DESCRIPTION-- +Determines whether or not HTML Purifier should attempt to fix up the +contents of script tags for legacy browsers with comments. +--ALIASES-- +Core.CommentScriptContents +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.FixInnerHTML.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.FixInnerHTML.txt new file mode 100644 index 0000000..d6f0d9f --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.FixInnerHTML.txt @@ -0,0 +1,15 @@ +Output.FixInnerHTML +TYPE: bool +VERSION: 4.3.0 +DEFAULT: true +--DESCRIPTION-- +

+ If true, HTML Purifier will protect against Internet Explorer's + mishandling of the innerHTML attribute by appending + a space to any attribute that does not contain angled brackets, spaces + or quotes, but contains a backtick. This slightly changes the + semantics of any given attribute, so if this is unacceptable and + you do not use innerHTML on any of your pages, you can + turn this directive off. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.FlashCompat.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.FlashCompat.txt new file mode 100644 index 0000000..93398e8 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.FlashCompat.txt @@ -0,0 +1,11 @@ +Output.FlashCompat +TYPE: bool +VERSION: 4.1.0 +DEFAULT: false +--DESCRIPTION-- +

+ If true, HTML Purifier will generate Internet Explorer compatibility + code for all object code. This is highly recommended if you enable + %HTML.SafeObject. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt new file mode 100644 index 0000000..79f8ad8 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.Newline.txt @@ -0,0 +1,13 @@ +Output.Newline +TYPE: string/null +VERSION: 2.0.1 +DEFAULT: NULL +--DESCRIPTION-- + +

+ Newline string to format final output with. If left null, HTML Purifier + will auto-detect the default newline type of the system and use that; + you can manually override it here. Remember, \r\n is Windows, \r + is Mac, and \n is Unix. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt new file mode 100644 index 0000000..232b023 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.SortAttr.txt @@ -0,0 +1,14 @@ +Output.SortAttr +TYPE: bool +VERSION: 3.2.0 +DEFAULT: false +--DESCRIPTION-- +

+ If true, HTML Purifier will sort attributes by name before writing them back + to the document, converting a tag like: <el b="" a="" c="" /> + to <el a="" b="" c="" />. This is a workaround for + a bug in FCKeditor which causes it to swap attributes order, adding noise + to text diffs. If you're not seeing this bug, chances are, you don't need + this directive. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.TidyFormat.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.TidyFormat.txt new file mode 100644 index 0000000..06bab00 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Output.TidyFormat.txt @@ -0,0 +1,25 @@ +Output.TidyFormat +TYPE: bool +VERSION: 1.1.1 +DEFAULT: false +--DESCRIPTION-- +

+ Determines whether or not to run Tidy on the final output for pretty + formatting reasons, such as indentation and wrap. +

+

+ This can greatly improve readability for editors who are hand-editing + the HTML, but is by no means necessary as HTML Purifier has already + fixed all major errors the HTML may have had. Tidy is a non-default + extension, and this directive will silently fail if Tidy is not + available. +

+

+ If you are looking to make the overall look of your page's source + better, I recommend running Tidy on the entire page rather than just + user-content (after all, the indentation relative to the containing + blocks will be incorrect). +

+--ALIASES-- +Core.TidyFormat +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Test.ForceNoIconv.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Test.ForceNoIconv.txt new file mode 100644 index 0000000..071bc02 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/Test.ForceNoIconv.txt @@ -0,0 +1,7 @@ +Test.ForceNoIconv +TYPE: bool +DEFAULT: false +--DESCRIPTION-- +When set to true, HTMLPurifier_Encoder will act as if iconv does not exist +and use only pure PHP implementations. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.AllowedSchemes.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.AllowedSchemes.txt new file mode 100644 index 0000000..eb97307 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.AllowedSchemes.txt @@ -0,0 +1,18 @@ +URI.AllowedSchemes +TYPE: lookup +--DEFAULT-- +array ( + 'http' => true, + 'https' => true, + 'mailto' => true, + 'ftp' => true, + 'nntp' => true, + 'news' => true, + 'tel' => true, +) +--DESCRIPTION-- +Whitelist that defines the schemes that a URI is allowed to have. This +prevents XSS attacks from using pseudo-schemes like javascript or mocha. +There is also support for the data and file +URI schemes, but they are not enabled by default. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Base.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Base.txt new file mode 100644 index 0000000..876f068 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Base.txt @@ -0,0 +1,17 @@ +URI.Base +TYPE: string/null +VERSION: 2.1.0 +DEFAULT: NULL +--DESCRIPTION-- + +

+ The base URI is the URI of the document this purified HTML will be + inserted into. This information is important if HTML Purifier needs + to calculate absolute URIs from relative URIs, such as when %URI.MakeAbsolute + is on. You may use a non-absolute URI for this value, but behavior + may vary (%URI.MakeAbsolute deals nicely with both absolute and + relative paths, but forwards-compatibility is not guaranteed). + Warning: If set, the scheme on this URI + overrides the one specified by %URI.DefaultScheme. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt new file mode 100644 index 0000000..834bc08 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefaultScheme.txt @@ -0,0 +1,15 @@ +URI.DefaultScheme +TYPE: string/null +DEFAULT: 'http' +--DESCRIPTION-- + +

+ Defines through what scheme the output will be served, in order to + select the proper object validator when no scheme information is present. +

+ +

+ Starting with HTML Purifier 4.9.0, the default scheme can be null, in + which case we reject all URIs which do not have explicit schemes. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionID.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionID.txt new file mode 100644 index 0000000..f05312b --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionID.txt @@ -0,0 +1,11 @@ +URI.DefinitionID +TYPE: string/null +VERSION: 2.1.0 +DEFAULT: NULL +--DESCRIPTION-- + +

+ Unique identifier for a custom-built URI definition. If you want + to add custom URIFilters, you must specify this value. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt new file mode 100644 index 0000000..80cfea9 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DefinitionRev.txt @@ -0,0 +1,11 @@ +URI.DefinitionRev +TYPE: int +VERSION: 2.1.0 +DEFAULT: 1 +--DESCRIPTION-- + +

+ Revision identifier for your custom definition. See + %HTML.DefinitionRev for details. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt new file mode 100644 index 0000000..71ce025 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Disable.txt @@ -0,0 +1,14 @@ +URI.Disable +TYPE: bool +VERSION: 1.3.0 +DEFAULT: false +--DESCRIPTION-- + +

+ Disables all URIs in all forms. Not sure why you'd want to do that + (after all, the Internet's founded on the notion of a hyperlink). +

+ +--ALIASES-- +Attr.DisableURI +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt new file mode 100644 index 0000000..13c122c --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternal.txt @@ -0,0 +1,11 @@ +URI.DisableExternal +TYPE: bool +VERSION: 1.2.0 +DEFAULT: false +--DESCRIPTION-- +Disables links to external websites. This is a highly effective anti-spam +and anti-pagerank-leech measure, but comes at a hefty price: nolinks or +images outside of your domain will be allowed. Non-linkified URIs will +still be preserved. If you want to be able to link to subdomains or use +absolute URIs, specify %URI.Host for your website. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt new file mode 100644 index 0000000..abcc1ef --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableExternalResources.txt @@ -0,0 +1,13 @@ +URI.DisableExternalResources +TYPE: bool +VERSION: 1.3.0 +DEFAULT: false +--DESCRIPTION-- +Disables the embedding of external resources, preventing users from +embedding things like images from other hosts. This prevents access +tracking (good for email viewers), bandwidth leeching, cross-site request +forging, goatse.cx posting, and other nasties, but also results in a loss +of end-user functionality (they can't directly post a pic they posted from +Flickr anymore). Use it if you don't have a robust user-content moderation +team. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt new file mode 100644 index 0000000..f891de4 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.DisableResources.txt @@ -0,0 +1,15 @@ +URI.DisableResources +TYPE: bool +VERSION: 4.2.0 +DEFAULT: false +--DESCRIPTION-- +

+ Disables embedding resources, essentially meaning no pictures. You can + still link to them though. See %URI.DisableExternalResources for why + this might be a good idea. +

+

+ Note: While this directive has been available since 1.3.0, + it didn't actually start doing anything until 4.2.0. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Host.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Host.txt new file mode 100644 index 0000000..ee83b12 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Host.txt @@ -0,0 +1,19 @@ +URI.Host +TYPE: string/null +VERSION: 1.2.0 +DEFAULT: NULL +--DESCRIPTION-- + +

+ Defines the domain name of the server, so we can determine whether or + an absolute URI is from your website or not. Not strictly necessary, + as users should be using relative URIs to reference resources on your + website. It will, however, let you use absolute URIs to link to + subdomains of the domain you post here: i.e. example.com will allow + sub.example.com. However, higher up domains will still be excluded: + if you set %URI.Host to sub.example.com, example.com will be blocked. + Note: This directive overrides %URI.Base because + a given page may be on a sub-domain, but you wish HTML Purifier to be + more relaxed and allow some of the parent domains too. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt new file mode 100644 index 0000000..0b6df76 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.HostBlacklist.txt @@ -0,0 +1,9 @@ +URI.HostBlacklist +TYPE: list +VERSION: 1.3.0 +DEFAULT: array() +--DESCRIPTION-- +List of strings that are forbidden in the host of any URI. Use it to kill +domain names of spam, etc. Note that it will catch anything in the domain, +so moo.com will catch moo.com.example.com. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MakeAbsolute.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MakeAbsolute.txt new file mode 100644 index 0000000..4214900 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MakeAbsolute.txt @@ -0,0 +1,13 @@ +URI.MakeAbsolute +TYPE: bool +VERSION: 2.1.0 +DEFAULT: false +--DESCRIPTION-- + +

+ Converts all URIs into absolute forms. This is useful when the HTML + being filtered assumes a specific base path, but will actually be + viewed in a different context (and setting an alternate base URI is + not possible). %URI.Base must be set for this directive to work. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt new file mode 100644 index 0000000..58c81dc --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.Munge.txt @@ -0,0 +1,83 @@ +URI.Munge +TYPE: string/null +VERSION: 1.3.0 +DEFAULT: NULL +--DESCRIPTION-- + +

+ Munges all browsable (usually http, https and ftp) + absolute URIs into another URI, usually a URI redirection service. + This directive accepts a URI, formatted with a %s where + the url-encoded original URI should be inserted (sample: + http://www.google.com/url?q=%s). +

+

+ Uses for this directive: +

+
    +
  • + Prevent PageRank leaks, while being fairly transparent + to users (you may also want to add some client side JavaScript to + override the text in the statusbar). Notice: + Many security experts believe that this form of protection does not deter spam-bots. +
  • +
  • + Redirect users to a splash page telling them they are leaving your + website. While this is poor usability practice, it is often mandated + in corporate environments. +
  • +
+

+ Prior to HTML Purifier 3.1.1, this directive also enabled the munging + of browsable external resources, which could break things if your redirection + script was a splash page or used meta tags. To revert to + previous behavior, please use %URI.MungeResources. +

+

+ You may want to also use %URI.MungeSecretKey along with this directive + in order to enforce what URIs your redirector script allows. Open + redirector scripts can be a security risk and negatively affect the + reputation of your domain name. +

+

+ Starting with HTML Purifier 3.1.1, there is also these substitutions: +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeyDescriptionExample <a href="">
%r1 - The URI embeds a resource
(blank) - The URI is merely a link
%nThe name of the tag this URI came froma
%mThe name of the attribute this URI came fromhref
%pThe name of the CSS property this URI came from, or blank if irrelevant
+

+ Admittedly, these letters are somewhat arbitrary; the only stipulation + was that they couldn't be a through f. r is for resource (I would have preferred + e, but you take what you can get), n is for name, m + was picked because it came after n (and I couldn't use a), p is for + property. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MungeResources.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MungeResources.txt new file mode 100644 index 0000000..6fce0fd --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MungeResources.txt @@ -0,0 +1,17 @@ +URI.MungeResources +TYPE: bool +VERSION: 3.1.1 +DEFAULT: false +--DESCRIPTION-- +

+ If true, any URI munging directives like %URI.Munge + will also apply to embedded resources, such as <img src="">. + Be careful enabling this directive if you have a redirector script + that does not use the Location HTTP header; all of your images + and other embedded resources will break. +

+

+ Warning: It is strongly advised you use this in conjunction + %URI.MungeSecretKey to mitigate the security risk of an open redirector. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MungeSecretKey.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MungeSecretKey.txt new file mode 100644 index 0000000..1e17c1d --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.MungeSecretKey.txt @@ -0,0 +1,30 @@ +URI.MungeSecretKey +TYPE: string/null +VERSION: 3.1.1 +DEFAULT: NULL +--DESCRIPTION-- +

+ This directive enables secure checksum generation along with %URI.Munge. + It should be set to a secure key that is not shared with anyone else. + The checksum can be placed in the URI using %t. Use of this checksum + affords an additional level of protection by allowing a redirector + to check if a URI has passed through HTML Purifier with this line: +

+ +
$checksum === hash_hmac("sha256", $url, $secret_key)
+ +

+ If the output is TRUE, the redirector script should accept the URI. +

+ +

+ Please note that it would still be possible for an attacker to procure + secure hashes en-mass by abusing your website's Preview feature or the + like, but this service affords an additional level of protection + that should be combined with website blacklisting. +

+ +

+ Remember this has no effect if %URI.Munge is not on. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.OverrideAllowedSchemes.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.OverrideAllowedSchemes.txt new file mode 100644 index 0000000..23331a4 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.OverrideAllowedSchemes.txt @@ -0,0 +1,9 @@ +URI.OverrideAllowedSchemes +TYPE: bool +DEFAULT: true +--DESCRIPTION-- +If this is set to true (which it is by default), you can override +%URI.AllowedSchemes by simply registering a HTMLPurifier_URIScheme to the +registry. If false, you will also have to update that directive in order +to add more schemes. +--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.SafeIframeRegexp.txt b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.SafeIframeRegexp.txt new file mode 100644 index 0000000..7908483 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/URI.SafeIframeRegexp.txt @@ -0,0 +1,22 @@ +URI.SafeIframeRegexp +TYPE: string/null +VERSION: 4.4.0 +DEFAULT: NULL +--DESCRIPTION-- +

+ A PCRE regular expression that will be matched against an iframe URI. This is + a relatively inflexible scheme, but works well enough for the most common + use-case of iframes: embedded video. This directive only has an effect if + %HTML.SafeIframe is enabled. Here are some example values: +

+
    +
  • %^http://www.youtube.com/embed/% - Allow YouTube videos
  • +
  • %^http://player.vimeo.com/video/% - Allow Vimeo videos
  • +
  • %^http://(www.youtube.com/embed/|player.vimeo.com/video/)% - Allow both
  • +
+

+ Note that this directive does not give you enough granularity to, say, disable + all autoplay videos. Pipe up on the HTML Purifier forums if this + is a capability you want. +

+--# vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/info.ini b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/info.ini new file mode 100644 index 0000000..5de4505 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ConfigSchema/schema/info.ini @@ -0,0 +1,3 @@ +name = "HTML Purifier" + +; vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ContentSets.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ContentSets.php new file mode 100644 index 0000000..543e3f8 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ContentSets.php @@ -0,0 +1,170 @@ + true) indexed by name. + * @type array + * @note This is in HTMLPurifier_HTMLDefinition->info_content_sets + */ + public $lookup = array(); + + /** + * Synchronized list of defined content sets (keys of info). + * @type array + */ + protected $keys = array(); + /** + * Synchronized list of defined content values (values of info). + * @type array + */ + protected $values = array(); + + /** + * Merges in module's content sets, expands identifiers in the content + * sets and populates the keys, values and lookup member variables. + * @param HTMLPurifier_HTMLModule[] $modules List of HTMLPurifier_HTMLModule + */ + public function __construct($modules) + { + if (!is_array($modules)) { + $modules = array($modules); + } + // populate content_sets based on module hints + // sorry, no way of overloading + foreach ($modules as $module) { + foreach ($module->content_sets as $key => $value) { + $temp = $this->convertToLookup($value); + if (isset($this->lookup[$key])) { + // add it into the existing content set + $this->lookup[$key] = array_merge($this->lookup[$key], $temp); + } else { + $this->lookup[$key] = $temp; + } + } + } + $old_lookup = false; + while ($old_lookup !== $this->lookup) { + $old_lookup = $this->lookup; + foreach ($this->lookup as $i => $set) { + $add = array(); + foreach ($set as $element => $x) { + if (isset($this->lookup[$element])) { + $add += $this->lookup[$element]; + unset($this->lookup[$i][$element]); + } + } + $this->lookup[$i] += $add; + } + } + + foreach ($this->lookup as $key => $lookup) { + $this->info[$key] = implode(' | ', array_keys($lookup)); + } + $this->keys = array_keys($this->info); + $this->values = array_values($this->info); + } + + /** + * Accepts a definition; generates and assigns a ChildDef for it + * @param HTMLPurifier_ElementDef $def HTMLPurifier_ElementDef reference + * @param HTMLPurifier_HTMLModule $module Module that defined the ElementDef + */ + public function generateChildDef(&$def, $module) + { + if (!empty($def->child)) { // already done! + return; + } + $content_model = $def->content_model; + if (is_string($content_model)) { + // Assume that $this->keys is alphanumeric + $def->content_model = preg_replace_callback( + '/\b(' . implode('|', $this->keys) . ')\b/', + array($this, 'generateChildDefCallback'), + $content_model + ); + //$def->content_model = str_replace( + // $this->keys, $this->values, $content_model); + } + $def->child = $this->getChildDef($def, $module); + } + + public function generateChildDefCallback($matches) + { + return $this->info[$matches[0]]; + } + + /** + * Instantiates a ChildDef based on content_model and content_model_type + * member variables in HTMLPurifier_ElementDef + * @note This will also defer to modules for custom HTMLPurifier_ChildDef + * subclasses that need content set expansion + * @param HTMLPurifier_ElementDef $def HTMLPurifier_ElementDef to have ChildDef extracted + * @param HTMLPurifier_HTMLModule $module Module that defined the ElementDef + * @return HTMLPurifier_ChildDef corresponding to ElementDef + */ + public function getChildDef($def, $module) + { + $value = $def->content_model; + if (is_object($value)) { + trigger_error( + 'Literal object child definitions should be stored in '. + 'ElementDef->child not ElementDef->content_model', + E_USER_NOTICE + ); + return $value; + } + switch ($def->content_model_type) { + case 'required': + return new HTMLPurifier_ChildDef_Required($value); + case 'optional': + return new HTMLPurifier_ChildDef_Optional($value); + case 'empty': + return new HTMLPurifier_ChildDef_Empty(); + case 'custom': + return new HTMLPurifier_ChildDef_Custom($value); + } + // defer to its module + $return = false; + if ($module->defines_child_def) { // save a func call + $return = $module->getChildDef($def); + } + if ($return !== false) { + return $return; + } + // error-out + trigger_error( + 'Could not determine which ChildDef class to instantiate', + E_USER_ERROR + ); + return false; + } + + /** + * Converts a string list of elements separated by pipes into + * a lookup array. + * @param string $string List of elements + * @return array Lookup array of elements + */ + protected function convertToLookup($string) + { + $array = explode('|', str_replace(' ', '', $string)); + $ret = array(); + foreach ($array as $k) { + $ret[$k] = true; + } + return $ret; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Context.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Context.php new file mode 100644 index 0000000..00e509c --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Context.php @@ -0,0 +1,95 @@ +_storage)) { + trigger_error( + "Name $name produces collision, cannot re-register", + E_USER_ERROR + ); + return; + } + $this->_storage[$name] =& $ref; + } + + /** + * Retrieves a variable reference from the context. + * @param string $name String name + * @param bool $ignore_error Boolean whether or not to ignore error + * @return mixed + */ + public function &get($name, $ignore_error = false) + { + if (!array_key_exists($name, $this->_storage)) { + if (!$ignore_error) { + trigger_error( + "Attempted to retrieve non-existent variable $name", + E_USER_ERROR + ); + } + $var = null; // so we can return by reference + return $var; + } + return $this->_storage[$name]; + } + + /** + * Destroys a variable in the context. + * @param string $name String name + */ + public function destroy($name) + { + if (!array_key_exists($name, $this->_storage)) { + trigger_error( + "Attempted to destroy non-existent variable $name", + E_USER_ERROR + ); + return; + } + unset($this->_storage[$name]); + } + + /** + * Checks whether or not the variable exists. + * @param string $name String name + * @return bool + */ + public function exists($name) + { + return array_key_exists($name, $this->_storage); + } + + /** + * Loads a series of variables from an associative array + * @param array $context_array Assoc array of variables to load + */ + public function loadArray($context_array) + { + foreach ($context_array as $key => $discard) { + $this->register($key, $context_array[$key]); + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Definition.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Definition.php new file mode 100644 index 0000000..bc6d433 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Definition.php @@ -0,0 +1,55 @@ +setup) { + return; + } + $this->setup = true; + $this->doSetup($config); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache.php new file mode 100644 index 0000000..9aa8ff3 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache.php @@ -0,0 +1,129 @@ +type = $type; + } + + /** + * Generates a unique identifier for a particular configuration + * @param HTMLPurifier_Config $config Instance of HTMLPurifier_Config + * @return string + */ + public function generateKey($config) + { + return $config->version . ',' . // possibly replace with function calls + $config->getBatchSerial($this->type) . ',' . + $config->get($this->type . '.DefinitionRev'); + } + + /** + * Tests whether or not a key is old with respect to the configuration's + * version and revision number. + * @param string $key Key to test + * @param HTMLPurifier_Config $config Instance of HTMLPurifier_Config to test against + * @return bool + */ + public function isOld($key, $config) + { + if (substr_count($key, ',') < 2) { + return true; + } + list($version, $hash, $revision) = explode(',', $key, 3); + $compare = version_compare($version, $config->version); + // version mismatch, is always old + if ($compare != 0) { + return true; + } + // versions match, ids match, check revision number + if ($hash == $config->getBatchSerial($this->type) && + $revision < $config->get($this->type . '.DefinitionRev')) { + return true; + } + return false; + } + + /** + * Checks if a definition's type jives with the cache's type + * @note Throws an error on failure + * @param HTMLPurifier_Definition $def Definition object to check + * @return bool true if good, false if not + */ + public function checkDefType($def) + { + if ($def->type !== $this->type) { + trigger_error("Cannot use definition of type {$def->type} in cache for {$this->type}"); + return false; + } + return true; + } + + /** + * Adds a definition object to the cache + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + */ + abstract public function add($def, $config); + + /** + * Unconditionally saves a definition object to the cache + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + */ + abstract public function set($def, $config); + + /** + * Replace an object in the cache + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + */ + abstract public function replace($def, $config); + + /** + * Retrieves a definition object from the cache + * @param HTMLPurifier_Config $config + */ + abstract public function get($config); + + /** + * Removes a definition object to the cache + * @param HTMLPurifier_Config $config + */ + abstract public function remove($config); + + /** + * Clears all objects from cache + * @param HTMLPurifier_Config $config + */ + abstract public function flush($config); + + /** + * Clears all expired (older version or revision) objects from cache + * @note Be careful implementing this method as flush. Flush must + * not interfere with other Definition types, and cleanup() + * should not be repeatedly called by userland code. + * @param HTMLPurifier_Config $config + */ + abstract public function cleanup($config); +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator.php new file mode 100644 index 0000000..b57a51b --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator.php @@ -0,0 +1,112 @@ +copy(); + // reference is necessary for mocks in PHP 4 + $decorator->cache =& $cache; + $decorator->type = $cache->type; + return $decorator; + } + + /** + * Cross-compatible clone substitute + * @return HTMLPurifier_DefinitionCache_Decorator + */ + public function copy() + { + return new HTMLPurifier_DefinitionCache_Decorator(); + } + + /** + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function add($def, $config) + { + return $this->cache->add($def, $config); + } + + /** + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function set($def, $config) + { + return $this->cache->set($def, $config); + } + + /** + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function replace($def, $config) + { + return $this->cache->replace($def, $config); + } + + /** + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function get($config) + { + return $this->cache->get($config); + } + + /** + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function remove($config) + { + return $this->cache->remove($config); + } + + /** + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function flush($config) + { + return $this->cache->flush($config); + } + + /** + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function cleanup($config) + { + return $this->cache->cleanup($config); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php new file mode 100644 index 0000000..4991777 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Cleanup.php @@ -0,0 +1,78 @@ +definitions[$this->generateKey($config)] = $def; + } + return $status; + } + + /** + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function set($def, $config) + { + $status = parent::set($def, $config); + if ($status) { + $this->definitions[$this->generateKey($config)] = $def; + } + return $status; + } + + /** + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function replace($def, $config) + { + $status = parent::replace($def, $config); + if ($status) { + $this->definitions[$this->generateKey($config)] = $def; + } + return $status; + } + + /** + * @param HTMLPurifier_Config $config + * @return mixed + */ + public function get($config) + { + $key = $this->generateKey($config); + if (isset($this->definitions[$key])) { + return $this->definitions[$key]; + } + $this->definitions[$key] = parent::get($config); + return $this->definitions[$key]; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Template.php.in b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Template.php.in new file mode 100644 index 0000000..b1fec8d --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Decorator/Template.php.in @@ -0,0 +1,82 @@ +checkDefType($def)) { + return; + } + $file = $this->generateFilePath($config); + if (file_exists($file)) { + return false; + } + if (!$this->_prepareDir($config)) { + return false; + } + return $this->_write($file, serialize($def), $config); + } + + /** + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + * @return int|bool + */ + public function set($def, $config) + { + if (!$this->checkDefType($def)) { + return; + } + $file = $this->generateFilePath($config); + if (!$this->_prepareDir($config)) { + return false; + } + return $this->_write($file, serialize($def), $config); + } + + /** + * @param HTMLPurifier_Definition $def + * @param HTMLPurifier_Config $config + * @return int|bool + */ + public function replace($def, $config) + { + if (!$this->checkDefType($def)) { + return; + } + $file = $this->generateFilePath($config); + if (!file_exists($file)) { + return false; + } + if (!$this->_prepareDir($config)) { + return false; + } + return $this->_write($file, serialize($def), $config); + } + + /** + * @param HTMLPurifier_Config $config + * @return bool|HTMLPurifier_Config + */ + public function get($config) + { + $file = $this->generateFilePath($config); + if (!file_exists($file)) { + return false; + } + return unserialize(file_get_contents($file)); + } + + /** + * @param HTMLPurifier_Config $config + * @return bool + */ + public function remove($config) + { + $file = $this->generateFilePath($config); + if (!file_exists($file)) { + return false; + } + return unlink($file); + } + + /** + * @param HTMLPurifier_Config $config + * @return bool + */ + public function flush($config) + { + if (!$this->_prepareDir($config)) { + return false; + } + $dir = $this->generateDirectoryPath($config); + $dh = opendir($dir); + // Apparently, on some versions of PHP, readdir will return + // an empty string if you pass an invalid argument to readdir. + // So you need this test. See #49. + if (false === $dh) { + return false; + } + while (false !== ($filename = readdir($dh))) { + if (empty($filename)) { + continue; + } + if ($filename[0] === '.') { + continue; + } + unlink($dir . '/' . $filename); + } + closedir($dh); + return true; + } + + /** + * @param HTMLPurifier_Config $config + * @return bool + */ + public function cleanup($config) + { + if (!$this->_prepareDir($config)) { + return false; + } + $dir = $this->generateDirectoryPath($config); + $dh = opendir($dir); + // See #49 (and above). + if (false === $dh) { + return false; + } + while (false !== ($filename = readdir($dh))) { + if (empty($filename)) { + continue; + } + if ($filename[0] === '.') { + continue; + } + $key = substr($filename, 0, strlen($filename) - 4); + if ($this->isOld($key, $config)) { + unlink($dir . '/' . $filename); + } + } + closedir($dh); + return true; + } + + /** + * Generates the file path to the serial file corresponding to + * the configuration and definition name + * @param HTMLPurifier_Config $config + * @return string + * @todo Make protected + */ + public function generateFilePath($config) + { + $key = $this->generateKey($config); + return $this->generateDirectoryPath($config) . '/' . $key . '.ser'; + } + + /** + * Generates the path to the directory contain this cache's serial files + * @param HTMLPurifier_Config $config + * @return string + * @note No trailing slash + * @todo Make protected + */ + public function generateDirectoryPath($config) + { + $base = $this->generateBaseDirectoryPath($config); + return $base . '/' . $this->type; + } + + /** + * Generates path to base directory that contains all definition type + * serials + * @param HTMLPurifier_Config $config + * @return mixed|string + * @todo Make protected + */ + public function generateBaseDirectoryPath($config) + { + $base = $config->get('Cache.SerializerPath'); + $base = is_null($base) ? HTMLPURIFIER_PREFIX . '/HTMLPurifier/DefinitionCache/Serializer' : $base; + return $base; + } + + /** + * Convenience wrapper function for file_put_contents + * @param string $file File name to write to + * @param string $data Data to write into file + * @param HTMLPurifier_Config $config + * @return int|bool Number of bytes written if success, or false if failure. + */ + private function _write($file, $data, $config) + { + $result = file_put_contents($file, $data); + if ($result !== false) { + // set permissions of the new file (no execute) + $chmod = $config->get('Cache.SerializerPermissions'); + if ($chmod !== null) { + chmod($file, $chmod & 0666); + } + } + return $result; + } + + /** + * Prepares the directory that this type stores the serials in + * @param HTMLPurifier_Config $config + * @return bool True if successful + */ + private function _prepareDir($config) + { + $directory = $this->generateDirectoryPath($config); + $chmod = $config->get('Cache.SerializerPermissions'); + if ($chmod === null) { + if (!@mkdir($directory) && !is_dir($directory)) { + trigger_error( + 'Could not create directory ' . $directory . '', + E_USER_WARNING + ); + return false; + } + return true; + } + if (!is_dir($directory)) { + $base = $this->generateBaseDirectoryPath($config); + if (!is_dir($base)) { + trigger_error( + 'Base directory ' . $base . ' does not exist, + please create or change using %Cache.SerializerPath', + E_USER_WARNING + ); + return false; + } elseif (!$this->_testPermissions($base, $chmod)) { + return false; + } + if (!@mkdir($directory, $chmod) && !is_dir($directory)) { + trigger_error( + 'Could not create directory ' . $directory . '', + E_USER_WARNING + ); + return false; + } + if (!$this->_testPermissions($directory, $chmod)) { + return false; + } + } elseif (!$this->_testPermissions($directory, $chmod)) { + return false; + } + return true; + } + + /** + * Tests permissions on a directory and throws out friendly + * error messages and attempts to chmod it itself if possible + * @param string $dir Directory path + * @param int $chmod Permissions + * @return bool True if directory is writable + */ + private function _testPermissions($dir, $chmod) + { + // early abort, if it is writable, everything is hunky-dory + if (is_writable($dir)) { + return true; + } + if (!is_dir($dir)) { + // generally, you'll want to handle this beforehand + // so a more specific error message can be given + trigger_error( + 'Directory ' . $dir . ' does not exist', + E_USER_WARNING + ); + return false; + } + if (function_exists('posix_getuid') && $chmod !== null) { + // POSIX system, we can give more specific advice + if (fileowner($dir) === posix_getuid()) { + // we can chmod it ourselves + $chmod = $chmod | 0700; + if (chmod($dir, $chmod)) { + return true; + } + } elseif (filegroup($dir) === posix_getgid()) { + $chmod = $chmod | 0070; + } else { + // PHP's probably running as nobody, it is + // not obvious how to fix this (777 is probably + // bad if you are multi-user), let the user figure it out + $chmod = null; + } + trigger_error( + 'Directory ' . $dir . ' not writable. ' . + ($chmod === null ? '' : 'Please chmod to ' . decoct($chmod)), + E_USER_WARNING + ); + } else { + // generic error message + trigger_error( + 'Directory ' . $dir . ' not writable, ' . + 'please alter file permissions', + E_USER_WARNING + ); + } + return false; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/HTML/4.18.0,f474c0a322b208e83d22d3aef33ecb184bc71d31,1.ser b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/HTML/4.18.0,f474c0a322b208e83d22d3aef33ecb184bc71d31,1.ser new file mode 100644 index 0000000..931f16a Binary files /dev/null and b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/HTML/4.18.0,f474c0a322b208e83d22d3aef33ecb184bc71d31,1.ser differ diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/README b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/README new file mode 100644 index 0000000..2e35c1c --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/README @@ -0,0 +1,3 @@ +This is a dummy file to prevent Git from ignoring this empty directory. + + vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCacheFactory.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCacheFactory.php new file mode 100644 index 0000000..3a0f461 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DefinitionCacheFactory.php @@ -0,0 +1,106 @@ + array()); + + /** + * @type array + */ + protected $implementations = array(); + + /** + * @type HTMLPurifier_DefinitionCache_Decorator[] + */ + protected $decorators = array(); + + /** + * Initialize default decorators + */ + public function setup() + { + $this->addDecorator('Cleanup'); + } + + /** + * Retrieves an instance of global definition cache factory. + * @param HTMLPurifier_DefinitionCacheFactory $prototype + * @return HTMLPurifier_DefinitionCacheFactory + */ + public static function instance($prototype = null) + { + static $instance; + if ($prototype !== null) { + $instance = $prototype; + } elseif ($instance === null || $prototype === true) { + $instance = new HTMLPurifier_DefinitionCacheFactory(); + $instance->setup(); + } + return $instance; + } + + /** + * Registers a new definition cache object + * @param string $short Short name of cache object, for reference + * @param string $long Full class name of cache object, for construction + */ + public function register($short, $long) + { + $this->implementations[$short] = $long; + } + + /** + * Factory method that creates a cache object based on configuration + * @param string $type Name of definitions handled by cache + * @param HTMLPurifier_Config $config Config instance + * @return mixed + */ + public function create($type, $config) + { + $method = $config->get('Cache.DefinitionImpl'); + if ($method === null) { + return new HTMLPurifier_DefinitionCache_Null($type); + } + if (!empty($this->caches[$method][$type])) { + return $this->caches[$method][$type]; + } + if (isset($this->implementations[$method]) && + class_exists($class = $this->implementations[$method])) { + $cache = new $class($type); + } else { + if ($method != 'Serializer') { + trigger_error("Unrecognized DefinitionCache $method, using Serializer instead", E_USER_WARNING); + } + $cache = new HTMLPurifier_DefinitionCache_Serializer($type); + } + foreach ($this->decorators as $decorator) { + $new_cache = $decorator->decorate($cache); + // prevent infinite recursion in PHP 4 + unset($cache); + $cache = $new_cache; + } + $this->caches[$method][$type] = $cache; + return $this->caches[$method][$type]; + } + + /** + * Registers a decorator to add to all new cache objects + * @param HTMLPurifier_DefinitionCache_Decorator|string $decorator An instance or the name of a decorator + */ + public function addDecorator($decorator) + { + if (is_string($decorator)) { + $class = "HTMLPurifier_DefinitionCache_Decorator_$decorator"; + $decorator = new $class; + } + $this->decorators[$decorator->name] = $decorator; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Doctype.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Doctype.php new file mode 100644 index 0000000..4acd06e --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Doctype.php @@ -0,0 +1,73 @@ +renderDoctype. + * If structure changes, please update that function. + */ +class HTMLPurifier_Doctype +{ + /** + * Full name of doctype + * @type string + */ + public $name; + + /** + * List of standard modules (string identifiers or literal objects) + * that this doctype uses + * @type array + */ + public $modules = array(); + + /** + * List of modules to use for tidying up code + * @type array + */ + public $tidyModules = array(); + + /** + * Is the language derived from XML (i.e. XHTML)? + * @type bool + */ + public $xml = true; + + /** + * List of aliases for this doctype + * @type array + */ + public $aliases = array(); + + /** + * Public DTD identifier + * @type string + */ + public $dtdPublic; + + /** + * System DTD identifier + * @type string + */ + public $dtdSystem; + + public function __construct( + $name = null, + $xml = true, + $modules = array(), + $tidyModules = array(), + $aliases = array(), + $dtd_public = null, + $dtd_system = null + ) { + $this->name = $name; + $this->xml = $xml; + $this->modules = $modules; + $this->tidyModules = $tidyModules; + $this->aliases = $aliases; + $this->dtdPublic = $dtd_public; + $this->dtdSystem = $dtd_system; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DoctypeRegistry.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DoctypeRegistry.php new file mode 100644 index 0000000..acc1d64 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/DoctypeRegistry.php @@ -0,0 +1,142 @@ +doctypes[$doctype->name] = $doctype; + $name = $doctype->name; + // hookup aliases + foreach ($doctype->aliases as $alias) { + if (isset($this->doctypes[$alias])) { + continue; + } + $this->aliases[$alias] = $name; + } + // remove old aliases + if (isset($this->aliases[$name])) { + unset($this->aliases[$name]); + } + return $doctype; + } + + /** + * Retrieves reference to a doctype of a certain name + * @note This function resolves aliases + * @note When possible, use the more fully-featured make() + * @param string $doctype Name of doctype + * @return HTMLPurifier_Doctype Editable doctype object + */ + public function get($doctype) + { + if (isset($this->aliases[$doctype])) { + $doctype = $this->aliases[$doctype]; + } + if (!isset($this->doctypes[$doctype])) { + trigger_error('Doctype ' . htmlspecialchars($doctype) . ' does not exist', E_USER_ERROR); + $anon = new HTMLPurifier_Doctype($doctype); + return $anon; + } + return $this->doctypes[$doctype]; + } + + /** + * Creates a doctype based on a configuration object, + * will perform initialization on the doctype + * @note Use this function to get a copy of doctype that config + * can hold on to (this is necessary in order to tell + * Generator whether or not the current document is XML + * based or not). + * @param HTMLPurifier_Config $config + * @return HTMLPurifier_Doctype + */ + public function make($config) + { + return clone $this->get($this->getDoctypeFromConfig($config)); + } + + /** + * Retrieves the doctype from the configuration object + * @param HTMLPurifier_Config $config + * @return string + */ + public function getDoctypeFromConfig($config) + { + // recommended test + $doctype = $config->get('HTML.Doctype'); + if (!empty($doctype)) { + return $doctype; + } + $doctype = $config->get('HTML.CustomDoctype'); + if (!empty($doctype)) { + return $doctype; + } + // backwards-compatibility + if ($config->get('HTML.XHTML')) { + $doctype = 'XHTML 1.0'; + } else { + $doctype = 'HTML 4.01'; + } + if ($config->get('HTML.Strict')) { + $doctype .= ' Strict'; + } else { + $doctype .= ' Transitional'; + } + return $doctype; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ElementDef.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ElementDef.php new file mode 100644 index 0000000..57cfd2b --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ElementDef.php @@ -0,0 +1,216 @@ +setup(), this array may also + * contain an array at index 0 that indicates which attribute + * collections to load into the full array. It may also + * contain string indentifiers in lieu of HTMLPurifier_AttrDef, + * see HTMLPurifier_AttrTypes on how they are expanded during + * HTMLPurifier_HTMLDefinition->setup() processing. + */ + public $attr = array(); + + // XXX: Design note: currently, it's not possible to override + // previously defined AttrTransforms without messing around with + // the final generated config. This is by design; a previous version + // used an associated list of attr_transform, but it was extremely + // easy to accidentally override other attribute transforms by + // forgetting to specify an index (and just using 0.) While we + // could check this by checking the index number and complaining, + // there is a second problem which is that it is not at all easy to + // tell when something is getting overridden. Combine this with a + // codebase where this isn't really being used, and it's perfect for + // nuking. + + /** + * List of tags HTMLPurifier_AttrTransform to be done before validation. + * @type array + */ + public $attr_transform_pre = array(); + + /** + * List of tags HTMLPurifier_AttrTransform to be done after validation. + * @type array + */ + public $attr_transform_post = array(); + + /** + * HTMLPurifier_ChildDef of this tag. + * @type HTMLPurifier_ChildDef + */ + public $child; + + /** + * Abstract string representation of internal ChildDef rules. + * @see HTMLPurifier_ContentSets for how this is parsed and then transformed + * into an HTMLPurifier_ChildDef. + * @warning This is a temporary variable that is not available after + * being processed by HTMLDefinition + * @type string + */ + public $content_model; + + /** + * Value of $child->type, used to determine which ChildDef to use, + * used in combination with $content_model. + * @warning This must be lowercase + * @warning This is a temporary variable that is not available after + * being processed by HTMLDefinition + * @type string + */ + public $content_model_type; + + /** + * Does the element have a content model (#PCDATA | Inline)*? This + * is important for chameleon ins and del processing in + * HTMLPurifier_ChildDef_Chameleon. Dynamically set: modules don't + * have to worry about this one. + * @type bool + */ + public $descendants_are_inline = false; + + /** + * List of the names of required attributes this element has. + * Dynamically populated by HTMLPurifier_HTMLDefinition::getElement() + * @type array + */ + public $required_attr = array(); + + /** + * Lookup table of tags excluded from all descendants of this tag. + * @type array + * @note SGML permits exclusions for all descendants, but this is + * not possible with DTDs or XML Schemas. W3C has elected to + * use complicated compositions of content_models to simulate + * exclusion for children, but we go the simpler, SGML-style + * route of flat-out exclusions, which correctly apply to + * all descendants and not just children. Note that the XHTML + * Modularization Abstract Modules are blithely unaware of such + * distinctions. + */ + public $excludes = array(); + + /** + * This tag is explicitly auto-closed by the following tags. + * @type array + */ + public $autoclose = array(); + + /** + * If a foreign element is found in this element, test if it is + * allowed by this sub-element; if it is, instead of closing the + * current element, place it inside this element. + * @type string + */ + public $wrap; + + /** + * Whether or not this is a formatting element affected by the + * "Active Formatting Elements" algorithm. + * @type bool + */ + public $formatting; + + /** + * Low-level factory constructor for creating new standalone element defs + */ + public static function create($content_model, $content_model_type, $attr) + { + $def = new HTMLPurifier_ElementDef(); + $def->content_model = $content_model; + $def->content_model_type = $content_model_type; + $def->attr = $attr; + return $def; + } + + /** + * Merges the values of another element definition into this one. + * Values from the new element def take precedence if a value is + * not mergeable. + * @param HTMLPurifier_ElementDef $def + */ + public function mergeIn($def) + { + // later keys takes precedence + foreach ($def->attr as $k => $v) { + if ($k === 0) { + // merge in the includes + // sorry, no way to override an include + foreach ($v as $v2) { + $this->attr[0][] = $v2; + } + continue; + } + if ($v === false) { + if (isset($this->attr[$k])) { + unset($this->attr[$k]); + } + continue; + } + $this->attr[$k] = $v; + } + $this->_mergeAssocArray($this->excludes, $def->excludes); + $this->attr_transform_pre = array_merge($this->attr_transform_pre, $def->attr_transform_pre); + $this->attr_transform_post = array_merge($this->attr_transform_post, $def->attr_transform_post); + + if (!empty($def->content_model)) { + $this->content_model = + str_replace("#SUPER", (string)$this->content_model, $def->content_model); + $this->child = false; + } + if (!empty($def->content_model_type)) { + $this->content_model_type = $def->content_model_type; + $this->child = false; + } + if (!is_null($def->child)) { + $this->child = $def->child; + } + if (!is_null($def->formatting)) { + $this->formatting = $def->formatting; + } + if ($def->descendants_are_inline) { + $this->descendants_are_inline = $def->descendants_are_inline; + } + } + + /** + * Merges one array into another, removes values which equal false + * @param $a1 Array by reference that is merged into + * @param $a2 Array that merges into $a1 + */ + private function _mergeAssocArray(&$a1, $a2) + { + foreach ($a2 as $k => $v) { + if ($v === false) { + if (isset($a1[$k])) { + unset($a1[$k]); + } + continue; + } + $a1[$k] = $v; + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Encoder.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Encoder.php new file mode 100644 index 0000000..d4791cc --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Encoder.php @@ -0,0 +1,617 @@ += $c) { + $r .= self::unsafeIconv($in, $out, substr($text, $i)); + break; + } + // wibble the boundary + if (0x80 != (0xC0 & ord($text[$i + $max_chunk_size]))) { + $chunk_size = $max_chunk_size; + } elseif (0x80 != (0xC0 & ord($text[$i + $max_chunk_size - 1]))) { + $chunk_size = $max_chunk_size - 1; + } elseif (0x80 != (0xC0 & ord($text[$i + $max_chunk_size - 2]))) { + $chunk_size = $max_chunk_size - 2; + } elseif (0x80 != (0xC0 & ord($text[$i + $max_chunk_size - 3]))) { + $chunk_size = $max_chunk_size - 3; + } else { + return false; // rather confusing UTF-8... + } + $chunk = substr($text, $i, $chunk_size); // substr doesn't mind overlong lengths + $r .= self::unsafeIconv($in, $out, $chunk); + $i += $chunk_size; + } + return $r; + } else { + return false; + } + } else { + return false; + } + } + + /** + * Cleans a UTF-8 string for well-formedness and SGML validity + * + * It will parse according to UTF-8 and return a valid UTF8 string, with + * non-SGML codepoints excluded. + * + * Specifically, it will permit: + * \x{9}\x{A}\x{D}\x{20}-\x{7E}\x{A0}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF} + * Source: https://www.w3.org/TR/REC-xml/#NT-Char + * Arguably this function should be modernized to the HTML5 set + * of allowed characters: + * https://www.w3.org/TR/html5/syntax.html#preprocessing-the-input-stream + * which simultaneously expand and restrict the set of allowed characters. + * + * @param string $str The string to clean + * @param bool $force_php + * @return string + * + * @note Just for reference, the non-SGML code points are 0 to 31 and + * 127 to 159, inclusive. However, we allow code points 9, 10 + * and 13, which are the tab, line feed and carriage return + * respectively. 128 and above the code points map to multibyte + * UTF-8 representations. + * + * @note Fallback code adapted from utf8ToUnicode by Henri Sivonen and + * hsivonen@iki.fi at under the + * LGPL license. Notes on what changed are inside, but in general, + * the original code transformed UTF-8 text into an array of integer + * Unicode codepoints. Understandably, transforming that back to + * a string would be somewhat expensive, so the function was modded to + * directly operate on the string. However, this discourages code + * reuse, and the logic enumerated here would be useful for any + * function that needs to be able to understand UTF-8 characters. + * As of right now, only smart lossless character encoding converters + * would need that, and I'm probably not going to implement them. + */ + public static function cleanUTF8($str, $force_php = false) + { + // UTF-8 validity is checked since PHP 4.3.5 + // This is an optimization: if the string is already valid UTF-8, no + // need to do PHP stuff. 99% of the time, this will be the case. + if (preg_match( + '/^[\x{9}\x{A}\x{D}\x{20}-\x{7E}\x{A0}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]*$/Du', + $str + )) { + return $str; + } + + $mState = 0; // cached expected number of octets after the current octet + // until the beginning of the next UTF8 character sequence + $mUcs4 = 0; // cached Unicode character + $mBytes = 1; // cached expected number of octets in the current sequence + + // original code involved an $out that was an array of Unicode + // codepoints. Instead of having to convert back into UTF-8, we've + // decided to directly append valid UTF-8 characters onto a string + // $out once they're done. $char accumulates raw bytes, while $mUcs4 + // turns into the Unicode code point, so there's some redundancy. + + $out = ''; + $char = ''; + + $len = strlen($str); + for ($i = 0; $i < $len; $i++) { + $in = ord($str[$i]); + $char .= $str[$i]; // append byte to char + if (0 == $mState) { + // When mState is zero we expect either a US-ASCII character + // or a multi-octet sequence. + if (0 == (0x80 & ($in))) { + // US-ASCII, pass straight through. + if (($in <= 31 || $in == 127) && + !($in == 9 || $in == 13 || $in == 10) // save \r\t\n + ) { + // control characters, remove + } else { + $out .= $char; + } + // reset + $char = ''; + $mBytes = 1; + } elseif (0xC0 == (0xE0 & ($in))) { + // First octet of 2 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x1F) << 6; + $mState = 1; + $mBytes = 2; + } elseif (0xE0 == (0xF0 & ($in))) { + // First octet of 3 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x0F) << 12; + $mState = 2; + $mBytes = 3; + } elseif (0xF0 == (0xF8 & ($in))) { + // First octet of 4 octet sequence + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x07) << 18; + $mState = 3; + $mBytes = 4; + } elseif (0xF8 == (0xFC & ($in))) { + // First octet of 5 octet sequence. + // + // This is illegal because the encoded codepoint must be + // either: + // (a) not the shortest form or + // (b) outside the Unicode range of 0-0x10FFFF. + // Rather than trying to resynchronize, we will carry on + // until the end of the sequence and let the later error + // handling code catch it. + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 0x03) << 24; + $mState = 4; + $mBytes = 5; + } elseif (0xFC == (0xFE & ($in))) { + // First octet of 6 octet sequence, see comments for 5 + // octet sequence. + $mUcs4 = ($in); + $mUcs4 = ($mUcs4 & 1) << 30; + $mState = 5; + $mBytes = 6; + } else { + // Current octet is neither in the US-ASCII range nor a + // legal first octet of a multi-octet sequence. + $mState = 0; + $mUcs4 = 0; + $mBytes = 1; + $char = ''; + } + } else { + // When mState is non-zero, we expect a continuation of the + // multi-octet sequence + if (0x80 == (0xC0 & ($in))) { + // Legal continuation. + $shift = ($mState - 1) * 6; + $tmp = $in; + $tmp = ($tmp & 0x0000003F) << $shift; + $mUcs4 |= $tmp; + + if (0 == --$mState) { + // End of the multi-octet sequence. mUcs4 now contains + // the final Unicode codepoint to be output + + // Check for illegal sequences and codepoints. + + // From Unicode 3.1, non-shortest form is illegal + if (((2 == $mBytes) && ($mUcs4 < 0x0080)) || + ((3 == $mBytes) && ($mUcs4 < 0x0800)) || + ((4 == $mBytes) && ($mUcs4 < 0x10000)) || + (4 < $mBytes) || + // From Unicode 3.2, surrogate characters = illegal + (($mUcs4 & 0xFFFFF800) == 0xD800) || + // Codepoints outside the Unicode range are illegal + ($mUcs4 > 0x10FFFF) + ) { + + } elseif (0xFEFF != $mUcs4 && // omit BOM + // check for valid Char unicode codepoints + ( + 0x9 == $mUcs4 || + 0xA == $mUcs4 || + 0xD == $mUcs4 || + (0x20 <= $mUcs4 && 0x7E >= $mUcs4) || + // 7F-9F is not strictly prohibited by XML, + // but it is non-SGML, and thus we don't allow it + (0xA0 <= $mUcs4 && 0xD7FF >= $mUcs4) || + (0xE000 <= $mUcs4 && 0xFFFD >= $mUcs4) || + (0x10000 <= $mUcs4 && 0x10FFFF >= $mUcs4) + ) + ) { + $out .= $char; + } + // initialize UTF8 cache (reset) + $mState = 0; + $mUcs4 = 0; + $mBytes = 1; + $char = ''; + } + } else { + // ((0xC0 & (*in) != 0x80) && (mState != 0)) + // Incomplete multi-octet sequence. + // used to result in complete fail, but we'll reset + $mState = 0; + $mUcs4 = 0; + $mBytes = 1; + $char =''; + } + } + } + return $out; + } + + /** + * Translates a Unicode codepoint into its corresponding UTF-8 character. + * @note Based on Feyd's function at + * , + * which is in public domain. + * @note While we're going to do code point parsing anyway, a good + * optimization would be to refuse to translate code points that + * are non-SGML characters. However, this could lead to duplication. + * @note This is very similar to the unichr function in + * maintenance/generate-entity-file.php (although this is superior, + * due to its sanity checks). + */ + + // +----------+----------+----------+----------+ + // | 33222222 | 22221111 | 111111 | | + // | 10987654 | 32109876 | 54321098 | 76543210 | bit + // +----------+----------+----------+----------+ + // | | | | 0xxxxxxx | 1 byte 0x00000000..0x0000007F + // | | | 110yyyyy | 10xxxxxx | 2 byte 0x00000080..0x000007FF + // | | 1110zzzz | 10yyyyyy | 10xxxxxx | 3 byte 0x00000800..0x0000FFFF + // | 11110www | 10wwzzzz | 10yyyyyy | 10xxxxxx | 4 byte 0x00010000..0x0010FFFF + // +----------+----------+----------+----------+ + // | 00000000 | 00011111 | 11111111 | 11111111 | Theoretical upper limit of legal scalars: 2097151 (0x001FFFFF) + // | 00000000 | 00010000 | 11111111 | 11111111 | Defined upper limit of legal scalar codes + // +----------+----------+----------+----------+ + + public static function unichr($code) + { + if ($code > 1114111 or $code < 0 or + ($code >= 55296 and $code <= 57343) ) { + // bits are set outside the "valid" range as defined + // by UNICODE 4.1.0 + return ''; + } + + $x = $y = $z = $w = 0; + if ($code < 128) { + // regular ASCII character + $x = $code; + } else { + // set up bits for UTF-8 + $x = ($code & 63) | 128; + if ($code < 2048) { + $y = (($code & 2047) >> 6) | 192; + } else { + $y = (($code & 4032) >> 6) | 128; + if ($code < 65536) { + $z = (($code >> 12) & 15) | 224; + } else { + $z = (($code >> 12) & 63) | 128; + $w = (($code >> 18) & 7) | 240; + } + } + } + // set up the actual character + $ret = ''; + if ($w) { + $ret .= chr($w); + } + if ($z) { + $ret .= chr($z); + } + if ($y) { + $ret .= chr($y); + } + $ret .= chr($x); + + return $ret; + } + + /** + * @return bool + */ + public static function iconvAvailable() + { + static $iconv = null; + if ($iconv === null) { + $iconv = function_exists('iconv') && self::testIconvTruncateBug() != self::ICONV_UNUSABLE; + } + return $iconv; + } + + /** + * Convert a string to UTF-8 based on configuration. + * @param string $str The string to convert + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return string + */ + public static function convertToUTF8($str, $config, $context) + { + $encoding = $config->get('Core.Encoding'); + if ($encoding === 'utf-8') { + return $str; + } + static $iconv = null; + if ($iconv === null) { + $iconv = self::iconvAvailable(); + } + if ($iconv && !$config->get('Test.ForceNoIconv')) { + // unaffected by bugs, since UTF-8 support all characters + $str = self::unsafeIconv($encoding, 'utf-8//IGNORE', $str); + if ($str === false) { + // $encoding is not a valid encoding + trigger_error('Invalid encoding ' . $encoding, E_USER_ERROR); + return ''; + } + // If the string is bjorked by Shift_JIS or a similar encoding + // that doesn't support all of ASCII, convert the naughty + // characters to their true byte-wise ASCII/UTF-8 equivalents. + $str = strtr($str, self::testEncodingSupportsASCII($encoding)); + return $str; + } elseif ($encoding === 'iso-8859-1' && function_exists('mb_convert_encoding')) { + $str = mb_convert_encoding($str, 'UTF-8', 'ISO-8859-1'); + return $str; + } + $bug = HTMLPurifier_Encoder::testIconvTruncateBug(); + if ($bug == self::ICONV_OK) { + trigger_error('Encoding not supported, please install iconv', E_USER_ERROR); + } else { + trigger_error( + 'You have a buggy version of iconv, see https://bugs.php.net/bug.php?id=48147 ' . + 'and http://sourceware.org/bugzilla/show_bug.cgi?id=13541', + E_USER_ERROR + ); + } + } + + /** + * Converts a string from UTF-8 based on configuration. + * @param string $str The string to convert + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return string + * @note Currently, this is a lossy conversion, with unexpressable + * characters being omitted. + */ + public static function convertFromUTF8($str, $config, $context) + { + $encoding = $config->get('Core.Encoding'); + if ($escape = $config->get('Core.EscapeNonASCIICharacters')) { + $str = self::convertToASCIIDumbLossless($str); + } + if ($encoding === 'utf-8') { + return $str; + } + static $iconv = null; + if ($iconv === null) { + $iconv = self::iconvAvailable(); + } + if ($iconv && !$config->get('Test.ForceNoIconv')) { + // Undo our previous fix in convertToUTF8, otherwise iconv will barf + $ascii_fix = self::testEncodingSupportsASCII($encoding); + if (!$escape && !empty($ascii_fix)) { + $clear_fix = array(); + foreach ($ascii_fix as $utf8 => $native) { + $clear_fix[$utf8] = ''; + } + $str = strtr($str, $clear_fix); + } + $str = strtr($str, array_flip($ascii_fix)); + // Normal stuff + $str = self::iconv('utf-8', $encoding . '//IGNORE', $str); + return $str; + } elseif ($encoding === 'iso-8859-1' && function_exists('mb_convert_encoding')) { + $str = mb_convert_encoding($str, 'ISO-8859-1', 'UTF-8'); + return $str; + } + trigger_error('Encoding not supported', E_USER_ERROR); + // You might be tempted to assume that the ASCII representation + // might be OK, however, this is *not* universally true over all + // encodings. So we take the conservative route here, rather + // than forcibly turn on %Core.EscapeNonASCIICharacters + } + + /** + * Lossless (character-wise) conversion of HTML to ASCII + * @param string $str UTF-8 string to be converted to ASCII + * @return string ASCII encoded string with non-ASCII character entity-ized + * @warning Adapted from MediaWiki, claiming fair use: this is a common + * algorithm. If you disagree with this license fudgery, + * implement it yourself. + * @note Uses decimal numeric entities since they are best supported. + * @note This is a DUMB function: it has no concept of keeping + * character entities that the projected character encoding + * can allow. We could possibly implement a smart version + * but that would require it to also know which Unicode + * codepoints the charset supported (not an easy task). + * @note Sort of with cleanUTF8() but it assumes that $str is + * well-formed UTF-8 + */ + public static function convertToASCIIDumbLossless($str) + { + $bytesleft = 0; + $result = ''; + $working = 0; + $len = strlen($str); + for ($i = 0; $i < $len; $i++) { + $bytevalue = ord($str[$i]); + if ($bytevalue <= 0x7F) { //0xxx xxxx + $result .= chr($bytevalue); + $bytesleft = 0; + } elseif ($bytevalue <= 0xBF) { //10xx xxxx + $working = $working << 6; + $working += ($bytevalue & 0x3F); + $bytesleft--; + if ($bytesleft <= 0) { + $result .= "&#" . $working . ";"; + } + } elseif ($bytevalue <= 0xDF) { //110x xxxx + $working = $bytevalue & 0x1F; + $bytesleft = 1; + } elseif ($bytevalue <= 0xEF) { //1110 xxxx + $working = $bytevalue & 0x0F; + $bytesleft = 2; + } else { //1111 0xxx + $working = $bytevalue & 0x07; + $bytesleft = 3; + } + } + return $result; + } + + /** No bugs detected in iconv. */ + const ICONV_OK = 0; + + /** Iconv truncates output if converting from UTF-8 to another + * character set with //IGNORE, and a non-encodable character is found */ + const ICONV_TRUNCATES = 1; + + /** Iconv does not support //IGNORE, making it unusable for + * transcoding purposes */ + const ICONV_UNUSABLE = 2; + + /** + * glibc iconv has a known bug where it doesn't handle the magic + * //IGNORE stanza correctly. In particular, rather than ignore + * characters, it will return an EILSEQ after consuming some number + * of characters, and expect you to restart iconv as if it were + * an E2BIG. Old versions of PHP did not respect the errno, and + * returned the fragment, so as a result you would see iconv + * mysteriously truncating output. We can work around this by + * manually chopping our input into segments of about 8000 + * characters, as long as PHP ignores the error code. If PHP starts + * paying attention to the error code, iconv becomes unusable. + * + * @return int Error code indicating severity of bug. + */ + public static function testIconvTruncateBug() + { + static $code = null; + if ($code === null) { + // better not use iconv, otherwise infinite loop! + $r = self::unsafeIconv('utf-8', 'ascii//IGNORE', "\xCE\xB1" . str_repeat('a', 9000)); + if ($r === false) { + $code = self::ICONV_UNUSABLE; + } elseif (($c = strlen($r)) < 9000) { + $code = self::ICONV_TRUNCATES; + } elseif ($c > 9000) { + trigger_error( + 'Your copy of iconv is extremely buggy. Please notify HTML Purifier maintainers: ' . + 'include your iconv version as per phpversion()', + E_USER_ERROR + ); + } else { + $code = self::ICONV_OK; + } + } + return $code; + } + + /** + * This expensive function tests whether or not a given character + * encoding supports ASCII. 7/8-bit encodings like Shift_JIS will + * fail this test, and require special processing. Variable width + * encodings shouldn't ever fail. + * + * @param string $encoding Encoding name to test, as per iconv format + * @param bool $bypass Whether or not to bypass the precompiled arrays. + * @return Array of UTF-8 characters to their corresponding ASCII, + * which can be used to "undo" any overzealous iconv action. + */ + public static function testEncodingSupportsASCII($encoding, $bypass = false) + { + // All calls to iconv here are unsafe, proof by case analysis: + // If ICONV_OK, no difference. + // If ICONV_TRUNCATE, all calls involve one character inputs, + // so bug is not triggered. + // If ICONV_UNUSABLE, this call is irrelevant + static $encodings = array(); + if (!$bypass) { + if (isset($encodings[$encoding])) { + return $encodings[$encoding]; + } + $lenc = strtolower($encoding); + switch ($lenc) { + case 'shift_jis': + return array("\xC2\xA5" => '\\', "\xE2\x80\xBE" => '~'); + case 'johab': + return array("\xE2\x82\xA9" => '\\'); + } + if (strpos($lenc, 'iso-8859-') === 0) { + return array(); + } + } + $ret = array(); + if (self::unsafeIconv('UTF-8', $encoding, 'a') === false) { + return false; + } + for ($i = 0x20; $i <= 0x7E; $i++) { // all printable ASCII chars + $c = chr($i); // UTF-8 char + $r = self::unsafeIconv('UTF-8', "$encoding//IGNORE", $c); // initial conversion + if ($r === '' || + // This line is needed for iconv implementations that do not + // omit characters that do not exist in the target character set + ($r === $c && self::unsafeIconv($encoding, 'UTF-8//IGNORE', $r) !== $c) + ) { + // Reverse engineer: what's the UTF-8 equiv of this byte + // sequence? This assumes that there's no variable width + // encoding that doesn't support ASCII. + $ret[self::unsafeIconv($encoding, 'UTF-8//IGNORE', $c)] = $c; + } + } + $encodings[$encoding] = $ret; + return $ret; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityLookup.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityLookup.php new file mode 100644 index 0000000..f12ff13 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityLookup.php @@ -0,0 +1,48 @@ +table = unserialize(file_get_contents($file)); + } + + /** + * Retrieves sole instance of the object. + * @param bool|HTMLPurifier_EntityLookup $prototype Optional prototype of custom lookup table to overload with. + * @return HTMLPurifier_EntityLookup + */ + public static function instance($prototype = false) + { + // no references, since PHP doesn't copy unless modified + static $instance = null; + if ($prototype) { + $instance = $prototype; + } elseif (!$instance) { + $instance = new HTMLPurifier_EntityLookup(); + $instance->setup(); + } + return $instance; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityLookup/entities.ser b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityLookup/entities.ser new file mode 100644 index 0000000..e8b0812 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityLookup/entities.ser @@ -0,0 +1 @@ +a:253:{s:4:"fnof";s:2:"ƒ";s:5:"Alpha";s:2:"Α";s:4:"Beta";s:2:"Β";s:5:"Gamma";s:2:"Γ";s:5:"Delta";s:2:"Δ";s:7:"Epsilon";s:2:"Ε";s:4:"Zeta";s:2:"Ζ";s:3:"Eta";s:2:"Η";s:5:"Theta";s:2:"Θ";s:4:"Iota";s:2:"Ι";s:5:"Kappa";s:2:"Κ";s:6:"Lambda";s:2:"Λ";s:2:"Mu";s:2:"Μ";s:2:"Nu";s:2:"Ν";s:2:"Xi";s:2:"Ξ";s:7:"Omicron";s:2:"Ο";s:2:"Pi";s:2:"Π";s:3:"Rho";s:2:"Ρ";s:5:"Sigma";s:2:"Σ";s:3:"Tau";s:2:"Τ";s:7:"Upsilon";s:2:"Υ";s:3:"Phi";s:2:"Φ";s:3:"Chi";s:2:"Χ";s:3:"Psi";s:2:"Ψ";s:5:"Omega";s:2:"Ω";s:5:"alpha";s:2:"α";s:4:"beta";s:2:"β";s:5:"gamma";s:2:"γ";s:5:"delta";s:2:"δ";s:7:"epsilon";s:2:"ε";s:4:"zeta";s:2:"ζ";s:3:"eta";s:2:"η";s:5:"theta";s:2:"θ";s:4:"iota";s:2:"ι";s:5:"kappa";s:2:"κ";s:6:"lambda";s:2:"λ";s:2:"mu";s:2:"μ";s:2:"nu";s:2:"ν";s:2:"xi";s:2:"ξ";s:7:"omicron";s:2:"ο";s:2:"pi";s:2:"π";s:3:"rho";s:2:"ρ";s:6:"sigmaf";s:2:"ς";s:5:"sigma";s:2:"σ";s:3:"tau";s:2:"τ";s:7:"upsilon";s:2:"υ";s:3:"phi";s:2:"φ";s:3:"chi";s:2:"χ";s:3:"psi";s:2:"ψ";s:5:"omega";s:2:"ω";s:8:"thetasym";s:2:"ϑ";s:5:"upsih";s:2:"ϒ";s:3:"piv";s:2:"ϖ";s:4:"bull";s:3:"•";s:6:"hellip";s:3:"…";s:5:"prime";s:3:"′";s:5:"Prime";s:3:"″";s:5:"oline";s:3:"‾";s:5:"frasl";s:3:"⁄";s:6:"weierp";s:3:"℘";s:5:"image";s:3:"ℑ";s:4:"real";s:3:"ℜ";s:5:"trade";s:3:"™";s:7:"alefsym";s:3:"ℵ";s:4:"larr";s:3:"←";s:4:"uarr";s:3:"↑";s:4:"rarr";s:3:"→";s:4:"darr";s:3:"↓";s:4:"harr";s:3:"↔";s:5:"crarr";s:3:"↵";s:4:"lArr";s:3:"⇐";s:4:"uArr";s:3:"⇑";s:4:"rArr";s:3:"⇒";s:4:"dArr";s:3:"⇓";s:4:"hArr";s:3:"⇔";s:6:"forall";s:3:"∀";s:4:"part";s:3:"∂";s:5:"exist";s:3:"∃";s:5:"empty";s:3:"∅";s:5:"nabla";s:3:"∇";s:4:"isin";s:3:"∈";s:5:"notin";s:3:"∉";s:2:"ni";s:3:"∋";s:4:"prod";s:3:"∏";s:3:"sum";s:3:"∑";s:5:"minus";s:3:"−";s:6:"lowast";s:3:"∗";s:5:"radic";s:3:"√";s:4:"prop";s:3:"∝";s:5:"infin";s:3:"∞";s:3:"ang";s:3:"∠";s:3:"and";s:3:"∧";s:2:"or";s:3:"∨";s:3:"cap";s:3:"∩";s:3:"cup";s:3:"∪";s:3:"int";s:3:"∫";s:6:"there4";s:3:"∴";s:3:"sim";s:3:"∼";s:4:"cong";s:3:"≅";s:5:"asymp";s:3:"≈";s:2:"ne";s:3:"≠";s:5:"equiv";s:3:"≡";s:2:"le";s:3:"≤";s:2:"ge";s:3:"≥";s:3:"sub";s:3:"⊂";s:3:"sup";s:3:"⊃";s:4:"nsub";s:3:"⊄";s:4:"sube";s:3:"⊆";s:4:"supe";s:3:"⊇";s:5:"oplus";s:3:"⊕";s:6:"otimes";s:3:"⊗";s:4:"perp";s:3:"⊥";s:4:"sdot";s:3:"⋅";s:5:"lceil";s:3:"⌈";s:5:"rceil";s:3:"⌉";s:6:"lfloor";s:3:"⌊";s:6:"rfloor";s:3:"⌋";s:4:"lang";s:3:"〈";s:4:"rang";s:3:"〉";s:3:"loz";s:3:"◊";s:6:"spades";s:3:"♠";s:5:"clubs";s:3:"♣";s:6:"hearts";s:3:"♥";s:5:"diams";s:3:"♦";s:4:"quot";s:1:""";s:3:"amp";s:1:"&";s:2:"lt";s:1:"<";s:2:"gt";s:1:">";s:4:"apos";s:1:"'";s:5:"OElig";s:2:"Œ";s:5:"oelig";s:2:"œ";s:6:"Scaron";s:2:"Š";s:6:"scaron";s:2:"š";s:4:"Yuml";s:2:"Ÿ";s:4:"circ";s:2:"ˆ";s:5:"tilde";s:2:"˜";s:4:"ensp";s:3:" ";s:4:"emsp";s:3:" ";s:6:"thinsp";s:3:" ";s:4:"zwnj";s:3:"‌";s:3:"zwj";s:3:"‍";s:3:"lrm";s:3:"‎";s:3:"rlm";s:3:"‏";s:5:"ndash";s:3:"–";s:5:"mdash";s:3:"—";s:5:"lsquo";s:3:"‘";s:5:"rsquo";s:3:"’";s:5:"sbquo";s:3:"‚";s:5:"ldquo";s:3:"“";s:5:"rdquo";s:3:"”";s:5:"bdquo";s:3:"„";s:6:"dagger";s:3:"†";s:6:"Dagger";s:3:"‡";s:6:"permil";s:3:"‰";s:6:"lsaquo";s:3:"‹";s:6:"rsaquo";s:3:"›";s:4:"euro";s:3:"€";s:4:"nbsp";s:2:" ";s:5:"iexcl";s:2:"¡";s:4:"cent";s:2:"¢";s:5:"pound";s:2:"£";s:6:"curren";s:2:"¤";s:3:"yen";s:2:"¥";s:6:"brvbar";s:2:"¦";s:4:"sect";s:2:"§";s:3:"uml";s:2:"¨";s:4:"copy";s:2:"©";s:4:"ordf";s:2:"ª";s:5:"laquo";s:2:"«";s:3:"not";s:2:"¬";s:3:"shy";s:2:"­";s:3:"reg";s:2:"®";s:4:"macr";s:2:"¯";s:3:"deg";s:2:"°";s:6:"plusmn";s:2:"±";s:4:"sup2";s:2:"²";s:4:"sup3";s:2:"³";s:5:"acute";s:2:"´";s:5:"micro";s:2:"µ";s:4:"para";s:2:"¶";s:6:"middot";s:2:"·";s:5:"cedil";s:2:"¸";s:4:"sup1";s:2:"¹";s:4:"ordm";s:2:"º";s:5:"raquo";s:2:"»";s:6:"frac14";s:2:"¼";s:6:"frac12";s:2:"½";s:6:"frac34";s:2:"¾";s:6:"iquest";s:2:"¿";s:6:"Agrave";s:2:"À";s:6:"Aacute";s:2:"Á";s:5:"Acirc";s:2:"Â";s:6:"Atilde";s:2:"Ã";s:4:"Auml";s:2:"Ä";s:5:"Aring";s:2:"Å";s:5:"AElig";s:2:"Æ";s:6:"Ccedil";s:2:"Ç";s:6:"Egrave";s:2:"È";s:6:"Eacute";s:2:"É";s:5:"Ecirc";s:2:"Ê";s:4:"Euml";s:2:"Ë";s:6:"Igrave";s:2:"Ì";s:6:"Iacute";s:2:"Í";s:5:"Icirc";s:2:"Î";s:4:"Iuml";s:2:"Ï";s:3:"ETH";s:2:"Ð";s:6:"Ntilde";s:2:"Ñ";s:6:"Ograve";s:2:"Ò";s:6:"Oacute";s:2:"Ó";s:5:"Ocirc";s:2:"Ô";s:6:"Otilde";s:2:"Õ";s:4:"Ouml";s:2:"Ö";s:5:"times";s:2:"×";s:6:"Oslash";s:2:"Ø";s:6:"Ugrave";s:2:"Ù";s:6:"Uacute";s:2:"Ú";s:5:"Ucirc";s:2:"Û";s:4:"Uuml";s:2:"Ü";s:6:"Yacute";s:2:"Ý";s:5:"THORN";s:2:"Þ";s:5:"szlig";s:2:"ß";s:6:"agrave";s:2:"à";s:6:"aacute";s:2:"á";s:5:"acirc";s:2:"â";s:6:"atilde";s:2:"ã";s:4:"auml";s:2:"ä";s:5:"aring";s:2:"å";s:5:"aelig";s:2:"æ";s:6:"ccedil";s:2:"ç";s:6:"egrave";s:2:"è";s:6:"eacute";s:2:"é";s:5:"ecirc";s:2:"ê";s:4:"euml";s:2:"ë";s:6:"igrave";s:2:"ì";s:6:"iacute";s:2:"í";s:5:"icirc";s:2:"î";s:4:"iuml";s:2:"ï";s:3:"eth";s:2:"ð";s:6:"ntilde";s:2:"ñ";s:6:"ograve";s:2:"ò";s:6:"oacute";s:2:"ó";s:5:"ocirc";s:2:"ô";s:6:"otilde";s:2:"õ";s:4:"ouml";s:2:"ö";s:6:"divide";s:2:"÷";s:6:"oslash";s:2:"ø";s:6:"ugrave";s:2:"ù";s:6:"uacute";s:2:"ú";s:5:"ucirc";s:2:"û";s:4:"uuml";s:2:"ü";s:6:"yacute";s:2:"ý";s:5:"thorn";s:2:"þ";s:4:"yuml";s:2:"ÿ";} \ No newline at end of file diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityParser.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityParser.php new file mode 100644 index 0000000..0f2b83d --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/EntityParser.php @@ -0,0 +1,285 @@ +_semiOptionalPrefixRegex = "/&()()()($semi_optional)/"; + + $this->_textEntitiesRegex = + '/&(?:'. + // hex + '[#]x([a-fA-F0-9]+);?|'. + // dec + '[#]0*(\d+);?|'. + // string (mandatory semicolon) + // NB: order matters: match semicolon preferentially + '([A-Za-z_:][A-Za-z0-9.\-_:]*);|'. + // string (optional semicolon) + "($semi_optional)". + ')/'; + + $this->_attrEntitiesRegex = + '/&(?:'. + // hex + '[#]x([a-fA-F0-9]+);?|'. + // dec + '[#]0*(\d+);?|'. + // string (mandatory semicolon) + // NB: order matters: match semicolon preferentially + '([A-Za-z_:][A-Za-z0-9.\-_:]*);|'. + // string (optional semicolon) + // don't match if trailing is equals or alphanumeric (URL + // like) + "($semi_optional)(?![=;A-Za-z0-9])". + ')/'; + + } + + /** + * Substitute entities with the parsed equivalents. Use this on + * textual data in an HTML document (as opposed to attributes.) + * + * @param string $string String to have entities parsed. + * @return string Parsed string. + */ + public function substituteTextEntities($string) + { + return preg_replace_callback( + $this->_textEntitiesRegex, + array($this, 'entityCallback'), + $string + ); + } + + /** + * Substitute entities with the parsed equivalents. Use this on + * attribute contents in documents. + * + * @param string $string String to have entities parsed. + * @return string Parsed string. + */ + public function substituteAttrEntities($string) + { + return preg_replace_callback( + $this->_attrEntitiesRegex, + array($this, 'entityCallback'), + $string + ); + } + + /** + * Callback function for substituteNonSpecialEntities() that does the work. + * + * @param array $matches PCRE matches array, with 0 the entire match, and + * either index 1, 2 or 3 set with a hex value, dec value, + * or string (respectively). + * @return string Replacement string. + */ + + protected function entityCallback($matches) + { + $entity = $matches[0]; + $hex_part = isset($matches[1]) ? $matches[1] : null; + $dec_part = isset($matches[2]) ? $matches[2] : null; + $named_part = empty($matches[3]) ? (empty($matches[4]) ? "" : $matches[4]) : $matches[3]; + if ($hex_part !== NULL && $hex_part !== "") { + return HTMLPurifier_Encoder::unichr(hexdec($hex_part)); + } elseif ($dec_part !== NULL && $dec_part !== "") { + return HTMLPurifier_Encoder::unichr((int) $dec_part); + } else { + if (!$this->_entity_lookup) { + $this->_entity_lookup = HTMLPurifier_EntityLookup::instance(); + } + if (isset($this->_entity_lookup->table[$named_part])) { + return $this->_entity_lookup->table[$named_part]; + } else { + // exact match didn't match anything, so test if + // any of the semicolon optional match the prefix. + // Test that this is an EXACT match is important to + // prevent infinite loop + if (!empty($matches[3])) { + return preg_replace_callback( + $this->_semiOptionalPrefixRegex, + array($this, 'entityCallback'), + $entity + ); + } + return $entity; + } + } + } + + // LEGACY CODE BELOW + + /** + * Callback regex string for parsing entities. + * @type string + */ + protected $_substituteEntitiesRegex = + '/&(?:[#]x([a-fA-F0-9]+)|[#]0*(\d+)|([A-Za-z_:][A-Za-z0-9.\-_:]*));?/'; + // 1. hex 2. dec 3. string (XML style) + + /** + * Decimal to parsed string conversion table for special entities. + * @type array + */ + protected $_special_dec2str = + array( + 34 => '"', + 38 => '&', + 39 => "'", + 60 => '<', + 62 => '>' + ); + + /** + * Stripped entity names to decimal conversion table for special entities. + * @type array + */ + protected $_special_ent2dec = + array( + 'quot' => 34, + 'amp' => 38, + 'lt' => 60, + 'gt' => 62 + ); + + /** + * Substitutes non-special entities with their parsed equivalents. Since + * running this whenever you have parsed character is t3h 5uck, we run + * it before everything else. + * + * @param string $string String to have non-special entities parsed. + * @return string Parsed string. + */ + public function substituteNonSpecialEntities($string) + { + // it will try to detect missing semicolons, but don't rely on it + return preg_replace_callback( + $this->_substituteEntitiesRegex, + array($this, 'nonSpecialEntityCallback'), + $string + ); + } + + /** + * Callback function for substituteNonSpecialEntities() that does the work. + * + * @param array $matches PCRE matches array, with 0 the entire match, and + * either index 1, 2 or 3 set with a hex value, dec value, + * or string (respectively). + * @return string Replacement string. + */ + + protected function nonSpecialEntityCallback($matches) + { + // replaces all but big five + $entity = $matches[0]; + $is_num = (@$matches[0][1] === '#'); + if ($is_num) { + $is_hex = (@$entity[2] === 'x'); + $code = $is_hex ? hexdec($matches[1]) : (int) $matches[2]; + // abort for special characters + if (isset($this->_special_dec2str[$code])) { + return $entity; + } + return HTMLPurifier_Encoder::unichr($code); + } else { + if (isset($this->_special_ent2dec[$matches[3]])) { + return $entity; + } + if (!$this->_entity_lookup) { + $this->_entity_lookup = HTMLPurifier_EntityLookup::instance(); + } + if (isset($this->_entity_lookup->table[$matches[3]])) { + return $this->_entity_lookup->table[$matches[3]]; + } else { + return $entity; + } + } + } + + /** + * Substitutes only special entities with their parsed equivalents. + * + * @notice We try to avoid calling this function because otherwise, it + * would have to be called a lot (for every parsed section). + * + * @param string $string String to have non-special entities parsed. + * @return string Parsed string. + */ + public function substituteSpecialEntities($string) + { + return preg_replace_callback( + $this->_substituteEntitiesRegex, + array($this, 'specialEntityCallback'), + $string + ); + } + + /** + * Callback function for substituteSpecialEntities() that does the work. + * + * This callback has same syntax as nonSpecialEntityCallback(). + * + * @param array $matches PCRE-style matches array, with 0 the entire match, and + * either index 1, 2 or 3 set with a hex value, dec value, + * or string (respectively). + * @return string Replacement string. + */ + protected function specialEntityCallback($matches) + { + $entity = $matches[0]; + $is_num = (@$matches[0][1] === '#'); + if ($is_num) { + $is_hex = (@$entity[2] === 'x'); + $int = $is_hex ? hexdec($matches[1]) : (int) $matches[2]; + return isset($this->_special_dec2str[$int]) ? + $this->_special_dec2str[$int] : + $entity; + } else { + return isset($this->_special_ent2dec[$matches[3]]) ? + $this->_special_dec2str[$this->_special_ent2dec[$matches[3]]] : + $entity; + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorCollector.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorCollector.php new file mode 100644 index 0000000..d47e3f2 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorCollector.php @@ -0,0 +1,244 @@ +locale =& $context->get('Locale'); + $this->context = $context; + $this->_current =& $this->_stacks[0]; + $this->errors =& $this->_stacks[0]; + } + + /** + * Sends an error message to the collector for later use + * @param int $severity Error severity, PHP error style (don't use E_USER_) + * @param string $msg Error message text + */ + public function send($severity, $msg) + { + $args = array(); + if (func_num_args() > 2) { + $args = func_get_args(); + array_shift($args); + unset($args[0]); + } + + $token = $this->context->get('CurrentToken', true); + $line = $token ? $token->line : $this->context->get('CurrentLine', true); + $col = $token ? $token->col : $this->context->get('CurrentCol', true); + $attr = $this->context->get('CurrentAttr', true); + + // perform special substitutions, also add custom parameters + $subst = array(); + if (!is_null($token)) { + $args['CurrentToken'] = $token; + } + if (!is_null($attr)) { + $subst['$CurrentAttr.Name'] = $attr; + if (isset($token->attr[$attr])) { + $subst['$CurrentAttr.Value'] = $token->attr[$attr]; + } + } + + if (empty($args)) { + $msg = $this->locale->getMessage($msg); + } else { + $msg = $this->locale->formatMessage($msg, $args); + } + + if (!empty($subst)) { + $msg = strtr($msg, $subst); + } + + // (numerically indexed) + $error = array( + self::LINENO => $line, + self::SEVERITY => $severity, + self::MESSAGE => $msg, + self::CHILDREN => array() + ); + $this->_current[] = $error; + + // NEW CODE BELOW ... + // Top-level errors are either: + // TOKEN type, if $value is set appropriately, or + // "syntax" type, if $value is null + $new_struct = new HTMLPurifier_ErrorStruct(); + $new_struct->type = HTMLPurifier_ErrorStruct::TOKEN; + if ($token) { + $new_struct->value = clone $token; + } + if (is_int($line) && is_int($col)) { + if (isset($this->lines[$line][$col])) { + $struct = $this->lines[$line][$col]; + } else { + $struct = $this->lines[$line][$col] = $new_struct; + } + // These ksorts may present a performance problem + ksort($this->lines[$line], SORT_NUMERIC); + } else { + if (isset($this->lines[-1])) { + $struct = $this->lines[-1]; + } else { + $struct = $this->lines[-1] = $new_struct; + } + } + ksort($this->lines, SORT_NUMERIC); + + // Now, check if we need to operate on a lower structure + if (!empty($attr)) { + $struct = $struct->getChild(HTMLPurifier_ErrorStruct::ATTR, $attr); + if (!$struct->value) { + $struct->value = array($attr, 'PUT VALUE HERE'); + } + } + if (!empty($cssprop)) { + $struct = $struct->getChild(HTMLPurifier_ErrorStruct::CSSPROP, $cssprop); + if (!$struct->value) { + // if we tokenize CSS this might be a little more difficult to do + $struct->value = array($cssprop, 'PUT VALUE HERE'); + } + } + + // Ok, structs are all setup, now time to register the error + $struct->addError($severity, $msg); + } + + /** + * Retrieves raw error data for custom formatter to use + */ + public function getRaw() + { + return $this->errors; + } + + /** + * Default HTML formatting implementation for error messages + * @param HTMLPurifier_Config $config Configuration, vital for HTML output nature + * @param array $errors Errors array to display; used for recursion. + * @return string + */ + public function getHTMLFormatted($config, $errors = null) + { + $ret = array(); + + $this->generator = new HTMLPurifier_Generator($config, $this->context); + if ($errors === null) { + $errors = $this->errors; + } + + // 'At line' message needs to be removed + + // generation code for new structure goes here. It needs to be recursive. + foreach ($this->lines as $line => $col_array) { + if ($line == -1) { + continue; + } + foreach ($col_array as $col => $struct) { + $this->_renderStruct($ret, $struct, $line, $col); + } + } + if (isset($this->lines[-1])) { + $this->_renderStruct($ret, $this->lines[-1]); + } + + if (empty($errors)) { + return '

' . $this->locale->getMessage('ErrorCollector: No errors') . '

'; + } else { + return '
  • ' . implode('
  • ', $ret) . '
'; + } + + } + + private function _renderStruct(&$ret, $struct, $line = null, $col = null) + { + $stack = array($struct); + $context_stack = array(array()); + while ($current = array_pop($stack)) { + $context = array_pop($context_stack); + foreach ($current->errors as $error) { + list($severity, $msg) = $error; + $string = ''; + $string .= '
'; + // W3C uses an icon to indicate the severity of the error. + $error = $this->locale->getErrorName($severity); + $string .= "$error "; + if (!is_null($line) && !is_null($col)) { + $string .= "Line $line, Column $col: "; + } else { + $string .= 'End of Document: '; + } + $string .= '' . $this->generator->escape($msg) . ' '; + $string .= '
'; + // Here, have a marker for the character on the column appropriate. + // Be sure to clip extremely long lines. + //$string .= '
';
+                //$string .= '';
+                //$string .= '
'; + $ret[] = $string; + } + foreach ($current->children as $array) { + $context[] = $current; + $stack = array_merge($stack, array_reverse($array, true)); + for ($i = count($array); $i > 0; $i--) { + $context_stack[] = $context; + } + } + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorStruct.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorStruct.php new file mode 100644 index 0000000..cf869d3 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/ErrorStruct.php @@ -0,0 +1,74 @@ +children[$type][$id])) { + $this->children[$type][$id] = new HTMLPurifier_ErrorStruct(); + $this->children[$type][$id]->type = $type; + } + return $this->children[$type][$id]; + } + + /** + * @param int $severity + * @param string $message + */ + public function addError($severity, $message) + { + $this->errors[] = array($severity, $message); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Exception.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Exception.php new file mode 100644 index 0000000..be85b4c --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Exception.php @@ -0,0 +1,12 @@ +preFilter, + * 2->preFilter, 3->preFilter, purify, 3->postFilter, 2->postFilter, + * 1->postFilter. + * + * @note Methods are not declared abstract as it is perfectly legitimate + * for an implementation not to want anything to happen on a step + */ + +class HTMLPurifier_Filter +{ + + /** + * Name of the filter for identification purposes. + * @type string + */ + public $name; + + /** + * Pre-processor function, handles HTML before HTML Purifier + * @param string $html + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return string + */ + public function preFilter($html, $config, $context) + { + return $html; + } + + /** + * Post-processor function, handles HTML after HTML Purifier + * @param string $html + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return string + */ + public function postFilter($html, $config, $context) + { + return $html; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter/ExtractStyleBlocks.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter/ExtractStyleBlocks.php new file mode 100644 index 0000000..e7e3cac --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter/ExtractStyleBlocks.php @@ -0,0 +1,362 @@ + blocks from input HTML, cleans them up + * using CSSTidy, and then places them in $purifier->context->get('StyleBlocks') + * so they can be used elsewhere in the document. + * + * @note + * See tests/HTMLPurifier/Filter/ExtractStyleBlocksTest.php for + * sample usage. + * + * @note + * This filter can also be used on stylesheets not included in the + * document--something purists would probably prefer. Just directly + * call HTMLPurifier_Filter_ExtractStyleBlocks->cleanCSS() + */ +class HTMLPurifier_Filter_ExtractStyleBlocks extends HTMLPurifier_Filter +{ + /** + * @type string + */ + public $name = 'ExtractStyleBlocks'; + + /** + * @type array + */ + private $_styleMatches = array(); + + /** + * @type csstidy + */ + private $_tidy; + + /** + * @type HTMLPurifier_AttrDef_HTML_ID + */ + private $_id_attrdef; + + /** + * @type HTMLPurifier_AttrDef_CSS_Ident + */ + private $_class_attrdef; + + /** + * @type HTMLPurifier_AttrDef_Enum + */ + private $_enum_attrdef; + + /** + * @type HTMLPurifier_AttrDef_Enum + */ + private $_universal_attrdef; + + public function __construct() + { + $this->_tidy = new csstidy(); + $this->_tidy->set_cfg('lowercase_s', false); + $this->_id_attrdef = new HTMLPurifier_AttrDef_HTML_ID(true); + $this->_class_attrdef = new HTMLPurifier_AttrDef_CSS_Ident(); + $this->_enum_attrdef = new HTMLPurifier_AttrDef_Enum( + array( + 'first-child', + 'link', + 'visited', + 'active', + 'hover', + 'focus' + ) + ); + $this->_universal_attrdef = new HTMLPurifier_AttrDef_Enum( + array( + 'initial', + 'inherit', + 'unset', + ) + ); + } + + /** + * Save the contents of CSS blocks to style matches + * @param array $matches preg_replace style $matches array + */ + protected function styleCallback($matches) + { + $this->_styleMatches[] = $matches[1]; + } + + /** + * Removes inline + // we must not grab foo in a font-family prop). + if ($config->get('Filter.ExtractStyleBlocks.Escaping')) { + $css = str_replace( + array('<', '>', '&'), + array('\3C ', '\3E ', '\26 '), + $css + ); + } + return $css; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter/YouTube.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter/YouTube.php new file mode 100644 index 0000000..276d836 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Filter/YouTube.php @@ -0,0 +1,65 @@ +]+>.+?' . + '(?:http:)?//www.youtube.com/((?:v|cp)/[A-Za-z0-9\-_=]+).+?#s'; + $pre_replace = '\1'; + return preg_replace($pre_regex, $pre_replace, $html); + } + + /** + * @param string $html + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return string + */ + public function postFilter($html, $config, $context) + { + $post_regex = '#((?:v|cp)/[A-Za-z0-9\-_=]+)#'; + return preg_replace_callback($post_regex, array($this, 'postFilterCallback'), $html); + } + + /** + * @param $url + * @return string + */ + protected function armorUrl($url) + { + return str_replace('--', '--', $url); + } + + /** + * @param array $matches + * @return string + */ + protected function postFilterCallback($matches) + { + $url = $this->armorUrl($matches[1]); + return '' . + '' . + '' . + ''; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Generator.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Generator.php new file mode 100644 index 0000000..eb56e2d --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Generator.php @@ -0,0 +1,286 @@ + tags. + * @type bool + */ + private $_scriptFix = false; + + /** + * Cache of HTMLDefinition during HTML output to determine whether or + * not attributes should be minimized. + * @type HTMLPurifier_HTMLDefinition + */ + private $_def; + + /** + * Cache of %Output.SortAttr. + * @type bool + */ + private $_sortAttr; + + /** + * Cache of %Output.FlashCompat. + * @type bool + */ + private $_flashCompat; + + /** + * Cache of %Output.FixInnerHTML. + * @type bool + */ + private $_innerHTMLFix; + + /** + * Stack for keeping track of object information when outputting IE + * compatibility code. + * @type array + */ + private $_flashStack = array(); + + /** + * Configuration for the generator + * @type HTMLPurifier_Config + */ + protected $config; + + /** + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + */ + public function __construct($config, $context) + { + $this->config = $config; + $this->_scriptFix = $config->get('Output.CommentScriptContents'); + $this->_innerHTMLFix = $config->get('Output.FixInnerHTML'); + $this->_sortAttr = $config->get('Output.SortAttr'); + $this->_flashCompat = $config->get('Output.FlashCompat'); + $this->_def = $config->getHTMLDefinition(); + $this->_xhtml = $this->_def->doctype->xml; + } + + /** + * Generates HTML from an array of tokens. + * @param HTMLPurifier_Token[] $tokens Array of HTMLPurifier_Token + * @return string Generated HTML + */ + public function generateFromTokens($tokens) + { + if (!$tokens) { + return ''; + } + + // Basic algorithm + $html = ''; + for ($i = 0, $size = count($tokens); $i < $size; $i++) { + if ($this->_scriptFix && $tokens[$i]->name === 'script' + && $i + 2 < $size && $tokens[$i+2] instanceof HTMLPurifier_Token_End) { + // script special case + // the contents of the script block must be ONE token + // for this to work. + $html .= $this->generateFromToken($tokens[$i++]); + $html .= $this->generateScriptFromToken($tokens[$i++]); + } + $html .= $this->generateFromToken($tokens[$i]); + } + + // Tidy cleanup + if (extension_loaded('tidy') && $this->config->get('Output.TidyFormat')) { + $tidy = new Tidy; + $tidy->parseString( + $html, + array( + 'indent'=> true, + 'output-xhtml' => $this->_xhtml, + 'show-body-only' => true, + 'indent-spaces' => 2, + 'wrap' => 68, + ), + 'utf8' + ); + $tidy->cleanRepair(); + $html = (string) $tidy; // explicit cast necessary + } + + // Normalize newlines to system defined value + if ($this->config->get('Core.NormalizeNewlines')) { + $nl = $this->config->get('Output.Newline'); + if ($nl === null) { + $nl = PHP_EOL; + } + if ($nl !== "\n") { + $html = str_replace("\n", $nl, $html); + } + } + return $html; + } + + /** + * Generates HTML from a single token. + * @param HTMLPurifier_Token $token HTMLPurifier_Token object. + * @return string Generated HTML + */ + public function generateFromToken($token) + { + if (!$token instanceof HTMLPurifier_Token) { + trigger_error('Cannot generate HTML from non-HTMLPurifier_Token object', E_USER_WARNING); + return ''; + + } elseif ($token instanceof HTMLPurifier_Token_Start) { + $attr = $this->generateAttributes($token->attr, $token->name); + if ($this->_flashCompat) { + if ($token->name == "object") { + $flash = new stdClass(); + $flash->attr = $token->attr; + $flash->param = array(); + $this->_flashStack[] = $flash; + } + } + return '<' . $token->name . ($attr ? ' ' : '') . $attr . '>'; + + } elseif ($token instanceof HTMLPurifier_Token_End) { + $_extra = ''; + if ($this->_flashCompat) { + if ($token->name == "object" && !empty($this->_flashStack)) { + // doesn't do anything for now + } + } + return $_extra . 'name . '>'; + + } elseif ($token instanceof HTMLPurifier_Token_Empty) { + if ($this->_flashCompat && $token->name == "param" && !empty($this->_flashStack)) { + $this->_flashStack[count($this->_flashStack)-1]->param[$token->attr['name']] = $token->attr['value']; + } + $attr = $this->generateAttributes($token->attr, $token->name); + return '<' . $token->name . ($attr ? ' ' : '') . $attr . + ( $this->_xhtml ? ' /': '' ) //
v.
+ . '>'; + + } elseif ($token instanceof HTMLPurifier_Token_Text) { + return $this->escape($token->data, ENT_NOQUOTES); + + } elseif ($token instanceof HTMLPurifier_Token_Comment) { + return ''; + } else { + return ''; + + } + } + + /** + * Special case processor for the contents of script tags + * @param HTMLPurifier_Token $token HTMLPurifier_Token object. + * @return string + * @warning This runs into problems if there's already a literal + * --> somewhere inside the script contents. + */ + public function generateScriptFromToken($token) + { + if (!$token instanceof HTMLPurifier_Token_Text) { + return $this->generateFromToken($token); + } + // Thanks + $data = preg_replace('#//\s*$#', '', $token->data); + return ''; + } + + /** + * Generates attribute declarations from attribute array. + * @note This does not include the leading or trailing space. + * @param array $assoc_array_of_attributes Attribute array + * @param string $element Name of element attributes are for, used to check + * attribute minimization. + * @return string Generated HTML fragment for insertion. + */ + public function generateAttributes($assoc_array_of_attributes, $element = '') + { + $html = ''; + if ($this->_sortAttr) { + ksort($assoc_array_of_attributes); + } + foreach ($assoc_array_of_attributes as $key => $value) { + if (!$this->_xhtml) { + // Remove namespaced attributes + if (strpos($key, ':') !== false) { + continue; + } + // Check if we should minimize the attribute: val="val" -> val + if ($element && !empty($this->_def->info[$element]->attr[$key]->minimized)) { + $html .= $key . ' '; + continue; + } + } + // Workaround for Internet Explorer innerHTML bug. + // Essentially, Internet Explorer, when calculating + // innerHTML, omits quotes if there are no instances of + // angled brackets, quotes or spaces. However, when parsing + // HTML (for example, when you assign to innerHTML), it + // treats backticks as quotes. Thus, + // `` + // becomes + // `` + // becomes + // + // Fortunately, all we need to do is trigger an appropriate + // quoting style, which we do by adding an extra space. + // This also is consistent with the W3C spec, which states + // that user agents may ignore leading or trailing + // whitespace (in fact, most don't, at least for attributes + // like alt, but an extra space at the end is barely + // noticeable). Still, we have a configuration knob for + // this, since this transformation is not necesary if you + // don't process user input with innerHTML or you don't plan + // on supporting Internet Explorer. + if ($this->_innerHTMLFix) { + if (strpos($value, '`') !== false) { + // check if correct quoting style would not already be + // triggered + if (strcspn($value, '"\' <>') === strlen($value)) { + // protect! + $value .= ' '; + } + } + } + $html .= $key.'="'.$this->escape($value).'" '; + } + return rtrim($html); + } + + /** + * Escapes raw text data. + * @todo This really ought to be protected, but until we have a facility + * for properly generating HTML here w/o using tokens, it stays + * public. + * @param string $string String data to escape for HTML. + * @param int $quote Quoting style, like htmlspecialchars. ENT_NOQUOTES is + * permissible for non-attribute output. + * @return string escaped data. + */ + public function escape($string, $quote = null) + { + // Workaround for APC bug on Mac Leopard reported by sidepodcast + // http://htmlpurifier.org/phorum/read.php?3,4823,4846 + if ($quote === null) { + $quote = ENT_COMPAT; + } + return htmlspecialchars($string, $quote, 'UTF-8'); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLDefinition.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLDefinition.php new file mode 100644 index 0000000..9b7b334 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLDefinition.php @@ -0,0 +1,493 @@ +getAnonymousModule(); + if (!isset($module->info[$element_name])) { + $element = $module->addBlankElement($element_name); + } else { + $element = $module->info[$element_name]; + } + $element->attr[$attr_name] = $def; + } + + /** + * Adds a custom element to your HTML definition + * @see HTMLPurifier_HTMLModule::addElement() for detailed + * parameter and return value descriptions. + */ + public function addElement($element_name, $type, $contents, $attr_collections, $attributes = array()) + { + $module = $this->getAnonymousModule(); + // assume that if the user is calling this, the element + // is safe. This may not be a good idea + $element = $module->addElement($element_name, $type, $contents, $attr_collections, $attributes); + return $element; + } + + /** + * Adds a blank element to your HTML definition, for overriding + * existing behavior + * @param string $element_name + * @return HTMLPurifier_ElementDef + * @see HTMLPurifier_HTMLModule::addBlankElement() for detailed + * parameter and return value descriptions. + */ + public function addBlankElement($element_name) + { + $module = $this->getAnonymousModule(); + $element = $module->addBlankElement($element_name); + return $element; + } + + /** + * Retrieves a reference to the anonymous module, so you can + * bust out advanced features without having to make your own + * module. + * @return HTMLPurifier_HTMLModule + */ + public function getAnonymousModule() + { + if (!$this->_anonModule) { + $this->_anonModule = new HTMLPurifier_HTMLModule(); + $this->_anonModule->name = 'Anonymous'; + } + return $this->_anonModule; + } + + private $_anonModule = null; + + // PUBLIC BUT INTERNAL VARIABLES -------------------------------------- + + /** + * @type string + */ + public $type = 'HTML'; + + /** + * @type HTMLPurifier_HTMLModuleManager + */ + public $manager; + + /** + * Performs low-cost, preliminary initialization. + */ + public function __construct() + { + $this->manager = new HTMLPurifier_HTMLModuleManager(); + } + + /** + * @param HTMLPurifier_Config $config + */ + protected function doSetup($config) + { + $this->processModules($config); + $this->setupConfigStuff($config); + unset($this->manager); + + // cleanup some of the element definitions + foreach ($this->info as $k => $v) { + unset($this->info[$k]->content_model); + unset($this->info[$k]->content_model_type); + } + } + + /** + * Extract out the information from the manager + * @param HTMLPurifier_Config $config + */ + protected function processModules($config) + { + if ($this->_anonModule) { + // for user specific changes + // this is late-loaded so we don't have to deal with PHP4 + // reference wonky-ness + $this->manager->addModule($this->_anonModule); + unset($this->_anonModule); + } + + $this->manager->setup($config); + $this->doctype = $this->manager->doctype; + + foreach ($this->manager->modules as $module) { + foreach ($module->info_tag_transform as $k => $v) { + if ($v === false) { + unset($this->info_tag_transform[$k]); + } else { + $this->info_tag_transform[$k] = $v; + } + } + foreach ($module->info_attr_transform_pre as $k => $v) { + if ($v === false) { + unset($this->info_attr_transform_pre[$k]); + } else { + $this->info_attr_transform_pre[$k] = $v; + } + } + foreach ($module->info_attr_transform_post as $k => $v) { + if ($v === false) { + unset($this->info_attr_transform_post[$k]); + } else { + $this->info_attr_transform_post[$k] = $v; + } + } + foreach ($module->info_injector as $k => $v) { + if ($v === false) { + unset($this->info_injector[$k]); + } else { + $this->info_injector[$k] = $v; + } + } + } + $this->info = $this->manager->getElements(); + $this->info_content_sets = $this->manager->contentSets->lookup; + } + + /** + * Sets up stuff based on config. We need a better way of doing this. + * @param HTMLPurifier_Config $config + */ + protected function setupConfigStuff($config) + { + $block_wrapper = $config->get('HTML.BlockWrapper'); + if (isset($this->info_content_sets['Block'][$block_wrapper])) { + $this->info_block_wrapper = $block_wrapper; + } else { + trigger_error( + 'Cannot use non-block element as block wrapper', + E_USER_ERROR + ); + } + + $parent = $config->get('HTML.Parent'); + $def = $this->manager->getElement($parent, true); + if ($def) { + $this->info_parent = $parent; + $this->info_parent_def = $def; + } else { + trigger_error( + 'Cannot use unrecognized element as parent', + E_USER_ERROR + ); + $this->info_parent_def = $this->manager->getElement($this->info_parent, true); + } + + // support template text + $support = "(for information on implementing this, see the support forums) "; + + // setup allowed elements ----------------------------------------- + + $allowed_elements = $config->get('HTML.AllowedElements'); + $allowed_attributes = $config->get('HTML.AllowedAttributes'); // retrieve early + + if (!is_array($allowed_elements) && !is_array($allowed_attributes)) { + $allowed = $config->get('HTML.Allowed'); + if (is_string($allowed)) { + list($allowed_elements, $allowed_attributes) = $this->parseTinyMCEAllowedList($allowed); + } + } + + if (is_array($allowed_elements)) { + foreach ($this->info as $name => $d) { + if (!isset($allowed_elements[$name])) { + unset($this->info[$name]); + } + unset($allowed_elements[$name]); + } + // emit errors + foreach ($allowed_elements as $element => $d) { + $element = htmlspecialchars($element); // PHP doesn't escape errors, be careful! + trigger_error("Element '$element' is not supported $support", E_USER_WARNING); + } + } + + // setup allowed attributes --------------------------------------- + + $allowed_attributes_mutable = $allowed_attributes; // by copy! + if (is_array($allowed_attributes)) { + // This actually doesn't do anything, since we went away from + // global attributes. It's possible that userland code uses + // it, but HTMLModuleManager doesn't! + foreach ($this->info_global_attr as $attr => $x) { + $keys = array($attr, "*@$attr", "*.$attr"); + $delete = true; + foreach ($keys as $key) { + if ($delete && isset($allowed_attributes[$key])) { + $delete = false; + } + if (isset($allowed_attributes_mutable[$key])) { + unset($allowed_attributes_mutable[$key]); + } + } + if ($delete) { + unset($this->info_global_attr[$attr]); + } + } + + foreach ($this->info as $tag => $info) { + foreach ($info->attr as $attr => $x) { + $keys = array("$tag@$attr", $attr, "*@$attr", "$tag.$attr", "*.$attr"); + $delete = true; + foreach ($keys as $key) { + if ($delete && isset($allowed_attributes[$key])) { + $delete = false; + } + if (isset($allowed_attributes_mutable[$key])) { + unset($allowed_attributes_mutable[$key]); + } + } + if ($delete) { + if ($this->info[$tag]->attr[$attr]->required) { + trigger_error( + "Required attribute '$attr' in element '$tag' " . + "was not allowed, which means '$tag' will not be allowed either", + E_USER_WARNING + ); + } + unset($this->info[$tag]->attr[$attr]); + } + } + } + // emit errors + foreach ($allowed_attributes_mutable as $elattr => $d) { + $bits = preg_split('/[.@]/', $elattr, 2); + $c = count($bits); + switch ($c) { + case 2: + if ($bits[0] !== '*') { + $element = htmlspecialchars($bits[0]); + $attribute = htmlspecialchars($bits[1]); + if (!isset($this->info[$element])) { + trigger_error( + "Cannot allow attribute '$attribute' if element " . + "'$element' is not allowed/supported $support" + ); + } else { + trigger_error( + "Attribute '$attribute' in element '$element' not supported $support", + E_USER_WARNING + ); + } + break; + } + // otherwise fall through + case 1: + $attribute = htmlspecialchars($bits[0]); + trigger_error( + "Global attribute '$attribute' is not ". + "supported in any elements $support", + E_USER_WARNING + ); + break; + } + } + } + + // setup forbidden elements --------------------------------------- + + $forbidden_elements = $config->get('HTML.ForbiddenElements'); + $forbidden_attributes = $config->get('HTML.ForbiddenAttributes'); + + foreach ($this->info as $tag => $info) { + if (isset($forbidden_elements[$tag])) { + unset($this->info[$tag]); + continue; + } + foreach ($info->attr as $attr => $x) { + if (isset($forbidden_attributes["$tag@$attr"]) || + isset($forbidden_attributes["*@$attr"]) || + isset($forbidden_attributes[$attr]) + ) { + unset($this->info[$tag]->attr[$attr]); + continue; + } elseif (isset($forbidden_attributes["$tag.$attr"])) { // this segment might get removed eventually + // $tag.$attr are not user supplied, so no worries! + trigger_error( + "Error with $tag.$attr: tag.attr syntax not supported for " . + "HTML.ForbiddenAttributes; use tag@attr instead", + E_USER_WARNING + ); + } + } + } + foreach ($forbidden_attributes as $key => $v) { + if (strlen($key) < 2) { + continue; + } + if ($key[0] != '*') { + continue; + } + if ($key[1] == '.') { + trigger_error( + "Error with $key: *.attr syntax not supported for HTML.ForbiddenAttributes; use attr instead", + E_USER_WARNING + ); + } + } + + // setup injectors ----------------------------------------------------- + foreach ($this->info_injector as $i => $injector) { + if ($injector->checkNeeded($config) !== false) { + // remove injector that does not have it's required + // elements/attributes present, and is thus not needed. + unset($this->info_injector[$i]); + } + } + } + + /** + * Parses a TinyMCE-flavored Allowed Elements and Attributes list into + * separate lists for processing. Format is element[attr1|attr2],element2... + * @warning Although it's largely drawn from TinyMCE's implementation, + * it is different, and you'll probably have to modify your lists + * @param array $list String list to parse + * @return array + * @todo Give this its own class, probably static interface + */ + public function parseTinyMCEAllowedList($list) + { + $list = str_replace(array(' ', "\t"), '', $list); + + $elements = array(); + $attributes = array(); + + $chunks = preg_split('/(,|[\n\r]+)/', $list); + foreach ($chunks as $chunk) { + if (empty($chunk)) { + continue; + } + // remove TinyMCE element control characters + if (!strpos($chunk, '[')) { + $element = $chunk; + $attr = false; + } else { + list($element, $attr) = explode('[', $chunk); + } + if ($element !== '*') { + $elements[$element] = true; + } + if (!$attr) { + continue; + } + $attr = substr($attr, 0, strlen($attr) - 1); // remove trailing ] + $attr = explode('|', $attr); + foreach ($attr as $key) { + $attributes["$element.$key"] = true; + } + } + return array($elements, $attributes); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule.php new file mode 100644 index 0000000..9dbb987 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule.php @@ -0,0 +1,285 @@ +info, since the object's data is only info, + * with extra behavior associated with it. + * @type array + */ + public $attr_collections = array(); + + /** + * Associative array of deprecated tag name to HTMLPurifier_TagTransform. + * @type array + */ + public $info_tag_transform = array(); + + /** + * List of HTMLPurifier_AttrTransform to be performed before validation. + * @type array + */ + public $info_attr_transform_pre = array(); + + /** + * List of HTMLPurifier_AttrTransform to be performed after validation. + * @type array + */ + public $info_attr_transform_post = array(); + + /** + * List of HTMLPurifier_Injector to be performed during well-formedness fixing. + * An injector will only be invoked if all of it's pre-requisites are met; + * if an injector fails setup, there will be no error; it will simply be + * silently disabled. + * @type array + */ + public $info_injector = array(); + + /** + * Boolean flag that indicates whether or not getChildDef is implemented. + * For optimization reasons: may save a call to a function. Be sure + * to set it if you do implement getChildDef(), otherwise it will have + * no effect! + * @type bool + */ + public $defines_child_def = false; + + /** + * Boolean flag whether or not this module is safe. If it is not safe, all + * of its members are unsafe. Modules are safe by default (this might be + * slightly dangerous, but it doesn't make much sense to force HTML Purifier, + * which is based off of safe HTML, to explicitly say, "This is safe," even + * though there are modules which are "unsafe") + * + * @type bool + * @note Previously, safety could be applied at an element level granularity. + * We've removed this ability, so in order to add "unsafe" elements + * or attributes, a dedicated module with this property set to false + * must be used. + */ + public $safe = true; + + /** + * Retrieves a proper HTMLPurifier_ChildDef subclass based on + * content_model and content_model_type member variables of + * the HTMLPurifier_ElementDef class. There is a similar function + * in HTMLPurifier_HTMLDefinition. + * @param HTMLPurifier_ElementDef $def + * @return HTMLPurifier_ChildDef subclass + */ + public function getChildDef($def) + { + return false; + } + + // -- Convenience ----------------------------------------------------- + + /** + * Convenience function that sets up a new element + * @param string $element Name of element to add + * @param string|bool $type What content set should element be registered to? + * Set as false to skip this step. + * @param string|HTMLPurifier_ChildDef $contents Allowed children in form of: + * "$content_model_type: $content_model" + * @param array|string $attr_includes What attribute collections to register to + * element? + * @param array $attr What unique attributes does the element define? + * @see HTMLPurifier_ElementDef:: for in-depth descriptions of these parameters. + * @return HTMLPurifier_ElementDef Created element definition object, so you + * can set advanced parameters + */ + public function addElement($element, $type, $contents, $attr_includes = array(), $attr = array()) + { + $this->elements[] = $element; + // parse content_model + list($content_model_type, $content_model) = $this->parseContents($contents); + // merge in attribute inclusions + $this->mergeInAttrIncludes($attr, $attr_includes); + // add element to content sets + if ($type) { + $this->addElementToContentSet($element, $type); + } + // create element + $this->info[$element] = HTMLPurifier_ElementDef::create( + $content_model, + $content_model_type, + $attr + ); + // literal object $contents means direct child manipulation + if (!is_string($contents)) { + $this->info[$element]->child = $contents; + } + return $this->info[$element]; + } + + /** + * Convenience function that creates a totally blank, non-standalone + * element. + * @param string $element Name of element to create + * @return HTMLPurifier_ElementDef Created element + */ + public function addBlankElement($element) + { + if (!isset($this->info[$element])) { + $this->elements[] = $element; + $this->info[$element] = new HTMLPurifier_ElementDef(); + $this->info[$element]->standalone = false; + } else { + trigger_error("Definition for $element already exists in module, cannot redefine"); + } + return $this->info[$element]; + } + + /** + * Convenience function that registers an element to a content set + * @param string $element Element to register + * @param string $type Name content set (warning: case sensitive, usually upper-case + * first letter) + */ + public function addElementToContentSet($element, $type) + { + if (!isset($this->content_sets[$type])) { + $this->content_sets[$type] = ''; + } else { + $this->content_sets[$type] .= ' | '; + } + $this->content_sets[$type] .= $element; + } + + /** + * Convenience function that transforms single-string contents + * into separate content model and content model type + * @param string $contents Allowed children in form of: + * "$content_model_type: $content_model" + * @return array + * @note If contents is an object, an array of two nulls will be + * returned, and the callee needs to take the original $contents + * and use it directly. + */ + public function parseContents($contents) + { + if (!is_string($contents)) { + return array(null, null); + } // defer + switch ($contents) { + // check for shorthand content model forms + case 'Empty': + return array('empty', ''); + case 'Inline': + return array('optional', 'Inline | #PCDATA'); + case 'Flow': + return array('optional', 'Flow | #PCDATA'); + } + list($content_model_type, $content_model) = explode(':', $contents); + $content_model_type = strtolower(trim($content_model_type)); + $content_model = trim($content_model); + return array($content_model_type, $content_model); + } + + /** + * Convenience function that merges a list of attribute includes into + * an attribute array. + * @param array $attr Reference to attr array to modify + * @param array $attr_includes Array of includes / string include to merge in + */ + public function mergeInAttrIncludes(&$attr, $attr_includes) + { + if (!is_array($attr_includes)) { + if (empty($attr_includes)) { + $attr_includes = array(); + } else { + $attr_includes = array($attr_includes); + } + } + $attr[0] = $attr_includes; + } + + /** + * Convenience function that generates a lookup table with boolean + * true as value. + * @param string $list List of values to turn into a lookup + * @note You can also pass an arbitrary number of arguments in + * place of the regular argument + * @return array array equivalent of list + */ + public function makeLookup($list) + { + $args = func_get_args(); + if (is_string($list)) { + $list = $args; + } + $ret = array(); + foreach ($list as $value) { + if (is_null($value)) { + continue; + } + $ret[$value] = true; + } + return $ret; + } + + /** + * Lazy load construction of the module after determining whether + * or not it's needed, and also when a finalized configuration object + * is available. + * @param HTMLPurifier_Config $config + */ + public function setup($config) + { + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Bdo.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Bdo.php new file mode 100644 index 0000000..1e67c79 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Bdo.php @@ -0,0 +1,44 @@ + array('dir' => false) + ); + + /** + * @param HTMLPurifier_Config $config + */ + public function setup($config) + { + $bdo = $this->addElement( + 'bdo', + 'Inline', + 'Inline', + array('Core', 'Lang'), + array( + 'dir' => 'Enum#ltr,rtl', // required + // The Abstract Module specification has the attribute + // inclusions wrong for bdo: bdo allows Lang + ) + ); + $bdo->attr_transform_post[] = new HTMLPurifier_AttrTransform_BdoDir(); + + $this->attr_collections['I18N']['dir'] = 'Enum#ltr,rtl'; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/CommonAttributes.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/CommonAttributes.php new file mode 100644 index 0000000..7220c14 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/CommonAttributes.php @@ -0,0 +1,32 @@ + array( + 0 => array('Style'), + // 'xml:space' => false, + 'class' => 'Class', + 'id' => 'ID', + 'title' => 'CDATA', + 'contenteditable' => 'ContentEditable', + ), + 'Lang' => array(), + 'I18N' => array( + 0 => array('Lang'), // proprietary, for xml:lang/lang + ), + 'Common' => array( + 0 => array('Core', 'I18N') + ) + ); +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Edit.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Edit.php new file mode 100644 index 0000000..a9042a3 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Edit.php @@ -0,0 +1,55 @@ + 'URI', + // 'datetime' => 'Datetime', // not implemented + ); + $this->addElement('del', 'Inline', $contents, 'Common', $attr); + $this->addElement('ins', 'Inline', $contents, 'Common', $attr); + } + + // HTML 4.01 specifies that ins/del must not contain block + // elements when used in an inline context, chameleon is + // a complicated workaround to acheive this effect + + // Inline context ! Block context (exclamation mark is + // separator, see getChildDef for parsing) + + /** + * @type bool + */ + public $defines_child_def = true; + + /** + * @param HTMLPurifier_ElementDef $def + * @return HTMLPurifier_ChildDef_Chameleon + */ + public function getChildDef($def) + { + if ($def->content_model_type != 'chameleon') { + return false; + } + $value = explode('!', $def->content_model); + return new HTMLPurifier_ChildDef_Chameleon($value[0], $value[1]); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Forms.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Forms.php new file mode 100644 index 0000000..eb0edcf --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Forms.php @@ -0,0 +1,194 @@ + 'Form', + 'Inline' => 'Formctrl', + ); + + /** + * @param HTMLPurifier_Config $config + */ + public function setup($config) + { + if ($config->get('HTML.Forms')) { + $this->safe = true; + } + + $form = $this->addElement( + 'form', + 'Form', + 'Required: Heading | List | Block | fieldset', + 'Common', + array( + 'accept' => 'ContentTypes', + 'accept-charset' => 'Charsets', + 'action*' => 'URI', + 'method' => 'Enum#get,post', + // really ContentType, but these two are the only ones used today + 'enctype' => 'Enum#application/x-www-form-urlencoded,multipart/form-data', + ) + ); + $form->excludes = array('form' => true); + + $input = $this->addElement( + 'input', + 'Formctrl', + 'Empty', + 'Common', + array( + 'accept' => 'ContentTypes', + 'accesskey' => 'Character', + 'alt' => 'Text', + 'checked' => 'Bool#checked', + 'disabled' => 'Bool#disabled', + 'maxlength' => 'Number', + 'name' => 'CDATA', + 'readonly' => 'Bool#readonly', + 'size' => 'Number', + 'src' => 'URI#embedded', + 'tabindex' => 'Number', + 'type' => 'Enum#text,password,checkbox,button,radio,submit,reset,file,hidden,image', + 'value' => 'CDATA', + ) + ); + $input->attr_transform_post[] = new HTMLPurifier_AttrTransform_Input(); + + $this->addElement( + 'select', + 'Formctrl', + 'Required: optgroup | option', + 'Common', + array( + 'disabled' => 'Bool#disabled', + 'multiple' => 'Bool#multiple', + 'name' => 'CDATA', + 'size' => 'Number', + 'tabindex' => 'Number', + ) + ); + + $this->addElement( + 'option', + false, + 'Optional: #PCDATA', + 'Common', + array( + 'disabled' => 'Bool#disabled', + 'label' => 'Text', + 'selected' => 'Bool#selected', + 'value' => 'CDATA', + ) + ); + // It's illegal for there to be more than one selected, but not + // be multiple. Also, no selected means undefined behavior. This might + // be difficult to implement; perhaps an injector, or a context variable. + + $textarea = $this->addElement( + 'textarea', + 'Formctrl', + 'Optional: #PCDATA', + 'Common', + array( + 'accesskey' => 'Character', + 'cols*' => 'Number', + 'disabled' => 'Bool#disabled', + 'name' => 'CDATA', + 'readonly' => 'Bool#readonly', + 'rows*' => 'Number', + 'tabindex' => 'Number', + ) + ); + $textarea->attr_transform_pre[] = new HTMLPurifier_AttrTransform_Textarea(); + + $button = $this->addElement( + 'button', + 'Formctrl', + 'Optional: #PCDATA | Heading | List | Block | Inline', + 'Common', + array( + 'accesskey' => 'Character', + 'disabled' => 'Bool#disabled', + 'name' => 'CDATA', + 'tabindex' => 'Number', + 'type' => 'Enum#button,submit,reset', + 'value' => 'CDATA', + ) + ); + + // For exclusions, ideally we'd specify content sets, not literal elements + $button->excludes = $this->makeLookup( + 'form', + 'fieldset', // Form + 'input', + 'select', + 'textarea', + 'label', + 'button', // Formctrl + 'a', // as per HTML 4.01 spec, this is omitted by modularization + 'isindex', + 'iframe' // legacy items + ); + + // Extra exclusion: img usemap="" is not permitted within this element. + // We'll omit this for now, since we don't have any good way of + // indicating it yet. + + // This is HIGHLY user-unfriendly; we need a custom child-def for this + $this->addElement('fieldset', 'Form', 'Custom: (#WS?,legend,(Flow|#PCDATA)*)', 'Common'); + + $label = $this->addElement( + 'label', + 'Formctrl', + 'Optional: #PCDATA | Inline', + 'Common', + array( + 'accesskey' => 'Character', + // 'for' => 'IDREF', // IDREF not implemented, cannot allow + ) + ); + $label->excludes = array('label' => true); + + $this->addElement( + 'legend', + false, + 'Optional: #PCDATA | Inline', + 'Common', + array( + 'accesskey' => 'Character', + ) + ); + + $this->addElement( + 'optgroup', + false, + 'Required: option', + 'Common', + array( + 'disabled' => 'Bool#disabled', + 'label*' => 'Text', + ) + ); + // Don't forget an injector for . This one's a little complex + // because it maps to multiple elements. + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Hypertext.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Hypertext.php new file mode 100644 index 0000000..72d7a31 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Hypertext.php @@ -0,0 +1,40 @@ +addElement( + 'a', + 'Inline', + 'Inline', + 'Common', + array( + // 'accesskey' => 'Character', + // 'charset' => 'Charset', + 'href' => 'URI', + // 'hreflang' => 'LanguageCode', + 'rel' => new HTMLPurifier_AttrDef_HTML_LinkTypes('rel'), + 'rev' => new HTMLPurifier_AttrDef_HTML_LinkTypes('rev'), + // 'tabindex' => 'Number', + // 'type' => 'ContentType', + ) + ); + $a->formatting = true; + $a->excludes = array('a' => true); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Iframe.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Iframe.php new file mode 100644 index 0000000..71dfc77 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Iframe.php @@ -0,0 +1,57 @@ +get('HTML.SafeIframe')) { + $this->safe = true; + } + $attrs = array( + 'src' => 'URI#embedded', + 'width' => 'Length', + 'height' => 'Length', + 'name' => 'ID', + 'scrolling' => 'Enum#yes,no,auto', + 'frameborder' => 'Enum#0,1', + 'longdesc' => 'URI', + 'marginheight' => 'Pixels', + 'marginwidth' => 'Pixels', + ); + + if ($config->get('HTML.Trusted')) { + $attrs['allowfullscreen'] = 'Bool#allowfullscreen'; + } + + $this->addElement( + 'iframe', + 'Inline', + 'Flow', + 'Common', + $attrs + ); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Image.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Image.php new file mode 100644 index 0000000..0f5fdb3 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Image.php @@ -0,0 +1,49 @@ +get('HTML.MaxImgLength'); + $img = $this->addElement( + 'img', + 'Inline', + 'Empty', + 'Common', + array( + 'alt*' => 'Text', + // According to the spec, it's Length, but percents can + // be abused, so we allow only Pixels. + 'height' => 'Pixels#' . $max, + 'width' => 'Pixels#' . $max, + 'longdesc' => 'URI', + 'src*' => new HTMLPurifier_AttrDef_URI(true), // embedded + ) + ); + if ($max === null || $config->get('HTML.Trusted')) { + $img->attr['height'] = + $img->attr['width'] = 'Length'; + } + + // kind of strange, but splitting things up would be inefficient + $img->attr_transform_pre[] = + $img->attr_transform_post[] = + new HTMLPurifier_AttrTransform_ImgRequired(); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Legacy.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Legacy.php new file mode 100644 index 0000000..86b5299 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Legacy.php @@ -0,0 +1,186 @@ +addElement( + 'basefont', + 'Inline', + 'Empty', + null, + array( + 'color' => 'Color', + 'face' => 'Text', // extremely broad, we should + 'size' => 'Text', // tighten it + 'id' => 'ID' + ) + ); + $this->addElement('center', 'Block', 'Flow', 'Common'); + $this->addElement( + 'dir', + 'Block', + 'Required: li', + 'Common', + array( + 'compact' => 'Bool#compact' + ) + ); + $this->addElement( + 'font', + 'Inline', + 'Inline', + array('Core', 'I18N'), + array( + 'color' => 'Color', + 'face' => 'Text', // extremely broad, we should + 'size' => 'Text', // tighten it + ) + ); + $this->addElement( + 'menu', + 'Block', + 'Required: li', + 'Common', + array( + 'compact' => 'Bool#compact' + ) + ); + + $s = $this->addElement('s', 'Inline', 'Inline', 'Common'); + $s->formatting = true; + + $strike = $this->addElement('strike', 'Inline', 'Inline', 'Common'); + $strike->formatting = true; + + $u = $this->addElement('u', 'Inline', 'Inline', 'Common'); + $u->formatting = true; + + // setup modifications to old elements + + $align = 'Enum#left,right,center,justify'; + + $address = $this->addBlankElement('address'); + $address->content_model = 'Inline | #PCDATA | p'; + $address->content_model_type = 'optional'; + $address->child = false; + + $blockquote = $this->addBlankElement('blockquote'); + $blockquote->content_model = 'Flow | #PCDATA'; + $blockquote->content_model_type = 'optional'; + $blockquote->child = false; + + $br = $this->addBlankElement('br'); + $br->attr['clear'] = 'Enum#left,all,right,none'; + + $caption = $this->addBlankElement('caption'); + $caption->attr['align'] = 'Enum#top,bottom,left,right'; + + $div = $this->addBlankElement('div'); + $div->attr['align'] = $align; + + $dl = $this->addBlankElement('dl'); + $dl->attr['compact'] = 'Bool#compact'; + + for ($i = 1; $i <= 6; $i++) { + $h = $this->addBlankElement("h$i"); + $h->attr['align'] = $align; + } + + $hr = $this->addBlankElement('hr'); + $hr->attr['align'] = $align; + $hr->attr['noshade'] = 'Bool#noshade'; + $hr->attr['size'] = 'Pixels'; + $hr->attr['width'] = 'Length'; + + $img = $this->addBlankElement('img'); + $img->attr['align'] = 'IAlign'; + $img->attr['border'] = 'Pixels'; + $img->attr['hspace'] = 'Pixels'; + $img->attr['vspace'] = 'Pixels'; + + // figure out this integer business + + $li = $this->addBlankElement('li'); + $li->attr['value'] = new HTMLPurifier_AttrDef_Integer(); + $li->attr['type'] = 'Enum#s:1,i,I,a,A,disc,square,circle'; + + $ol = $this->addBlankElement('ol'); + $ol->attr['compact'] = 'Bool#compact'; + $ol->attr['start'] = new HTMLPurifier_AttrDef_Integer(); + $ol->attr['type'] = 'Enum#s:1,i,I,a,A'; + + $p = $this->addBlankElement('p'); + $p->attr['align'] = $align; + + $pre = $this->addBlankElement('pre'); + $pre->attr['width'] = 'Number'; + + // script omitted + + $table = $this->addBlankElement('table'); + $table->attr['align'] = 'Enum#left,center,right'; + $table->attr['bgcolor'] = 'Color'; + + $tr = $this->addBlankElement('tr'); + $tr->attr['bgcolor'] = 'Color'; + + $th = $this->addBlankElement('th'); + $th->attr['bgcolor'] = 'Color'; + $th->attr['height'] = 'Length'; + $th->attr['nowrap'] = 'Bool#nowrap'; + $th->attr['width'] = 'Length'; + + $td = $this->addBlankElement('td'); + $td->attr['bgcolor'] = 'Color'; + $td->attr['height'] = 'Length'; + $td->attr['nowrap'] = 'Bool#nowrap'; + $td->attr['width'] = 'Length'; + + $ul = $this->addBlankElement('ul'); + $ul->attr['compact'] = 'Bool#compact'; + $ul->attr['type'] = 'Enum#square,disc,circle'; + + // "safe" modifications to "unsafe" elements + // WARNING: If you want to add support for an unsafe, legacy + // attribute, make a new TrustedLegacy module with the trusted + // bit set appropriately + + $form = $this->addBlankElement('form'); + $form->content_model = 'Flow | #PCDATA'; + $form->content_model_type = 'optional'; + $form->attr['target'] = 'FrameTarget'; + + $input = $this->addBlankElement('input'); + $input->attr['align'] = 'IAlign'; + + $legend = $this->addBlankElement('legend'); + $legend->attr['align'] = 'LAlign'; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/List.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/List.php new file mode 100644 index 0000000..7a20ff7 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/List.php @@ -0,0 +1,51 @@ + 'List'); + + /** + * @param HTMLPurifier_Config $config + */ + public function setup($config) + { + $ol = $this->addElement('ol', 'List', new HTMLPurifier_ChildDef_List(), 'Common'); + $ul = $this->addElement('ul', 'List', new HTMLPurifier_ChildDef_List(), 'Common'); + // XXX The wrap attribute is handled by MakeWellFormed. This is all + // quite unsatisfactory, because we generated this + // *specifically* for lists, and now a big chunk of the handling + // is done properly by the List ChildDef. So actually, we just + // want enough information to make autoclosing work properly, + // and then hand off the tricky stuff to the ChildDef. + $ol->wrap = 'li'; + $ul->wrap = 'li'; + $this->addElement('dl', 'List', 'Required: dt | dd', 'Common'); + + $this->addElement('li', false, 'Flow', 'Common'); + + $this->addElement('dd', false, 'Flow', 'Common'); + $this->addElement('dt', false, 'Inline', 'Common'); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Name.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Name.php new file mode 100644 index 0000000..60c0545 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Name.php @@ -0,0 +1,26 @@ +addBlankElement($name); + $element->attr['name'] = 'CDATA'; + if (!$config->get('HTML.Attr.Name.UseCDATA')) { + $element->attr_transform_post[] = new HTMLPurifier_AttrTransform_NameSync(); + } + } + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Nofollow.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Nofollow.php new file mode 100644 index 0000000..dc9410a --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Nofollow.php @@ -0,0 +1,25 @@ +addBlankElement('a'); + $a->attr_transform_post[] = new HTMLPurifier_AttrTransform_Nofollow(); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php new file mode 100644 index 0000000..da72225 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php @@ -0,0 +1,20 @@ + array( + 'lang' => 'LanguageCode', + ) + ); +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Object.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Object.php new file mode 100644 index 0000000..2f9efc5 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Object.php @@ -0,0 +1,62 @@ + to cater to legacy browsers: this + * module does not allow this sort of behavior + */ +class HTMLPurifier_HTMLModule_Object extends HTMLPurifier_HTMLModule +{ + /** + * @type string + */ + public $name = 'Object'; + + /** + * @type bool + */ + public $safe = false; + + /** + * @param HTMLPurifier_Config $config + */ + public function setup($config) + { + $this->addElement( + 'object', + 'Inline', + 'Optional: #PCDATA | Flow | param', + 'Common', + array( + 'archive' => 'URI', + 'classid' => 'URI', + 'codebase' => 'URI', + 'codetype' => 'Text', + 'data' => 'URI', + 'declare' => 'Bool#declare', + 'height' => 'Length', + 'name' => 'CDATA', + 'standby' => 'Text', + 'tabindex' => 'Number', + 'type' => 'ContentType', + 'width' => 'Length' + ) + ); + + $this->addElement( + 'param', + false, + 'Empty', + null, + array( + 'id' => 'ID', + 'name*' => 'Text', + 'type' => 'Text', + 'value' => 'Text', + 'valuetype' => 'Enum#data,ref,object' + ) + ); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Presentation.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Presentation.php new file mode 100644 index 0000000..6458ce9 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Presentation.php @@ -0,0 +1,42 @@ +addElement('hr', 'Block', 'Empty', 'Common'); + $this->addElement('sub', 'Inline', 'Inline', 'Common'); + $this->addElement('sup', 'Inline', 'Inline', 'Common'); + $b = $this->addElement('b', 'Inline', 'Inline', 'Common'); + $b->formatting = true; + $big = $this->addElement('big', 'Inline', 'Inline', 'Common'); + $big->formatting = true; + $i = $this->addElement('i', 'Inline', 'Inline', 'Common'); + $i->formatting = true; + $small = $this->addElement('small', 'Inline', 'Inline', 'Common'); + $small->formatting = true; + $tt = $this->addElement('tt', 'Inline', 'Inline', 'Common'); + $tt->formatting = true; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Proprietary.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Proprietary.php new file mode 100644 index 0000000..5ee3c8e --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Proprietary.php @@ -0,0 +1,40 @@ +addElement( + 'marquee', + 'Inline', + 'Flow', + 'Common', + array( + 'direction' => 'Enum#left,right,up,down', + 'behavior' => 'Enum#alternate', + 'width' => 'Length', + 'height' => 'Length', + 'scrolldelay' => 'Number', + 'scrollamount' => 'Number', + 'loop' => 'Number', + 'bgcolor' => 'Color', + 'hspace' => 'Pixels', + 'vspace' => 'Pixels', + ) + ); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Ruby.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Ruby.php new file mode 100644 index 0000000..a0d4892 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/Ruby.php @@ -0,0 +1,36 @@ +addElement( + 'ruby', + 'Inline', + 'Custom: ((rb, (rt | (rp, rt, rp))) | (rbc, rtc, rtc?))', + 'Common' + ); + $this->addElement('rbc', false, 'Required: rb', 'Common'); + $this->addElement('rtc', false, 'Required: rt', 'Common'); + $rb = $this->addElement('rb', false, 'Inline', 'Common'); + $rb->excludes = array('ruby' => true); + $rt = $this->addElement('rt', false, 'Inline', 'Common', array('rbspan' => 'Number')); + $rt->excludes = array('ruby' => true); + $this->addElement('rp', false, 'Optional: #PCDATA', 'Common'); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeEmbed.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeEmbed.php new file mode 100644 index 0000000..04e6689 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeEmbed.php @@ -0,0 +1,40 @@ +get('HTML.MaxImgLength'); + $embed = $this->addElement( + 'embed', + 'Inline', + 'Empty', + 'Common', + array( + 'src*' => 'URI#embedded', + 'type' => 'Enum#application/x-shockwave-flash', + 'width' => 'Pixels#' . $max, + 'height' => 'Pixels#' . $max, + 'allowscriptaccess' => 'Enum#never', + 'allownetworking' => 'Enum#internal', + 'flashvars' => 'Text', + 'wmode' => 'Enum#window,transparent,opaque', + 'name' => 'ID', + ) + ); + $embed->attr_transform_post[] = new HTMLPurifier_AttrTransform_SafeEmbed(); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeObject.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeObject.php new file mode 100644 index 0000000..1297f80 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeObject.php @@ -0,0 +1,62 @@ +get('HTML.MaxImgLength'); + $object = $this->addElement( + 'object', + 'Inline', + 'Optional: param | Flow | #PCDATA', + 'Common', + array( + // While technically not required by the spec, we're forcing + // it to this value. + 'type' => 'Enum#application/x-shockwave-flash', + 'width' => 'Pixels#' . $max, + 'height' => 'Pixels#' . $max, + 'data' => 'URI#embedded', + 'codebase' => new HTMLPurifier_AttrDef_Enum( + array( + 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0' + ) + ), + ) + ); + $object->attr_transform_post[] = new HTMLPurifier_AttrTransform_SafeObject(); + + $param = $this->addElement( + 'param', + false, + 'Empty', + false, + array( + 'id' => 'ID', + 'name*' => 'Text', + 'value' => 'Text' + ) + ); + $param->attr_transform_post[] = new HTMLPurifier_AttrTransform_SafeParam(); + $this->info_injector[] = 'SafeObject'; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeScripting.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeScripting.php new file mode 100644 index 0000000..aea7584 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/HTMLModule/SafeScripting.php @@ -0,0 +1,40 @@ +get('HTML.SafeScripting'); + $script = $this->addElement( + 'script', + 'Inline', + 'Optional:', // Not `Empty` to not allow to autoclose the #i', '', $html); + } + + return $html; + } + + /** + * Takes a string of HTML (fragment or document) and returns the content + * @todo Consider making protected + */ + public function extractBody($html) + { + $matches = array(); + $result = preg_match('|(.*?)]*>(.*)|is', $html, $matches); + if ($result) { + // Make sure it's not in a comment + $comment_start = strrpos($matches[1], ''); + if ($comment_start === false || + ($comment_end !== false && $comment_end > $comment_start)) { + return $matches[2]; + } + } + return $html; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php new file mode 100644 index 0000000..7d57983 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/DOMLex.php @@ -0,0 +1,340 @@ +factory = new HTMLPurifier_TokenFactory(); + } + + /** + * @param string $html + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return HTMLPurifier_Token[] + */ + public function tokenizeHTML($html, $config, $context) + { + $html = $this->normalize($html, $config, $context); + + // attempt to armor stray angled brackets that cannot possibly + // form tags and thus are probably being used as emoticons + if ($config->get('Core.AggressivelyFixLt')) { + $char = '[^a-z!\/]'; + $comment = "/|\z)/is"; + $html = preg_replace_callback($comment, array($this, 'callbackArmorCommentEntities'), $html); + do { + $old = $html; + $html = preg_replace("/<($char)/i", '<\\1', $html); + } while ($html !== $old); + $html = preg_replace_callback($comment, array($this, 'callbackUndoCommentSubst'), $html); // fix comments + } + + // preprocess html, essential for UTF-8 + $html = $this->wrapHTML($html, $config, $context); + + $doc = new DOMDocument(); + $doc->encoding = 'UTF-8'; // theoretically, the above has this covered + + $options = 0; + if ($config->get('Core.AllowParseManyTags') && defined('LIBXML_PARSEHUGE')) { + $options |= LIBXML_PARSEHUGE; + } + if ($config->get('Core.RemoveBlanks') && defined('LIBXML_NOBLANKS')) { + $options |= LIBXML_NOBLANKS; + } + + set_error_handler(array($this, 'muteErrorHandler')); + // loadHTML() fails on PHP 5.3 when second parameter is given + if ($options) { + $doc->loadHTML($html, $options); + } else { + $doc->loadHTML($html); + } + restore_error_handler(); + + $body = $doc->getElementsByTagName('html')->item(0)-> // + getElementsByTagName('body')->item(0); // + + $div = $body->getElementsByTagName('div')->item(0); //
+ $tokens = array(); + $this->tokenizeDOM($div, $tokens, $config); + // If the div has a sibling, that means we tripped across + // a premature
tag. So remove the div we parsed, + // and then tokenize the rest of body. We can't tokenize + // the sibling directly as we'll lose the tags in that case. + if ($div->nextSibling) { + $body->removeChild($div); + $this->tokenizeDOM($body, $tokens, $config); + } + return $tokens; + } + + /** + * Iterative function that tokenizes a node, putting it into an accumulator. + * To iterate is human, to recurse divine - L. Peter Deutsch + * @param DOMNode $node DOMNode to be tokenized. + * @param HTMLPurifier_Token[] $tokens Array-list of already tokenized tokens. + */ + protected function tokenizeDOM($node, &$tokens, $config) + { + $level = 0; + $nodes = array($level => new HTMLPurifier_Queue(array($node))); + $closingNodes = array(); + do { + while (!$nodes[$level]->isEmpty()) { + $node = $nodes[$level]->shift(); // FIFO + $collect = $level > 0 ? true : false; + $needEndingTag = $this->createStartNode($node, $tokens, $collect, $config); + if ($needEndingTag) { + $closingNodes[$level][] = $node; + } + if ($node->childNodes && $node->childNodes->length) { + $level++; + $nodes[$level] = new HTMLPurifier_Queue(); + foreach ($node->childNodes as $childNode) { + $nodes[$level]->push($childNode); + } + } + } + $level--; + if ($level && isset($closingNodes[$level])) { + while ($node = array_pop($closingNodes[$level])) { + $this->createEndNode($node, $tokens); + } + } + } while ($level > 0); + } + + /** + * Portably retrieve the tag name of a node; deals with older versions + * of libxml like 2.7.6 + * @param DOMNode $node + */ + protected function getTagName($node) + { + if (isset($node->tagName)) { + return $node->tagName; + } else if (isset($node->nodeName)) { + return $node->nodeName; + } else if (isset($node->localName)) { + return $node->localName; + } + return null; + } + + /** + * Portably retrieve the data of a node; deals with older versions + * of libxml like 2.7.6 + * @param DOMNode $node + */ + protected function getData($node) + { + if (isset($node->data)) { + return $node->data; + } else if (isset($node->nodeValue)) { + return $node->nodeValue; + } else if (isset($node->textContent)) { + return $node->textContent; + } + return null; + } + + + /** + * @param DOMNode $node DOMNode to be tokenized. + * @param HTMLPurifier_Token[] $tokens Array-list of already tokenized tokens. + * @param bool $collect Says whether or start and close are collected, set to + * false at first recursion because it's the implicit DIV + * tag you're dealing with. + * @return bool if the token needs an endtoken + * @todo data and tagName properties don't seem to exist in DOMNode? + */ + protected function createStartNode($node, &$tokens, $collect, $config) + { + // intercept non element nodes. WE MUST catch all of them, + // but we're not getting the character reference nodes because + // those should have been preprocessed + if ($node->nodeType === XML_TEXT_NODE) { + $data = $this->getData($node); // Handle variable data property + if ($data !== null) { + $tokens[] = $this->factory->createText($data); + } + return false; + } elseif ($node->nodeType === XML_CDATA_SECTION_NODE) { + // undo libxml's special treatment of )#si', + array($this, 'scriptCallback'), + $html + ); + } + + $html = $this->normalize($html, $config, $context); + + $cursor = 0; // our location in the text + $inside_tag = false; // whether or not we're parsing the inside of a tag + $array = array(); // result array + + // This is also treated to mean maintain *column* numbers too + $maintain_line_numbers = $config->get('Core.MaintainLineNumbers'); + + if ($maintain_line_numbers === null) { + // automatically determine line numbering by checking + // if error collection is on + $maintain_line_numbers = $config->get('Core.CollectErrors'); + } + + if ($maintain_line_numbers) { + $current_line = 1; + $current_col = 0; + $length = strlen($html); + } else { + $current_line = false; + $current_col = false; + $length = false; + } + $context->register('CurrentLine', $current_line); + $context->register('CurrentCol', $current_col); + $nl = "\n"; + // how often to manually recalculate. This will ALWAYS be right, + // but it's pretty wasteful. Set to 0 to turn off + $synchronize_interval = $config->get('Core.DirectLexLineNumberSyncInterval'); + + $e = false; + if ($config->get('Core.CollectErrors')) { + $e =& $context->get('ErrorCollector'); + } + + // for testing synchronization + $loops = 0; + + while (++$loops) { + // $cursor is either at the start of a token, or inside of + // a tag (i.e. there was a < immediately before it), as indicated + // by $inside_tag + + if ($maintain_line_numbers) { + // $rcursor, however, is always at the start of a token. + $rcursor = $cursor - (int)$inside_tag; + + // Column number is cheap, so we calculate it every round. + // We're interested at the *end* of the newline string, so + // we need to add strlen($nl) == 1 to $nl_pos before subtracting it + // from our "rcursor" position. + $nl_pos = strrpos($html, $nl, $rcursor - $length); + $current_col = $rcursor - (is_bool($nl_pos) ? 0 : $nl_pos + 1); + + // recalculate lines + if ($synchronize_interval && // synchronization is on + $cursor > 0 && // cursor is further than zero + $loops % $synchronize_interval === 0) { // time to synchronize! + $current_line = 1 + $this->substrCount($html, $nl, 0, $cursor); + } + } + + $position_next_lt = strpos($html, '<', $cursor); + $position_next_gt = strpos($html, '>', $cursor); + + // triggers on "asdf" but not "asdf " + // special case to set up context + if ($position_next_lt === $cursor) { + $inside_tag = true; + $cursor++; + } + + if (!$inside_tag && $position_next_lt !== false) { + // We are not inside tag and there still is another tag to parse + $token = new + HTMLPurifier_Token_Text( + $this->parseText( + substr( + $html, + $cursor, + $position_next_lt - $cursor + ), $config + ) + ); + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + $current_line += $this->substrCount($html, $nl, $cursor, $position_next_lt - $cursor); + } + $array[] = $token; + $cursor = $position_next_lt + 1; + $inside_tag = true; + continue; + } elseif (!$inside_tag) { + // We are not inside tag but there are no more tags + // If we're already at the end, break + if ($cursor === strlen($html)) { + break; + } + // Create Text of rest of string + $token = new + HTMLPurifier_Token_Text( + $this->parseText( + substr( + $html, + $cursor + ), $config + ) + ); + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + } + $array[] = $token; + break; + } elseif ($inside_tag && $position_next_gt !== false) { + // We are in tag and it is well formed + // Grab the internals of the tag + $strlen_segment = $position_next_gt - $cursor; + + if ($strlen_segment < 1) { + // there's nothing to process! + $token = new HTMLPurifier_Token_Text('<'); + $cursor++; + continue; + } + + $segment = substr($html, $cursor, $strlen_segment); + + if ($segment === false) { + // somehow, we attempted to access beyond the end of + // the string, defense-in-depth, reported by Nate Abele + break; + } + + // Check if it's a comment + if (substr($segment, 0, 3) === '!--') { + // re-determine segment length, looking for --> + $position_comment_end = strpos($html, '-->', $cursor); + if ($position_comment_end === false) { + // uh oh, we have a comment that extends to + // infinity. Can't be helped: set comment + // end position to end of string + if ($e) { + $e->send(E_WARNING, 'Lexer: Unclosed comment'); + } + $position_comment_end = strlen($html); + $end = true; + } else { + $end = false; + } + $strlen_segment = $position_comment_end - $cursor; + $segment = substr($html, $cursor, $strlen_segment); + $token = new + HTMLPurifier_Token_Comment( + substr( + $segment, + 3, + $strlen_segment - 3 + ) + ); + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + $current_line += $this->substrCount($html, $nl, $cursor, $strlen_segment); + } + $array[] = $token; + $cursor = $end ? $position_comment_end : $position_comment_end + 3; + $inside_tag = false; + continue; + } + + // Check if it's an end tag + $is_end_tag = (strpos($segment, '/') === 0); + if ($is_end_tag) { + $type = substr($segment, 1); + $token = new HTMLPurifier_Token_End($type); + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + $current_line += $this->substrCount($html, $nl, $cursor, $position_next_gt - $cursor); + } + $array[] = $token; + $inside_tag = false; + $cursor = $position_next_gt + 1; + continue; + } + + // Check leading character is alnum, if not, we may + // have accidently grabbed an emoticon. Translate into + // text and go our merry way + if (!ctype_alpha($segment[0])) { + // XML: $segment[0] !== '_' && $segment[0] !== ':' + if ($e) { + $e->send(E_NOTICE, 'Lexer: Unescaped lt'); + } + $token = new HTMLPurifier_Token_Text('<'); + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + $current_line += $this->substrCount($html, $nl, $cursor, $position_next_gt - $cursor); + } + $array[] = $token; + $inside_tag = false; + continue; + } + + // Check if it is explicitly self closing, if so, remove + // trailing slash. Remember, we could have a tag like
, so + // any later token processing scripts must convert improperly + // classified EmptyTags from StartTags. + $is_self_closing = (strrpos($segment, '/') === $strlen_segment - 1); + if ($is_self_closing) { + $strlen_segment--; + $segment = substr($segment, 0, $strlen_segment); + } + + // Check if there are any attributes + $position_first_space = strcspn($segment, $this->_whitespace); + + if ($position_first_space >= $strlen_segment) { + if ($is_self_closing) { + $token = new HTMLPurifier_Token_Empty($segment); + } else { + $token = new HTMLPurifier_Token_Start($segment); + } + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + $current_line += $this->substrCount($html, $nl, $cursor, $position_next_gt - $cursor); + } + $array[] = $token; + $inside_tag = false; + $cursor = $position_next_gt + 1; + continue; + } + + // Grab out all the data + $type = substr($segment, 0, $position_first_space); + $attribute_string = + trim( + substr( + $segment, + $position_first_space + ) + ); + if ($attribute_string) { + $attr = $this->parseAttributeString( + $attribute_string, + $config, + $context + ); + } else { + $attr = array(); + } + + if ($is_self_closing) { + $token = new HTMLPurifier_Token_Empty($type, $attr); + } else { + $token = new HTMLPurifier_Token_Start($type, $attr); + } + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + $current_line += $this->substrCount($html, $nl, $cursor, $position_next_gt - $cursor); + } + $array[] = $token; + $cursor = $position_next_gt + 1; + $inside_tag = false; + continue; + } else { + // inside tag, but there's no ending > sign + if ($e) { + $e->send(E_WARNING, 'Lexer: Missing gt'); + } + $token = new + HTMLPurifier_Token_Text( + '<' . + $this->parseText( + substr($html, $cursor), $config + ) + ); + if ($maintain_line_numbers) { + $token->rawPosition($current_line, $current_col); + } + // no cursor scroll? Hmm... + $array[] = $token; + break; + } + break; + } + + $context->destroy('CurrentLine'); + $context->destroy('CurrentCol'); + return $array; + } + + /** + * PHP 5.0.x compatible substr_count that implements offset and length + * @param string $haystack + * @param string $needle + * @param int $offset + * @param int $length + * @return int + */ + protected function substrCount($haystack, $needle, $offset, $length) + { + static $oldVersion; + if ($oldVersion === null) { + $oldVersion = version_compare(PHP_VERSION, '5.1', '<'); + } + if ($oldVersion) { + $haystack = substr($haystack, $offset, $length); + return substr_count($haystack, $needle); + } else { + return substr_count($haystack, $needle, $offset, $length); + } + } + + /** + * Takes the inside of an HTML tag and makes an assoc array of attributes. + * + * @param string $string Inside of tag excluding name. + * @param HTMLPurifier_Config $config + * @param HTMLPurifier_Context $context + * @return array Assoc array of attributes. + */ + public function parseAttributeString($string, $config, $context) + { + $string = (string)$string; // quick typecast + + if ($string == '') { + return array(); + } // no attributes + + $e = false; + if ($config->get('Core.CollectErrors')) { + $e =& $context->get('ErrorCollector'); + } + + // let's see if we can abort as quickly as possible + // one equal sign, no spaces => one attribute + $num_equal = substr_count($string, '='); + $has_space = strpos($string, ' '); + if ($num_equal === 0 && !$has_space) { + // bool attribute + return array($string => $string); + } elseif ($num_equal === 1 && !$has_space) { + // only one attribute + list($key, $quoted_value) = explode('=', $string); + $quoted_value = trim($quoted_value); + if (!$key) { + if ($e) { + $e->send(E_ERROR, 'Lexer: Missing attribute key'); + } + return array(); + } + if (!$quoted_value) { + return array($key => ''); + } + $first_char = @$quoted_value[0]; + $last_char = @$quoted_value[strlen($quoted_value) - 1]; + + $same_quote = ($first_char == $last_char); + $open_quote = ($first_char == '"' || $first_char == "'"); + + if ($same_quote && $open_quote) { + // well behaved + $value = substr($quoted_value, 1, strlen($quoted_value) - 2); + } else { + // not well behaved + if ($open_quote) { + if ($e) { + $e->send(E_ERROR, 'Lexer: Missing end quote'); + } + $value = substr($quoted_value, 1); + } else { + $value = $quoted_value; + } + } + if ($value === false) { + $value = ''; + } + return array($key => $this->parseAttr($value, $config)); + } + + // setup loop environment + $array = array(); // return assoc array of attributes + $cursor = 0; // current position in string (moves forward) + $size = strlen($string); // size of the string (stays the same) + + // if we have unquoted attributes, the parser expects a terminating + // space, so let's guarantee that there's always a terminating space. + $string .= ' '; + + $old_cursor = -1; + while ($cursor < $size) { + if ($old_cursor >= $cursor) { + throw new Exception("Infinite loop detected"); + } + $old_cursor = $cursor; + + $cursor += ($value = strspn($string, $this->_whitespace, $cursor)); + // grab the key + + $key_begin = $cursor; //we're currently at the start of the key + + // scroll past all characters that are the key (not whitespace or =) + $cursor += strcspn($string, $this->_whitespace . '=', $cursor); + + $key_end = $cursor; // now at the end of the key + + $key = substr($string, $key_begin, $key_end - $key_begin); + + if (!$key) { + if ($e) { + $e->send(E_ERROR, 'Lexer: Missing attribute key'); + } + $cursor += 1 + strcspn($string, $this->_whitespace, $cursor + 1); // prevent infinite loop + continue; // empty key + } + + // scroll past all whitespace + $cursor += strspn($string, $this->_whitespace, $cursor); + + if ($cursor >= $size) { + $array[$key] = $key; + break; + } + + // if the next character is an equal sign, we've got a regular + // pair, otherwise, it's a bool attribute + $first_char = @$string[$cursor]; + + if ($first_char == '=') { + // key="value" + + $cursor++; + $cursor += strspn($string, $this->_whitespace, $cursor); + + if ($cursor === false) { + $array[$key] = ''; + break; + } + + // we might be in front of a quote right now + + $char = @$string[$cursor]; + + if ($char == '"' || $char == "'") { + // it's quoted, end bound is $char + $cursor++; + $value_begin = $cursor; + $cursor = strpos($string, $char, $cursor); + $value_end = $cursor; + } else { + // it's not quoted, end bound is whitespace + $value_begin = $cursor; + $cursor += strcspn($string, $this->_whitespace, $cursor); + $value_end = $cursor; + } + + // we reached a premature end + if ($cursor === false) { + $cursor = $size; + $value_end = $cursor; + } + + $value = substr($string, $value_begin, $value_end - $value_begin); + if ($value === false) { + $value = ''; + } + $array[$key] = $this->parseAttr($value, $config); + $cursor++; + } else { + // boolattr + if ($key !== '') { + $array[$key] = $key; + } else { + // purely theoretical + if ($e) { + $e->send(E_ERROR, 'Lexer: Missing attribute key'); + } + } + } + } + return $array; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/PH5P.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/PH5P.php new file mode 100644 index 0000000..1564f28 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Lexer/PH5P.php @@ -0,0 +1,4788 @@ +normalize($html, $config, $context); + $new_html = $this->wrapHTML($new_html, $config, $context, false /* no div */); + try { + $parser = new HTML5($new_html); + $doc = $parser->save(); + } catch (DOMException $e) { + // Uh oh, it failed. Punt to DirectLex. + $lexer = new HTMLPurifier_Lexer_DirectLex(); + $context->register('PH5PError', $e); // save the error, so we can detect it + return $lexer->tokenizeHTML($html, $config, $context); // use original HTML + } + $tokens = array(); + $this->tokenizeDOM( + $doc->getElementsByTagName('html')->item(0)-> // + getElementsByTagName('body')->item(0) // + , + $tokens, $config + ); + return $tokens; + } +} + +/* + +Copyright 2007 Jeroen van der Meer + +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. + +*/ + +class HTML5 +{ + private $data; + private $char; + private $EOF; + private $state; + private $tree; + private $token; + private $content_model; + private $escape = false; + private $entities = array( + 'AElig;', + 'AElig', + 'AMP;', + 'AMP', + 'Aacute;', + 'Aacute', + 'Acirc;', + 'Acirc', + 'Agrave;', + 'Agrave', + 'Alpha;', + 'Aring;', + 'Aring', + 'Atilde;', + 'Atilde', + 'Auml;', + 'Auml', + 'Beta;', + 'COPY;', + 'COPY', + 'Ccedil;', + 'Ccedil', + 'Chi;', + 'Dagger;', + 'Delta;', + 'ETH;', + 'ETH', + 'Eacute;', + 'Eacute', + 'Ecirc;', + 'Ecirc', + 'Egrave;', + 'Egrave', + 'Epsilon;', + 'Eta;', + 'Euml;', + 'Euml', + 'GT;', + 'GT', + 'Gamma;', + 'Iacute;', + 'Iacute', + 'Icirc;', + 'Icirc', + 'Igrave;', + 'Igrave', + 'Iota;', + 'Iuml;', + 'Iuml', + 'Kappa;', + 'LT;', + 'LT', + 'Lambda;', + 'Mu;', + 'Ntilde;', + 'Ntilde', + 'Nu;', + 'OElig;', + 'Oacute;', + 'Oacute', + 'Ocirc;', + 'Ocirc', + 'Ograve;', + 'Ograve', + 'Omega;', + 'Omicron;', + 'Oslash;', + 'Oslash', + 'Otilde;', + 'Otilde', + 'Ouml;', + 'Ouml', + 'Phi;', + 'Pi;', + 'Prime;', + 'Psi;', + 'QUOT;', + 'QUOT', + 'REG;', + 'REG', + 'Rho;', + 'Scaron;', + 'Sigma;', + 'THORN;', + 'THORN', + 'TRADE;', + 'Tau;', + 'Theta;', + 'Uacute;', + 'Uacute', + 'Ucirc;', + 'Ucirc', + 'Ugrave;', + 'Ugrave', + 'Upsilon;', + 'Uuml;', + 'Uuml', + 'Xi;', + 'Yacute;', + 'Yacute', + 'Yuml;', + 'Zeta;', + 'aacute;', + 'aacute', + 'acirc;', + 'acirc', + 'acute;', + 'acute', + 'aelig;', + 'aelig', + 'agrave;', + 'agrave', + 'alefsym;', + 'alpha;', + 'amp;', + 'amp', + 'and;', + 'ang;', + 'apos;', + 'aring;', + 'aring', + 'asymp;', + 'atilde;', + 'atilde', + 'auml;', + 'auml', + 'bdquo;', + 'beta;', + 'brvbar;', + 'brvbar', + 'bull;', + 'cap;', + 'ccedil;', + 'ccedil', + 'cedil;', + 'cedil', + 'cent;', + 'cent', + 'chi;', + 'circ;', + 'clubs;', + 'cong;', + 'copy;', + 'copy', + 'crarr;', + 'cup;', + 'curren;', + 'curren', + 'dArr;', + 'dagger;', + 'darr;', + 'deg;', + 'deg', + 'delta;', + 'diams;', + 'divide;', + 'divide', + 'eacute;', + 'eacute', + 'ecirc;', + 'ecirc', + 'egrave;', + 'egrave', + 'empty;', + 'emsp;', + 'ensp;', + 'epsilon;', + 'equiv;', + 'eta;', + 'eth;', + 'eth', + 'euml;', + 'euml', + 'euro;', + 'exist;', + 'fnof;', + 'forall;', + 'frac12;', + 'frac12', + 'frac14;', + 'frac14', + 'frac34;', + 'frac34', + 'frasl;', + 'gamma;', + 'ge;', + 'gt;', + 'gt', + 'hArr;', + 'harr;', + 'hearts;', + 'hellip;', + 'iacute;', + 'iacute', + 'icirc;', + 'icirc', + 'iexcl;', + 'iexcl', + 'igrave;', + 'igrave', + 'image;', + 'infin;', + 'int;', + 'iota;', + 'iquest;', + 'iquest', + 'isin;', + 'iuml;', + 'iuml', + 'kappa;', + 'lArr;', + 'lambda;', + 'lang;', + 'laquo;', + 'laquo', + 'larr;', + 'lceil;', + 'ldquo;', + 'le;', + 'lfloor;', + 'lowast;', + 'loz;', + 'lrm;', + 'lsaquo;', + 'lsquo;', + 'lt;', + 'lt', + 'macr;', + 'macr', + 'mdash;', + 'micro;', + 'micro', + 'middot;', + 'middot', + 'minus;', + 'mu;', + 'nabla;', + 'nbsp;', + 'nbsp', + 'ndash;', + 'ne;', + 'ni;', + 'not;', + 'not', + 'notin;', + 'nsub;', + 'ntilde;', + 'ntilde', + 'nu;', + 'oacute;', + 'oacute', + 'ocirc;', + 'ocirc', + 'oelig;', + 'ograve;', + 'ograve', + 'oline;', + 'omega;', + 'omicron;', + 'oplus;', + 'or;', + 'ordf;', + 'ordf', + 'ordm;', + 'ordm', + 'oslash;', + 'oslash', + 'otilde;', + 'otilde', + 'otimes;', + 'ouml;', + 'ouml', + 'para;', + 'para', + 'part;', + 'permil;', + 'perp;', + 'phi;', + 'pi;', + 'piv;', + 'plusmn;', + 'plusmn', + 'pound;', + 'pound', + 'prime;', + 'prod;', + 'prop;', + 'psi;', + 'quot;', + 'quot', + 'rArr;', + 'radic;', + 'rang;', + 'raquo;', + 'raquo', + 'rarr;', + 'rceil;', + 'rdquo;', + 'real;', + 'reg;', + 'reg', + 'rfloor;', + 'rho;', + 'rlm;', + 'rsaquo;', + 'rsquo;', + 'sbquo;', + 'scaron;', + 'sdot;', + 'sect;', + 'sect', + 'shy;', + 'shy', + 'sigma;', + 'sigmaf;', + 'sim;', + 'spades;', + 'sub;', + 'sube;', + 'sum;', + 'sup1;', + 'sup1', + 'sup2;', + 'sup2', + 'sup3;', + 'sup3', + 'sup;', + 'supe;', + 'szlig;', + 'szlig', + 'tau;', + 'there4;', + 'theta;', + 'thetasym;', + 'thinsp;', + 'thorn;', + 'thorn', + 'tilde;', + 'times;', + 'times', + 'trade;', + 'uArr;', + 'uacute;', + 'uacute', + 'uarr;', + 'ucirc;', + 'ucirc', + 'ugrave;', + 'ugrave', + 'uml;', + 'uml', + 'upsih;', + 'upsilon;', + 'uuml;', + 'uuml', + 'weierp;', + 'xi;', + 'yacute;', + 'yacute', + 'yen;', + 'yen', + 'yuml;', + 'yuml', + 'zeta;', + 'zwj;', + 'zwnj;' + ); + + const PCDATA = 0; + const RCDATA = 1; + const CDATA = 2; + const PLAINTEXT = 3; + + const DOCTYPE = 0; + const STARTTAG = 1; + const ENDTAG = 2; + const COMMENT = 3; + const CHARACTR = 4; + const EOF = 5; + + public function __construct($data) + { + $this->data = $data; + $this->char = -1; + $this->EOF = strlen($data); + $this->tree = new HTML5TreeConstructer; + $this->content_model = self::PCDATA; + + $this->state = 'data'; + + while ($this->state !== null) { + $this->{$this->state . 'State'}(); + } + } + + public function save() + { + return $this->tree->save(); + } + + private function char() + { + return ($this->char < $this->EOF) + ? $this->data[$this->char] + : false; + } + + private function character($s, $l = 0) + { + if ($s + $l < $this->EOF) { + if ($l === 0) { + return $this->data[$s]; + } else { + return substr($this->data, $s, $l); + } + } + } + + private function characters($char_class, $start) + { + return preg_replace('#^([' . $char_class . ']+).*#s', '\\1', substr($this->data, $start)); + } + + private function dataState() + { + // Consume the next input character + $this->char++; + $char = $this->char(); + + if ($char === '&' && ($this->content_model === self::PCDATA || $this->content_model === self::RCDATA)) { + /* U+0026 AMPERSAND (&) + When the content model flag is set to one of the PCDATA or RCDATA + states: switch to the entity data state. Otherwise: treat it as per + the "anything else" entry below. */ + $this->state = 'entityData'; + + } elseif ($char === '-') { + /* If the content model flag is set to either the RCDATA state or + the CDATA state, and the escape flag is false, and there are at + least three characters before this one in the input stream, and the + last four characters in the input stream, including this one, are + U+003C LESS-THAN SIGN, U+0021 EXCLAMATION MARK, U+002D HYPHEN-MINUS, + and U+002D HYPHEN-MINUS (""), + set the escape flag to false. */ + if (($this->content_model === self::RCDATA || + $this->content_model === self::CDATA) && $this->escape === true && + $this->character($this->char, 3) === '-->' + ) { + $this->escape = false; + } + + /* In any case, emit the input character as a character token. + Stay in the data state. */ + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => $char + ) + ); + + } elseif ($this->char === $this->EOF) { + /* EOF + Emit an end-of-file token. */ + $this->EOF(); + + } elseif ($this->content_model === self::PLAINTEXT) { + /* When the content model flag is set to the PLAINTEXT state + THIS DIFFERS GREATLY FROM THE SPEC: Get the remaining characters of + the text and emit it as a character token. */ + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => substr($this->data, $this->char) + ) + ); + + $this->EOF(); + + } else { + /* Anything else + THIS DIFFERS GREATLY FROM THE SPEC: Get as many character that + otherwise would also be treated as a character token and emit it + as a single character token. Stay in the data state. */ + $len = strcspn($this->data, '<&', $this->char); + $char = substr($this->data, $this->char, $len); + $this->char += $len - 1; + + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => $char + ) + ); + + $this->state = 'data'; + } + } + + private function entityDataState() + { + // Attempt to consume an entity. + $entity = $this->entity(); + + // If nothing is returned, emit a U+0026 AMPERSAND character token. + // Otherwise, emit the character token that was returned. + $char = (!$entity) ? '&' : $entity; + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => $char + ) + ); + + // Finally, switch to the data state. + $this->state = 'data'; + } + + private function tagOpenState() + { + switch ($this->content_model) { + case self::RCDATA: + case self::CDATA: + /* If the next input character is a U+002F SOLIDUS (/) character, + consume it and switch to the close tag open state. If the next + input character is not a U+002F SOLIDUS (/) character, emit a + U+003C LESS-THAN SIGN character token and switch to the data + state to process the next input character. */ + if ($this->character($this->char + 1) === '/') { + $this->char++; + $this->state = 'closeTagOpen'; + + } else { + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => '<' + ) + ); + + $this->state = 'data'; + } + break; + + case self::PCDATA: + // If the content model flag is set to the PCDATA state + // Consume the next input character: + $this->char++; + $char = $this->char(); + + if ($char === '!') { + /* U+0021 EXCLAMATION MARK (!) + Switch to the markup declaration open state. */ + $this->state = 'markupDeclarationOpen'; + + } elseif ($char === '/') { + /* U+002F SOLIDUS (/) + Switch to the close tag open state. */ + $this->state = 'closeTagOpen'; + + } elseif (preg_match('/^[A-Za-z]$/', $char)) { + /* U+0041 LATIN LETTER A through to U+005A LATIN LETTER Z + Create a new start tag token, set its tag name to the lowercase + version of the input character (add 0x0020 to the character's code + point), then switch to the tag name state. (Don't emit the token + yet; further details will be filled in before it is emitted.) */ + $this->token = array( + 'name' => strtolower($char), + 'type' => self::STARTTAG, + 'attr' => array() + ); + + $this->state = 'tagName'; + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Parse error. Emit a U+003C LESS-THAN SIGN character token and a + U+003E GREATER-THAN SIGN character token. Switch to the data state. */ + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => '<>' + ) + ); + + $this->state = 'data'; + + } elseif ($char === '?') { + /* U+003F QUESTION MARK (?) + Parse error. Switch to the bogus comment state. */ + $this->state = 'bogusComment'; + + } else { + /* Anything else + Parse error. Emit a U+003C LESS-THAN SIGN character token and + reconsume the current input character in the data state. */ + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => '<' + ) + ); + + $this->char--; + $this->state = 'data'; + } + break; + } + } + + private function closeTagOpenState() + { + $next_node = strtolower($this->characters('A-Za-z', $this->char + 1)); + $the_same = count($this->tree->stack) > 0 && $next_node === end($this->tree->stack)->nodeName; + + if (($this->content_model === self::RCDATA || $this->content_model === self::CDATA) && + (!$the_same || ($the_same && (!preg_match( + '/[\t\n\x0b\x0c >\/]/', + $this->character($this->char + 1 + strlen($next_node)) + ) || $this->EOF === $this->char))) + ) { + /* If the content model flag is set to the RCDATA or CDATA states then + examine the next few characters. If they do not match the tag name of + the last start tag token emitted (case insensitively), or if they do but + they are not immediately followed by one of the following characters: + * U+0009 CHARACTER TABULATION + * U+000A LINE FEED (LF) + * U+000B LINE TABULATION + * U+000C FORM FEED (FF) + * U+0020 SPACE + * U+003E GREATER-THAN SIGN (>) + * U+002F SOLIDUS (/) + * EOF + ...then there is a parse error. Emit a U+003C LESS-THAN SIGN character + token, a U+002F SOLIDUS character token, and switch to the data state + to process the next input character. */ + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => 'state = 'data'; + + } else { + /* Otherwise, if the content model flag is set to the PCDATA state, + or if the next few characters do match that tag name, consume the + next input character: */ + $this->char++; + $char = $this->char(); + + if (preg_match('/^[A-Za-z]$/', $char)) { + /* U+0041 LATIN LETTER A through to U+005A LATIN LETTER Z + Create a new end tag token, set its tag name to the lowercase version + of the input character (add 0x0020 to the character's code point), then + switch to the tag name state. (Don't emit the token yet; further details + will be filled in before it is emitted.) */ + $this->token = array( + 'name' => strtolower($char), + 'type' => self::ENDTAG + ); + + $this->state = 'tagName'; + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Parse error. Switch to the data state. */ + $this->state = 'data'; + + } elseif ($this->char === $this->EOF) { + /* EOF + Parse error. Emit a U+003C LESS-THAN SIGN character token and a U+002F + SOLIDUS character token. Reconsume the EOF character in the data state. */ + $this->emitToken( + array( + 'type' => self::CHARACTR, + 'data' => 'char--; + $this->state = 'data'; + + } else { + /* Parse error. Switch to the bogus comment state. */ + $this->state = 'bogusComment'; + } + } + } + + private function tagNameState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + /* U+0009 CHARACTER TABULATION + U+000A LINE FEED (LF) + U+000B LINE TABULATION + U+000C FORM FEED (FF) + U+0020 SPACE + Switch to the before attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Emit the current tag token. Switch to the data state. */ + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif ($this->char === $this->EOF) { + /* EOF + Parse error. Emit the current tag token. Reconsume the EOF + character in the data state. */ + $this->emitToken($this->token); + + $this->char--; + $this->state = 'data'; + + } elseif ($char === '/') { + /* U+002F SOLIDUS (/) + Parse error unless this is a permitted slash. Switch to the before + attribute name state. */ + $this->state = 'beforeAttributeName'; + + } else { + /* Anything else + Append the current input character to the current tag token's tag name. + Stay in the tag name state. */ + $this->token['name'] .= strtolower($char); + $this->state = 'tagName'; + } + } + + private function beforeAttributeNameState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + /* U+0009 CHARACTER TABULATION + U+000A LINE FEED (LF) + U+000B LINE TABULATION + U+000C FORM FEED (FF) + U+0020 SPACE + Stay in the before attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Emit the current tag token. Switch to the data state. */ + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif ($char === '/') { + /* U+002F SOLIDUS (/) + Parse error unless this is a permitted slash. Stay in the before + attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($this->char === $this->EOF) { + /* EOF + Parse error. Emit the current tag token. Reconsume the EOF + character in the data state. */ + $this->emitToken($this->token); + + $this->char--; + $this->state = 'data'; + + } else { + /* Anything else + Start a new attribute in the current tag token. Set that attribute's + name to the current input character, and its value to the empty string. + Switch to the attribute name state. */ + $this->token['attr'][] = array( + 'name' => strtolower($char), + 'value' => null + ); + + $this->state = 'attributeName'; + } + } + + private function attributeNameState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + /* U+0009 CHARACTER TABULATION + U+000A LINE FEED (LF) + U+000B LINE TABULATION + U+000C FORM FEED (FF) + U+0020 SPACE + Stay in the before attribute name state. */ + $this->state = 'afterAttributeName'; + + } elseif ($char === '=') { + /* U+003D EQUALS SIGN (=) + Switch to the before attribute value state. */ + $this->state = 'beforeAttributeValue'; + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Emit the current tag token. Switch to the data state. */ + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif ($char === '/' && $this->character($this->char + 1) !== '>') { + /* U+002F SOLIDUS (/) + Parse error unless this is a permitted slash. Switch to the before + attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($this->char === $this->EOF) { + /* EOF + Parse error. Emit the current tag token. Reconsume the EOF + character in the data state. */ + $this->emitToken($this->token); + + $this->char--; + $this->state = 'data'; + + } else { + /* Anything else + Append the current input character to the current attribute's name. + Stay in the attribute name state. */ + $last = count($this->token['attr']) - 1; + $this->token['attr'][$last]['name'] .= strtolower($char); + + $this->state = 'attributeName'; + } + } + + private function afterAttributeNameState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + /* U+0009 CHARACTER TABULATION + U+000A LINE FEED (LF) + U+000B LINE TABULATION + U+000C FORM FEED (FF) + U+0020 SPACE + Stay in the after attribute name state. */ + $this->state = 'afterAttributeName'; + + } elseif ($char === '=') { + /* U+003D EQUALS SIGN (=) + Switch to the before attribute value state. */ + $this->state = 'beforeAttributeValue'; + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Emit the current tag token. Switch to the data state. */ + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif ($char === '/' && $this->character($this->char + 1) !== '>') { + /* U+002F SOLIDUS (/) + Parse error unless this is a permitted slash. Switch to the + before attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($this->char === $this->EOF) { + /* EOF + Parse error. Emit the current tag token. Reconsume the EOF + character in the data state. */ + $this->emitToken($this->token); + + $this->char--; + $this->state = 'data'; + + } else { + /* Anything else + Start a new attribute in the current tag token. Set that attribute's + name to the current input character, and its value to the empty string. + Switch to the attribute name state. */ + $this->token['attr'][] = array( + 'name' => strtolower($char), + 'value' => null + ); + + $this->state = 'attributeName'; + } + } + + private function beforeAttributeValueState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + /* U+0009 CHARACTER TABULATION + U+000A LINE FEED (LF) + U+000B LINE TABULATION + U+000C FORM FEED (FF) + U+0020 SPACE + Stay in the before attribute value state. */ + $this->state = 'beforeAttributeValue'; + + } elseif ($char === '"') { + /* U+0022 QUOTATION MARK (") + Switch to the attribute value (double-quoted) state. */ + $this->state = 'attributeValueDoubleQuoted'; + + } elseif ($char === '&') { + /* U+0026 AMPERSAND (&) + Switch to the attribute value (unquoted) state and reconsume + this input character. */ + $this->char--; + $this->state = 'attributeValueUnquoted'; + + } elseif ($char === '\'') { + /* U+0027 APOSTROPHE (') + Switch to the attribute value (single-quoted) state. */ + $this->state = 'attributeValueSingleQuoted'; + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Emit the current tag token. Switch to the data state. */ + $this->emitToken($this->token); + $this->state = 'data'; + + } else { + /* Anything else + Append the current input character to the current attribute's value. + Switch to the attribute value (unquoted) state. */ + $last = count($this->token['attr']) - 1; + $this->token['attr'][$last]['value'] .= $char; + + $this->state = 'attributeValueUnquoted'; + } + } + + private function attributeValueDoubleQuotedState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if ($char === '"') { + /* U+0022 QUOTATION MARK (") + Switch to the before attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($char === '&') { + /* U+0026 AMPERSAND (&) + Switch to the entity in attribute value state. */ + $this->entityInAttributeValueState('double'); + + } elseif ($this->char === $this->EOF) { + /* EOF + Parse error. Emit the current tag token. Reconsume the character + in the data state. */ + $this->emitToken($this->token); + + $this->char--; + $this->state = 'data'; + + } else { + /* Anything else + Append the current input character to the current attribute's value. + Stay in the attribute value (double-quoted) state. */ + $last = count($this->token['attr']) - 1; + $this->token['attr'][$last]['value'] .= $char; + + $this->state = 'attributeValueDoubleQuoted'; + } + } + + private function attributeValueSingleQuotedState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if ($char === '\'') { + /* U+0022 QUOTATION MARK (') + Switch to the before attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($char === '&') { + /* U+0026 AMPERSAND (&) + Switch to the entity in attribute value state. */ + $this->entityInAttributeValueState('single'); + + } elseif ($this->char === $this->EOF) { + /* EOF + Parse error. Emit the current tag token. Reconsume the character + in the data state. */ + $this->emitToken($this->token); + + $this->char--; + $this->state = 'data'; + + } else { + /* Anything else + Append the current input character to the current attribute's value. + Stay in the attribute value (single-quoted) state. */ + $last = count($this->token['attr']) - 1; + $this->token['attr'][$last]['value'] .= $char; + + $this->state = 'attributeValueSingleQuoted'; + } + } + + private function attributeValueUnquotedState() + { + // Consume the next input character: + $this->char++; + $char = $this->character($this->char); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + /* U+0009 CHARACTER TABULATION + U+000A LINE FEED (LF) + U+000B LINE TABULATION + U+000C FORM FEED (FF) + U+0020 SPACE + Switch to the before attribute name state. */ + $this->state = 'beforeAttributeName'; + + } elseif ($char === '&') { + /* U+0026 AMPERSAND (&) + Switch to the entity in attribute value state. */ + $this->entityInAttributeValueState(); + + } elseif ($char === '>') { + /* U+003E GREATER-THAN SIGN (>) + Emit the current tag token. Switch to the data state. */ + $this->emitToken($this->token); + $this->state = 'data'; + + } else { + /* Anything else + Append the current input character to the current attribute's value. + Stay in the attribute value (unquoted) state. */ + $last = count($this->token['attr']) - 1; + $this->token['attr'][$last]['value'] .= $char; + + $this->state = 'attributeValueUnquoted'; + } + } + + private function entityInAttributeValueState() + { + // Attempt to consume an entity. + $entity = $this->entity(); + + // If nothing is returned, append a U+0026 AMPERSAND character to the + // current attribute's value. Otherwise, emit the character token that + // was returned. + $char = (!$entity) + ? '&' + : $entity; + + $last = count($this->token['attr']) - 1; + $this->token['attr'][$last]['value'] .= $char; + } + + private function bogusCommentState() + { + /* Consume every character up to the first U+003E GREATER-THAN SIGN + character (>) or the end of the file (EOF), whichever comes first. Emit + a comment token whose data is the concatenation of all the characters + starting from and including the character that caused the state machine + to switch into the bogus comment state, up to and including the last + consumed character before the U+003E character, if any, or up to the + end of the file otherwise. (If the comment was started by the end of + the file (EOF), the token is empty.) */ + $data = $this->characters('^>', $this->char); + $this->emitToken( + array( + 'data' => $data, + 'type' => self::COMMENT + ) + ); + + $this->char += strlen($data); + + /* Switch to the data state. */ + $this->state = 'data'; + + /* If the end of the file was reached, reconsume the EOF character. */ + if ($this->char === $this->EOF) { + $this->char = $this->EOF - 1; + } + } + + private function markupDeclarationOpenState() + { + /* If the next two characters are both U+002D HYPHEN-MINUS (-) + characters, consume those two characters, create a comment token whose + data is the empty string, and switch to the comment state. */ + if ($this->character($this->char + 1, 2) === '--') { + $this->char += 2; + $this->state = 'comment'; + $this->token = array( + 'data' => null, + 'type' => self::COMMENT + ); + + /* Otherwise if the next seven chacacters are a case-insensitive match + for the word "DOCTYPE", then consume those characters and switch to the + DOCTYPE state. */ + } elseif (strtolower($this->character($this->char + 1, 7)) === 'doctype') { + $this->char += 7; + $this->state = 'doctype'; + + /* Otherwise, is is a parse error. Switch to the bogus comment state. + The next character that is consumed, if any, is the first character + that will be in the comment. */ + } else { + $this->char++; + $this->state = 'bogusComment'; + } + } + + private function commentState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + /* U+002D HYPHEN-MINUS (-) */ + if ($char === '-') { + /* Switch to the comment dash state */ + $this->state = 'commentDash'; + + /* EOF */ + } elseif ($this->char === $this->EOF) { + /* Parse error. Emit the comment token. Reconsume the EOF character + in the data state. */ + $this->emitToken($this->token); + $this->char--; + $this->state = 'data'; + + /* Anything else */ + } else { + /* Append the input character to the comment token's data. Stay in + the comment state. */ + $this->token['data'] .= $char; + } + } + + private function commentDashState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + /* U+002D HYPHEN-MINUS (-) */ + if ($char === '-') { + /* Switch to the comment end state */ + $this->state = 'commentEnd'; + + /* EOF */ + } elseif ($this->char === $this->EOF) { + /* Parse error. Emit the comment token. Reconsume the EOF character + in the data state. */ + $this->emitToken($this->token); + $this->char--; + $this->state = 'data'; + + /* Anything else */ + } else { + /* Append a U+002D HYPHEN-MINUS (-) character and the input + character to the comment token's data. Switch to the comment state. */ + $this->token['data'] .= '-' . $char; + $this->state = 'comment'; + } + } + + private function commentEndState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + if ($char === '>') { + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif ($char === '-') { + $this->token['data'] .= '-'; + + } elseif ($this->char === $this->EOF) { + $this->emitToken($this->token); + $this->char--; + $this->state = 'data'; + + } else { + $this->token['data'] .= '--' . $char; + $this->state = 'comment'; + } + } + + private function doctypeState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + $this->state = 'beforeDoctypeName'; + + } else { + $this->char--; + $this->state = 'beforeDoctypeName'; + } + } + + private function beforeDoctypeNameState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + // Stay in the before DOCTYPE name state. + + } elseif (preg_match('/^[a-z]$/', $char)) { + $this->token = array( + 'name' => strtoupper($char), + 'type' => self::DOCTYPE, + 'error' => true + ); + + $this->state = 'doctypeName'; + + } elseif ($char === '>') { + $this->emitToken( + array( + 'name' => null, + 'type' => self::DOCTYPE, + 'error' => true + ) + ); + + $this->state = 'data'; + + } elseif ($this->char === $this->EOF) { + $this->emitToken( + array( + 'name' => null, + 'type' => self::DOCTYPE, + 'error' => true + ) + ); + + $this->char--; + $this->state = 'data'; + + } else { + $this->token = array( + 'name' => $char, + 'type' => self::DOCTYPE, + 'error' => true + ); + + $this->state = 'doctypeName'; + } + } + + private function doctypeNameState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + $this->state = 'AfterDoctypeName'; + + } elseif ($char === '>') { + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif (preg_match('/^[a-z]$/', $char)) { + $this->token['name'] .= strtoupper($char); + + } elseif ($this->char === $this->EOF) { + $this->emitToken($this->token); + $this->char--; + $this->state = 'data'; + + } else { + $this->token['name'] .= $char; + } + + $this->token['error'] = ($this->token['name'] === 'HTML') + ? false + : true; + } + + private function afterDoctypeNameState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + if (preg_match('/^[\t\n\x0b\x0c ]$/', $char)) { + // Stay in the DOCTYPE name state. + + } elseif ($char === '>') { + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif ($this->char === $this->EOF) { + $this->emitToken($this->token); + $this->char--; + $this->state = 'data'; + + } else { + $this->token['error'] = true; + $this->state = 'bogusDoctype'; + } + } + + private function bogusDoctypeState() + { + /* Consume the next input character: */ + $this->char++; + $char = $this->char(); + + if ($char === '>') { + $this->emitToken($this->token); + $this->state = 'data'; + + } elseif ($this->char === $this->EOF) { + $this->emitToken($this->token); + $this->char--; + $this->state = 'data'; + + } else { + // Stay in the bogus DOCTYPE state. + } + } + + private function entity() + { + $start = $this->char; + + // This section defines how to consume an entity. This definition is + // used when parsing entities in text and in attributes. + + // The behaviour depends on the identity of the next character (the + // one immediately after the U+0026 AMPERSAND character): + + switch ($this->character($this->char + 1)) { + // U+0023 NUMBER SIGN (#) + case '#': + + // The behaviour further depends on the character after the + // U+0023 NUMBER SIGN: + switch ($this->character($this->char + 1)) { + // U+0078 LATIN SMALL LETTER X + // U+0058 LATIN CAPITAL LETTER X + case 'x': + case 'X': + // Follow the steps below, but using the range of + // characters U+0030 DIGIT ZERO through to U+0039 DIGIT + // NINE, U+0061 LATIN SMALL LETTER A through to U+0066 + // LATIN SMALL LETTER F, and U+0041 LATIN CAPITAL LETTER + // A, through to U+0046 LATIN CAPITAL LETTER F (in other + // words, 0-9, A-F, a-f). + $char = 1; + $char_class = '0-9A-Fa-f'; + break; + + // Anything else + default: + // Follow the steps below, but using the range of + // characters U+0030 DIGIT ZERO through to U+0039 DIGIT + // NINE (i.e. just 0-9). + $char = 0; + $char_class = '0-9'; + break; + } + + // Consume as many characters as match the range of characters + // given above. + $this->char++; + $e_name = $this->characters($char_class, $this->char + $char + 1); + $entity = $this->character($start, $this->char); + $cond = strlen($e_name) > 0; + + // The rest of the parsing happens below. + break; + + // Anything else + default: + // Consume the maximum number of characters possible, with the + // consumed characters case-sensitively matching one of the + // identifiers in the first column of the entities table. + + $e_name = $this->characters('0-9A-Za-z;', $this->char + 1); + $len = strlen($e_name); + + for ($c = 1; $c <= $len; $c++) { + $id = substr($e_name, 0, $c); + $this->char++; + + if (in_array($id, $this->entities)) { + if ($e_name[$c - 1] !== ';') { + if ($c < $len && $e_name[$c] == ';') { + $this->char++; // consume extra semicolon + } + } + $entity = $id; + break; + } + } + + $cond = isset($entity); + // The rest of the parsing happens below. + break; + } + + if (!$cond) { + // If no match can be made, then this is a parse error. No + // characters are consumed, and nothing is returned. + $this->char = $start; + return false; + } + + // Return a character token for the character corresponding to the + // entity name (as given by the second column of the entities table). + return html_entity_decode('&' . rtrim($entity, ';') . ';', ENT_QUOTES, 'UTF-8'); + } + + private function emitToken($token) + { + $emit = $this->tree->emitToken($token); + + if (is_int($emit)) { + $this->content_model = $emit; + + } elseif ($token['type'] === self::ENDTAG) { + $this->content_model = self::PCDATA; + } + } + + private function EOF() + { + $this->state = null; + $this->tree->emitToken( + array( + 'type' => self::EOF + ) + ); + } +} + +class HTML5TreeConstructer +{ + public $stack = array(); + + private $phase; + private $mode; + private $dom; + private $foster_parent = null; + private $a_formatting = array(); + + private $head_pointer = null; + private $form_pointer = null; + + private $scoping = array('button', 'caption', 'html', 'marquee', 'object', 'table', 'td', 'th'); + private $formatting = array( + 'a', + 'b', + 'big', + 'em', + 'font', + 'i', + 'nobr', + 's', + 'small', + 'strike', + 'strong', + 'tt', + 'u' + ); + private $special = array( + 'address', + 'area', + 'base', + 'basefont', + 'bgsound', + 'blockquote', + 'body', + 'br', + 'center', + 'col', + 'colgroup', + 'dd', + 'dir', + 'div', + 'dl', + 'dt', + 'embed', + 'fieldset', + 'form', + 'frame', + 'frameset', + 'h1', + 'h2', + 'h3', + 'h4', + 'h5', + 'h6', + 'head', + 'hr', + 'iframe', + 'image', + 'img', + 'input', + 'isindex', + 'li', + 'link', + 'listing', + 'menu', + 'meta', + 'noembed', + 'noframes', + 'noscript', + 'ol', + 'optgroup', + 'option', + 'p', + 'param', + 'plaintext', + 'pre', + 'script', + 'select', + 'spacer', + 'style', + 'tbody', + 'textarea', + 'tfoot', + 'thead', + 'title', + 'tr', + 'ul', + 'wbr' + ); + + // The different phases. + const INIT_PHASE = 0; + const ROOT_PHASE = 1; + const MAIN_PHASE = 2; + const END_PHASE = 3; + + // The different insertion modes for the main phase. + const BEFOR_HEAD = 0; + const IN_HEAD = 1; + const AFTER_HEAD = 2; + const IN_BODY = 3; + const IN_TABLE = 4; + const IN_CAPTION = 5; + const IN_CGROUP = 6; + const IN_TBODY = 7; + const IN_ROW = 8; + const IN_CELL = 9; + const IN_SELECT = 10; + const AFTER_BODY = 11; + const IN_FRAME = 12; + const AFTR_FRAME = 13; + + // The different types of elements. + const SPECIAL = 0; + const SCOPING = 1; + const FORMATTING = 2; + const PHRASING = 3; + + const MARKER = 0; + + public function __construct() + { + $this->phase = self::INIT_PHASE; + $this->mode = self::BEFOR_HEAD; + $this->dom = new DOMDocument; + + $this->dom->encoding = 'UTF-8'; + $this->dom->preserveWhiteSpace = true; + $this->dom->substituteEntities = true; + $this->dom->strictErrorChecking = false; + } + + // Process tag tokens + public function emitToken($token) + { + switch ($this->phase) { + case self::INIT_PHASE: + return $this->initPhase($token); + break; + case self::ROOT_PHASE: + return $this->rootElementPhase($token); + break; + case self::MAIN_PHASE: + return $this->mainPhase($token); + break; + case self::END_PHASE : + return $this->trailingEndPhase($token); + break; + } + } + + private function initPhase($token) + { + /* Initially, the tree construction stage must handle each token + emitted from the tokenisation stage as follows: */ + + /* A DOCTYPE token that is marked as being in error + A comment token + A start tag token + An end tag token + A character token that is not one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE + An end-of-file token */ + if ((isset($token['error']) && $token['error']) || + $token['type'] === HTML5::COMMENT || + $token['type'] === HTML5::STARTTAG || + $token['type'] === HTML5::ENDTAG || + $token['type'] === HTML5::EOF || + ($token['type'] === HTML5::CHARACTR && isset($token['data']) && + !preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) + ) { + /* This specification does not define how to handle this case. In + particular, user agents may ignore the entirety of this specification + altogether for such documents, and instead invoke special parse modes + with a greater emphasis on backwards compatibility. */ + + $this->phase = self::ROOT_PHASE; + return $this->rootElementPhase($token); + + /* A DOCTYPE token marked as being correct */ + } elseif (isset($token['error']) && !$token['error']) { + /* Append a DocumentType node to the Document node, with the name + attribute set to the name given in the DOCTYPE token (which will be + "HTML"), and the other attributes specific to DocumentType objects + set to null, empty lists, or the empty string as appropriate. */ + $doctype = new DOMDocumentType(null, null, 'HTML'); + + /* Then, switch to the root element phase of the tree construction + stage. */ + $this->phase = self::ROOT_PHASE; + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + } elseif (isset($token['data']) && preg_match( + '/^[\t\n\x0b\x0c ]+$/', + $token['data'] + ) + ) { + /* Append that character to the Document node. */ + $text = $this->dom->createTextNode($token['data']); + $this->dom->appendChild($text); + } + } + + private function rootElementPhase($token) + { + /* After the initial phase, as each token is emitted from the tokenisation + stage, it must be processed as described in this section. */ + + /* A DOCTYPE token */ + if ($token['type'] === HTML5::DOCTYPE) { + // Parse error. Ignore the token. + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the Document object with the data + attribute set to the data given in the comment token. */ + $comment = $this->dom->createComment($token['data']); + $this->dom->appendChild($comment); + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + } elseif ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Append that character to the Document node. */ + $text = $this->dom->createTextNode($token['data']); + $this->dom->appendChild($text); + + /* A character token that is not one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED + (FF), or U+0020 SPACE + A start tag token + An end tag token + An end-of-file token */ + } elseif (($token['type'] === HTML5::CHARACTR && + !preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) || + $token['type'] === HTML5::STARTTAG || + $token['type'] === HTML5::ENDTAG || + $token['type'] === HTML5::EOF + ) { + /* Create an HTMLElement node with the tag name html, in the HTML + namespace. Append it to the Document object. Switch to the main + phase and reprocess the current token. */ + $html = $this->dom->createElement('html'); + $this->dom->appendChild($html); + $this->stack[] = $html; + + $this->phase = self::MAIN_PHASE; + return $this->mainPhase($token); + } + } + + private function mainPhase($token) + { + /* Tokens in the main phase must be handled as follows: */ + + /* A DOCTYPE token */ + if ($token['type'] === HTML5::DOCTYPE) { + // Parse error. Ignore the token. + + /* A start tag token with the tag name "html" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'html') { + /* If this start tag token was not the first start tag token, then + it is a parse error. */ + + /* For each attribute on the token, check to see if the attribute + is already present on the top element of the stack of open elements. + If it is not, add the attribute and its corresponding value to that + element. */ + foreach ($token['attr'] as $attr) { + if (!$this->stack[0]->hasAttribute($attr['name'])) { + $this->stack[0]->setAttribute($attr['name'], $attr['value']); + } + } + + /* An end-of-file token */ + } elseif ($token['type'] === HTML5::EOF) { + /* Generate implied end tags. */ + $this->generateImpliedEndTags(); + + /* Anything else. */ + } else { + /* Depends on the insertion mode: */ + switch ($this->mode) { + case self::BEFOR_HEAD: + return $this->beforeHead($token); + break; + case self::IN_HEAD: + return $this->inHead($token); + break; + case self::AFTER_HEAD: + return $this->afterHead($token); + break; + case self::IN_BODY: + return $this->inBody($token); + break; + case self::IN_TABLE: + return $this->inTable($token); + break; + case self::IN_CAPTION: + return $this->inCaption($token); + break; + case self::IN_CGROUP: + return $this->inColumnGroup($token); + break; + case self::IN_TBODY: + return $this->inTableBody($token); + break; + case self::IN_ROW: + return $this->inRow($token); + break; + case self::IN_CELL: + return $this->inCell($token); + break; + case self::IN_SELECT: + return $this->inSelect($token); + break; + case self::AFTER_BODY: + return $this->afterBody($token); + break; + case self::IN_FRAME: + return $this->inFrameset($token); + break; + case self::AFTR_FRAME: + return $this->afterFrameset($token); + break; + case self::END_PHASE: + return $this->trailingEndPhase($token); + break; + } + } + } + + private function beforeHead($token) + { + /* Handle the token as follows: */ + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + if ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Append the character to the current node. */ + $this->insertText($token['data']); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data attribute + set to the data given in the comment token. */ + $this->insertComment($token['data']); + + /* A start tag token with the tag name "head" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'head') { + /* Create an element for the token, append the new element to the + current node and push it onto the stack of open elements. */ + $element = $this->insertElement($token); + + /* Set the head element pointer to this new element node. */ + $this->head_pointer = $element; + + /* Change the insertion mode to "in head". */ + $this->mode = self::IN_HEAD; + + /* A start tag token whose tag name is one of: "base", "link", "meta", + "script", "style", "title". Or an end tag with the tag name "html". + Or a character token that is not one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE. Or any other start tag token */ + } elseif ($token['type'] === HTML5::STARTTAG || + ($token['type'] === HTML5::ENDTAG && $token['name'] === 'html') || + ($token['type'] === HTML5::CHARACTR && !preg_match( + '/^[\t\n\x0b\x0c ]$/', + $token['data'] + )) + ) { + /* Act as if a start tag token with the tag name "head" and no + attributes had been seen, then reprocess the current token. */ + $this->beforeHead( + array( + 'name' => 'head', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + return $this->inHead($token); + + /* Any other end tag */ + } elseif ($token['type'] === HTML5::ENDTAG) { + /* Parse error. Ignore the token. */ + } + } + + private function inHead($token) + { + /* Handle the token as follows: */ + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE. + + THIS DIFFERS FROM THE SPEC: If the current node is either a title, style + or script element, append the character to the current node regardless + of its content. */ + if (($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) || ( + $token['type'] === HTML5::CHARACTR && in_array( + end($this->stack)->nodeName, + array('title', 'style', 'script') + )) + ) { + /* Append the character to the current node. */ + $this->insertText($token['data']); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data attribute + set to the data given in the comment token. */ + $this->insertComment($token['data']); + + } elseif ($token['type'] === HTML5::ENDTAG && + in_array($token['name'], array('title', 'style', 'script')) + ) { + array_pop($this->stack); + return HTML5::PCDATA; + + /* A start tag with the tag name "title" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'title') { + /* Create an element for the token and append the new element to the + node pointed to by the head element pointer, or, if that is null + (innerHTML case), to the current node. */ + if ($this->head_pointer !== null) { + $element = $this->insertElement($token, false); + $this->head_pointer->appendChild($element); + + } else { + $element = $this->insertElement($token); + } + + /* Switch the tokeniser's content model flag to the RCDATA state. */ + return HTML5::RCDATA; + + /* A start tag with the tag name "style" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'style') { + /* Create an element for the token and append the new element to the + node pointed to by the head element pointer, or, if that is null + (innerHTML case), to the current node. */ + if ($this->head_pointer !== null) { + $element = $this->insertElement($token, false); + $this->head_pointer->appendChild($element); + + } else { + $this->insertElement($token); + } + + /* Switch the tokeniser's content model flag to the CDATA state. */ + return HTML5::CDATA; + + /* A start tag with the tag name "script" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'script') { + /* Create an element for the token. */ + $element = $this->insertElement($token, false); + $this->head_pointer->appendChild($element); + + /* Switch the tokeniser's content model flag to the CDATA state. */ + return HTML5::CDATA; + + /* A start tag with the tag name "base", "link", or "meta" */ + } elseif ($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array('base', 'link', 'meta') + ) + ) { + /* Create an element for the token and append the new element to the + node pointed to by the head element pointer, or, if that is null + (innerHTML case), to the current node. */ + if ($this->head_pointer !== null) { + $element = $this->insertElement($token, false); + $this->head_pointer->appendChild($element); + array_pop($this->stack); + + } else { + $this->insertElement($token); + } + + /* An end tag with the tag name "head" */ + } elseif ($token['type'] === HTML5::ENDTAG && $token['name'] === 'head') { + /* If the current node is a head element, pop the current node off + the stack of open elements. */ + if ($this->head_pointer->isSameNode(end($this->stack))) { + array_pop($this->stack); + + /* Otherwise, this is a parse error. */ + } else { + // k + } + + /* Change the insertion mode to "after head". */ + $this->mode = self::AFTER_HEAD; + + /* A start tag with the tag name "head" or an end tag except "html". */ + } elseif (($token['type'] === HTML5::STARTTAG && $token['name'] === 'head') || + ($token['type'] === HTML5::ENDTAG && $token['name'] !== 'html') + ) { + // Parse error. Ignore the token. + + /* Anything else */ + } else { + /* If the current node is a head element, act as if an end tag + token with the tag name "head" had been seen. */ + if ($this->head_pointer->isSameNode(end($this->stack))) { + $this->inHead( + array( + 'name' => 'head', + 'type' => HTML5::ENDTAG + ) + ); + + /* Otherwise, change the insertion mode to "after head". */ + } else { + $this->mode = self::AFTER_HEAD; + } + + /* Then, reprocess the current token. */ + return $this->afterHead($token); + } + } + + private function afterHead($token) + { + /* Handle the token as follows: */ + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + if ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Append the character to the current node. */ + $this->insertText($token['data']); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data attribute + set to the data given in the comment token. */ + $this->insertComment($token['data']); + + /* A start tag token with the tag name "body" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'body') { + /* Insert a body element for the token. */ + $this->insertElement($token); + + /* Change the insertion mode to "in body". */ + $this->mode = self::IN_BODY; + + /* A start tag token with the tag name "frameset" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'frameset') { + /* Insert a frameset element for the token. */ + $this->insertElement($token); + + /* Change the insertion mode to "in frameset". */ + $this->mode = self::IN_FRAME; + + /* A start tag token whose tag name is one of: "base", "link", "meta", + "script", "style", "title" */ + } elseif ($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array('base', 'link', 'meta', 'script', 'style', 'title') + ) + ) { + /* Parse error. Switch the insertion mode back to "in head" and + reprocess the token. */ + $this->mode = self::IN_HEAD; + return $this->inHead($token); + + /* Anything else */ + } else { + /* Act as if a start tag token with the tag name "body" and no + attributes had been seen, and then reprocess the current token. */ + $this->afterHead( + array( + 'name' => 'body', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + return $this->inBody($token); + } + } + + private function inBody($token) + { + /* Handle the token as follows: */ + + switch ($token['type']) { + /* A character token */ + case HTML5::CHARACTR: + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Append the token's character to the current node. */ + $this->insertText($token['data']); + break; + + /* A comment token */ + case HTML5::COMMENT: + /* Append a Comment node to the current node with the data + attribute set to the data given in the comment token. */ + $this->insertComment($token['data']); + break; + + case HTML5::STARTTAG: + switch ($token['name']) { + /* A start tag token whose tag name is one of: "script", + "style" */ + case 'script': + case 'style': + /* Process the token as if the insertion mode had been "in + head". */ + return $this->inHead($token); + break; + + /* A start tag token whose tag name is one of: "base", "link", + "meta", "title" */ + case 'base': + case 'link': + case 'meta': + case 'title': + /* Parse error. Process the token as if the insertion mode + had been "in head". */ + return $this->inHead($token); + break; + + /* A start tag token with the tag name "body" */ + case 'body': + /* Parse error. If the second element on the stack of open + elements is not a body element, or, if the stack of open + elements has only one node on it, then ignore the token. + (innerHTML case) */ + if (count($this->stack) === 1 || $this->stack[1]->nodeName !== 'body') { + // Ignore + + /* Otherwise, for each attribute on the token, check to see + if the attribute is already present on the body element (the + second element) on the stack of open elements. If it is not, + add the attribute and its corresponding value to that + element. */ + } else { + foreach ($token['attr'] as $attr) { + if (!$this->stack[1]->hasAttribute($attr['name'])) { + $this->stack[1]->setAttribute($attr['name'], $attr['value']); + } + } + } + break; + + /* A start tag whose tag name is one of: "address", + "blockquote", "center", "dir", "div", "dl", "fieldset", + "listing", "menu", "ol", "p", "ul" */ + case 'address': + case 'blockquote': + case 'center': + case 'dir': + case 'div': + case 'dl': + case 'fieldset': + case 'listing': + case 'menu': + case 'ol': + case 'p': + case 'ul': + /* If the stack of open elements has a p element in scope, + then act as if an end tag with the tag name p had been + seen. */ + if ($this->elementInScope('p')) { + $this->emitToken( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + break; + + /* A start tag whose tag name is "form" */ + case 'form': + /* If the form element pointer is not null, ignore the + token with a parse error. */ + if ($this->form_pointer !== null) { + // Ignore. + + /* Otherwise: */ + } else { + /* If the stack of open elements has a p element in + scope, then act as if an end tag with the tag name p + had been seen. */ + if ($this->elementInScope('p')) { + $this->emitToken( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Insert an HTML element for the token, and set the + form element pointer to point to the element created. */ + $element = $this->insertElement($token); + $this->form_pointer = $element; + } + break; + + /* A start tag whose tag name is "li", "dd" or "dt" */ + case 'li': + case 'dd': + case 'dt': + /* If the stack of open elements has a p element in scope, + then act as if an end tag with the tag name p had been + seen. */ + if ($this->elementInScope('p')) { + $this->emitToken( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + } + + $stack_length = count($this->stack) - 1; + + for ($n = $stack_length; 0 <= $n; $n--) { + /* 1. Initialise node to be the current node (the + bottommost node of the stack). */ + $stop = false; + $node = $this->stack[$n]; + $cat = $this->getElementCategory($node->tagName); + + /* 2. If node is an li, dd or dt element, then pop all + the nodes from the current node up to node, including + node, then stop this algorithm. */ + if ($token['name'] === $node->tagName || ($token['name'] !== 'li' + && ($node->tagName === 'dd' || $node->tagName === 'dt')) + ) { + for ($x = $stack_length; $x >= $n; $x--) { + array_pop($this->stack); + } + + break; + } + + /* 3. If node is not in the formatting category, and is + not in the phrasing category, and is not an address or + div element, then stop this algorithm. */ + if ($cat !== self::FORMATTING && $cat !== self::PHRASING && + $node->tagName !== 'address' && $node->tagName !== 'div' + ) { + break; + } + } + + /* Finally, insert an HTML element with the same tag + name as the token's. */ + $this->insertElement($token); + break; + + /* A start tag token whose tag name is "plaintext" */ + case 'plaintext': + /* If the stack of open elements has a p element in scope, + then act as if an end tag with the tag name p had been + seen. */ + if ($this->elementInScope('p')) { + $this->emitToken( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + return HTML5::PLAINTEXT; + break; + + /* A start tag whose tag name is one of: "h1", "h2", "h3", "h4", + "h5", "h6" */ + case 'h1': + case 'h2': + case 'h3': + case 'h4': + case 'h5': + case 'h6': + /* If the stack of open elements has a p element in scope, + then act as if an end tag with the tag name p had been seen. */ + if ($this->elementInScope('p')) { + $this->emitToken( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* If the stack of open elements has in scope an element whose + tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6", then + this is a parse error; pop elements from the stack until an + element with one of those tag names has been popped from the + stack. */ + while ($this->elementInScope(array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'))) { + array_pop($this->stack); + } + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + break; + + /* A start tag whose tag name is "a" */ + case 'a': + /* If the list of active formatting elements contains + an element whose tag name is "a" between the end of the + list and the last marker on the list (or the start of + the list if there is no marker on the list), then this + is a parse error; act as if an end tag with the tag name + "a" had been seen, then remove that element from the list + of active formatting elements and the stack of open + elements if the end tag didn't already remove it (it + might not have if the element is not in table scope). */ + $leng = count($this->a_formatting); + + for ($n = $leng - 1; $n >= 0; $n--) { + if ($this->a_formatting[$n] === self::MARKER) { + break; + + } elseif ($this->a_formatting[$n]->nodeName === 'a') { + $this->emitToken( + array( + 'name' => 'a', + 'type' => HTML5::ENDTAG + ) + ); + break; + } + } + + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an HTML element for the token. */ + $el = $this->insertElement($token); + + /* Add that element to the list of active formatting + elements. */ + $this->a_formatting[] = $el; + break; + + /* A start tag whose tag name is one of: "b", "big", "em", "font", + "i", "nobr", "s", "small", "strike", "strong", "tt", "u" */ + case 'b': + case 'big': + case 'em': + case 'font': + case 'i': + case 'nobr': + case 's': + case 'small': + case 'strike': + case 'strong': + case 'tt': + case 'u': + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an HTML element for the token. */ + $el = $this->insertElement($token); + + /* Add that element to the list of active formatting + elements. */ + $this->a_formatting[] = $el; + break; + + /* A start tag token whose tag name is "button" */ + case 'button': + /* If the stack of open elements has a button element in scope, + then this is a parse error; act as if an end tag with the tag + name "button" had been seen, then reprocess the token. (We don't + do that. Unnecessary.) */ + if ($this->elementInScope('button')) { + $this->inBody( + array( + 'name' => 'button', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Insert a marker at the end of the list of active + formatting elements. */ + $this->a_formatting[] = self::MARKER; + break; + + /* A start tag token whose tag name is one of: "marquee", "object" */ + case 'marquee': + case 'object': + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Insert a marker at the end of the list of active + formatting elements. */ + $this->a_formatting[] = self::MARKER; + break; + + /* A start tag token whose tag name is "xmp" */ + case 'xmp': + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Switch the content model flag to the CDATA state. */ + return HTML5::CDATA; + break; + + /* A start tag whose tag name is "table" */ + case 'table': + /* If the stack of open elements has a p element in scope, + then act as if an end tag with the tag name p had been seen. */ + if ($this->elementInScope('p')) { + $this->emitToken( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Change the insertion mode to "in table". */ + $this->mode = self::IN_TABLE; + break; + + /* A start tag whose tag name is one of: "area", "basefont", + "bgsound", "br", "embed", "img", "param", "spacer", "wbr" */ + case 'area': + case 'basefont': + case 'bgsound': + case 'br': + case 'embed': + case 'img': + case 'param': + case 'spacer': + case 'wbr': + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Immediately pop the current node off the stack of open elements. */ + array_pop($this->stack); + break; + + /* A start tag whose tag name is "hr" */ + case 'hr': + /* If the stack of open elements has a p element in scope, + then act as if an end tag with the tag name p had been seen. */ + if ($this->elementInScope('p')) { + $this->emitToken( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Immediately pop the current node off the stack of open elements. */ + array_pop($this->stack); + break; + + /* A start tag whose tag name is "image" */ + case 'image': + /* Parse error. Change the token's tag name to "img" and + reprocess it. (Don't ask.) */ + $token['name'] = 'img'; + return $this->inBody($token); + break; + + /* A start tag whose tag name is "input" */ + case 'input': + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an input element for the token. */ + $element = $this->insertElement($token, false); + + /* If the form element pointer is not null, then associate the + input element with the form element pointed to by the form + element pointer. */ + $this->form_pointer !== null + ? $this->form_pointer->appendChild($element) + : end($this->stack)->appendChild($element); + + /* Pop that input element off the stack of open elements. */ + array_pop($this->stack); + break; + + /* A start tag whose tag name is "isindex" */ + case 'isindex': + /* Parse error. */ + // w/e + + /* If the form element pointer is not null, + then ignore the token. */ + if ($this->form_pointer === null) { + /* Act as if a start tag token with the tag name "form" had + been seen. */ + $this->inBody( + array( + 'name' => 'body', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + /* Act as if a start tag token with the tag name "hr" had + been seen. */ + $this->inBody( + array( + 'name' => 'hr', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + /* Act as if a start tag token with the tag name "p" had + been seen. */ + $this->inBody( + array( + 'name' => 'p', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + /* Act as if a start tag token with the tag name "label" + had been seen. */ + $this->inBody( + array( + 'name' => 'label', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + /* Act as if a stream of character tokens had been seen. */ + $this->insertText( + 'This is a searchable index. ' . + 'Insert your search keywords here: ' + ); + + /* Act as if a start tag token with the tag name "input" + had been seen, with all the attributes from the "isindex" + token, except with the "name" attribute set to the value + "isindex" (ignoring any explicit "name" attribute). */ + $attr = $token['attr']; + $attr[] = array('name' => 'name', 'value' => 'isindex'); + + $this->inBody( + array( + 'name' => 'input', + 'type' => HTML5::STARTTAG, + 'attr' => $attr + ) + ); + + /* Act as if a stream of character tokens had been seen + (see below for what they should say). */ + $this->insertText( + 'This is a searchable index. ' . + 'Insert your search keywords here: ' + ); + + /* Act as if an end tag token with the tag name "label" + had been seen. */ + $this->inBody( + array( + 'name' => 'label', + 'type' => HTML5::ENDTAG + ) + ); + + /* Act as if an end tag token with the tag name "p" had + been seen. */ + $this->inBody( + array( + 'name' => 'p', + 'type' => HTML5::ENDTAG + ) + ); + + /* Act as if a start tag token with the tag name "hr" had + been seen. */ + $this->inBody( + array( + 'name' => 'hr', + 'type' => HTML5::ENDTAG + ) + ); + + /* Act as if an end tag token with the tag name "form" had + been seen. */ + $this->inBody( + array( + 'name' => 'form', + 'type' => HTML5::ENDTAG + ) + ); + } + break; + + /* A start tag whose tag name is "textarea" */ + case 'textarea': + $this->insertElement($token); + + /* Switch the tokeniser's content model flag to the + RCDATA state. */ + return HTML5::RCDATA; + break; + + /* A start tag whose tag name is one of: "iframe", "noembed", + "noframes" */ + case 'iframe': + case 'noembed': + case 'noframes': + $this->insertElement($token); + + /* Switch the tokeniser's content model flag to the CDATA state. */ + return HTML5::CDATA; + break; + + /* A start tag whose tag name is "select" */ + case 'select': + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Change the insertion mode to "in select". */ + $this->mode = self::IN_SELECT; + break; + + /* A start or end tag whose tag name is one of: "caption", "col", + "colgroup", "frame", "frameset", "head", "option", "optgroup", + "tbody", "td", "tfoot", "th", "thead", "tr". */ + case 'caption': + case 'col': + case 'colgroup': + case 'frame': + case 'frameset': + case 'head': + case 'option': + case 'optgroup': + case 'tbody': + case 'td': + case 'tfoot': + case 'th': + case 'thead': + case 'tr': + // Parse error. Ignore the token. + break; + + /* A start or end tag whose tag name is one of: "event-source", + "section", "nav", "article", "aside", "header", "footer", + "datagrid", "command" */ + case 'event-source': + case 'section': + case 'nav': + case 'article': + case 'aside': + case 'header': + case 'footer': + case 'datagrid': + case 'command': + // Work in progress! + break; + + /* A start tag token not covered by the previous entries */ + default: + /* Reconstruct the active formatting elements, if any. */ + $this->reconstructActiveFormattingElements(); + + $this->insertElement($token, true, true); + break; + } + break; + + case HTML5::ENDTAG: + switch ($token['name']) { + /* An end tag with the tag name "body" */ + case 'body': + /* If the second element in the stack of open elements is + not a body element, this is a parse error. Ignore the token. + (innerHTML case) */ + if (count($this->stack) < 2 || $this->stack[1]->nodeName !== 'body') { + // Ignore. + + /* If the current node is not the body element, then this + is a parse error. */ + } elseif (end($this->stack)->nodeName !== 'body') { + // Parse error. + } + + /* Change the insertion mode to "after body". */ + $this->mode = self::AFTER_BODY; + break; + + /* An end tag with the tag name "html" */ + case 'html': + /* Act as if an end tag with tag name "body" had been seen, + then, if that token wasn't ignored, reprocess the current + token. */ + $this->inBody( + array( + 'name' => 'body', + 'type' => HTML5::ENDTAG + ) + ); + + return $this->afterBody($token); + break; + + /* An end tag whose tag name is one of: "address", "blockquote", + "center", "dir", "div", "dl", "fieldset", "listing", "menu", + "ol", "pre", "ul" */ + case 'address': + case 'blockquote': + case 'center': + case 'dir': + case 'div': + case 'dl': + case 'fieldset': + case 'listing': + case 'menu': + case 'ol': + case 'pre': + case 'ul': + /* If the stack of open elements has an element in scope + with the same tag name as that of the token, then generate + implied end tags. */ + if ($this->elementInScope($token['name'])) { + $this->generateImpliedEndTags(); + + /* Now, if the current node is not an element with + the same tag name as that of the token, then this + is a parse error. */ + // w/e + + /* If the stack of open elements has an element in + scope with the same tag name as that of the token, + then pop elements from this stack until an element + with that tag name has been popped from the stack. */ + for ($n = count($this->stack) - 1; $n >= 0; $n--) { + if ($this->stack[$n]->nodeName === $token['name']) { + $n = -1; + } + + array_pop($this->stack); + } + } + break; + + /* An end tag whose tag name is "form" */ + case 'form': + /* If the stack of open elements has an element in scope + with the same tag name as that of the token, then generate + implied end tags. */ + if ($this->elementInScope($token['name'])) { + $this->generateImpliedEndTags(); + + } + + if (end($this->stack)->nodeName !== $token['name']) { + /* Now, if the current node is not an element with the + same tag name as that of the token, then this is a parse + error. */ + // w/e + + } else { + /* Otherwise, if the current node is an element with + the same tag name as that of the token pop that element + from the stack. */ + array_pop($this->stack); + } + + /* In any case, set the form element pointer to null. */ + $this->form_pointer = null; + break; + + /* An end tag whose tag name is "p" */ + case 'p': + /* If the stack of open elements has a p element in scope, + then generate implied end tags, except for p elements. */ + if ($this->elementInScope('p')) { + $this->generateImpliedEndTags(array('p')); + + /* If the current node is not a p element, then this is + a parse error. */ + // k + + /* If the stack of open elements has a p element in + scope, then pop elements from this stack until the stack + no longer has a p element in scope. */ + for ($n = count($this->stack) - 1; $n >= 0; $n--) { + if ($this->elementInScope('p')) { + array_pop($this->stack); + + } else { + break; + } + } + } + break; + + /* An end tag whose tag name is "dd", "dt", or "li" */ + case 'dd': + case 'dt': + case 'li': + /* If the stack of open elements has an element in scope + whose tag name matches the tag name of the token, then + generate implied end tags, except for elements with the + same tag name as the token. */ + if ($this->elementInScope($token['name'])) { + $this->generateImpliedEndTags(array($token['name'])); + + /* If the current node is not an element with the same + tag name as the token, then this is a parse error. */ + // w/e + + /* If the stack of open elements has an element in scope + whose tag name matches the tag name of the token, then + pop elements from this stack until an element with that + tag name has been popped from the stack. */ + for ($n = count($this->stack) - 1; $n >= 0; $n--) { + if ($this->stack[$n]->nodeName === $token['name']) { + $n = -1; + } + + array_pop($this->stack); + } + } + break; + + /* An end tag whose tag name is one of: "h1", "h2", "h3", "h4", + "h5", "h6" */ + case 'h1': + case 'h2': + case 'h3': + case 'h4': + case 'h5': + case 'h6': + $elements = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6'); + + /* If the stack of open elements has in scope an element whose + tag name is one of "h1", "h2", "h3", "h4", "h5", or "h6", then + generate implied end tags. */ + if ($this->elementInScope($elements)) { + $this->generateImpliedEndTags(); + + /* Now, if the current node is not an element with the same + tag name as that of the token, then this is a parse error. */ + // w/e + + /* If the stack of open elements has in scope an element + whose tag name is one of "h1", "h2", "h3", "h4", "h5", or + "h6", then pop elements from the stack until an element + with one of those tag names has been popped from the stack. */ + while ($this->elementInScope($elements)) { + array_pop($this->stack); + } + } + break; + + /* An end tag whose tag name is one of: "a", "b", "big", "em", + "font", "i", "nobr", "s", "small", "strike", "strong", "tt", "u" */ + case 'a': + case 'b': + case 'big': + case 'em': + case 'font': + case 'i': + case 'nobr': + case 's': + case 'small': + case 'strike': + case 'strong': + case 'tt': + case 'u': + /* 1. Let the formatting element be the last element in + the list of active formatting elements that: + * is between the end of the list and the last scope + marker in the list, if any, or the start of the list + otherwise, and + * has the same tag name as the token. + */ + while (true) { + for ($a = count($this->a_formatting) - 1; $a >= 0; $a--) { + if ($this->a_formatting[$a] === self::MARKER) { + break; + + } elseif ($this->a_formatting[$a]->tagName === $token['name']) { + $formatting_element = $this->a_formatting[$a]; + $in_stack = in_array($formatting_element, $this->stack, true); + $fe_af_pos = $a; + break; + } + } + + /* If there is no such node, or, if that node is + also in the stack of open elements but the element + is not in scope, then this is a parse error. Abort + these steps. The token is ignored. */ + if (!isset($formatting_element) || ($in_stack && + !$this->elementInScope($token['name'])) + ) { + break; + + /* Otherwise, if there is such a node, but that node + is not in the stack of open elements, then this is a + parse error; remove the element from the list, and + abort these steps. */ + } elseif (isset($formatting_element) && !$in_stack) { + unset($this->a_formatting[$fe_af_pos]); + $this->a_formatting = array_merge($this->a_formatting); + break; + } + + /* 2. Let the furthest block be the topmost node in the + stack of open elements that is lower in the stack + than the formatting element, and is not an element in + the phrasing or formatting categories. There might + not be one. */ + $fe_s_pos = array_search($formatting_element, $this->stack, true); + $length = count($this->stack); + + for ($s = $fe_s_pos + 1; $s < $length; $s++) { + $category = $this->getElementCategory($this->stack[$s]->nodeName); + + if ($category !== self::PHRASING && $category !== self::FORMATTING) { + $furthest_block = $this->stack[$s]; + } + } + + /* 3. If there is no furthest block, then the UA must + skip the subsequent steps and instead just pop all + the nodes from the bottom of the stack of open + elements, from the current node up to the formatting + element, and remove the formatting element from the + list of active formatting elements. */ + if (!isset($furthest_block)) { + for ($n = $length - 1; $n >= $fe_s_pos; $n--) { + array_pop($this->stack); + } + + unset($this->a_formatting[$fe_af_pos]); + $this->a_formatting = array_merge($this->a_formatting); + break; + } + + /* 4. Let the common ancestor be the element + immediately above the formatting element in the stack + of open elements. */ + $common_ancestor = $this->stack[$fe_s_pos - 1]; + + /* 5. If the furthest block has a parent node, then + remove the furthest block from its parent node. */ + if ($furthest_block->parentNode !== null) { + $furthest_block->parentNode->removeChild($furthest_block); + } + + /* 6. Let a bookmark note the position of the + formatting element in the list of active formatting + elements relative to the elements on either side + of it in the list. */ + $bookmark = $fe_af_pos; + + /* 7. Let node and last node be the furthest block. + Follow these steps: */ + $node = $furthest_block; + $last_node = $furthest_block; + + while (true) { + for ($n = array_search($node, $this->stack, true) - 1; $n >= 0; $n--) { + /* 7.1 Let node be the element immediately + prior to node in the stack of open elements. */ + $node = $this->stack[$n]; + + /* 7.2 If node is not in the list of active + formatting elements, then remove node from + the stack of open elements and then go back + to step 1. */ + if (!in_array($node, $this->a_formatting, true)) { + unset($this->stack[$n]); + $this->stack = array_merge($this->stack); + + } else { + break; + } + } + + /* 7.3 Otherwise, if node is the formatting + element, then go to the next step in the overall + algorithm. */ + if ($node === $formatting_element) { + break; + + /* 7.4 Otherwise, if last node is the furthest + block, then move the aforementioned bookmark to + be immediately after the node in the list of + active formatting elements. */ + } elseif ($last_node === $furthest_block) { + $bookmark = array_search($node, $this->a_formatting, true) + 1; + } + + /* 7.5 If node has any children, perform a + shallow clone of node, replace the entry for + node in the list of active formatting elements + with an entry for the clone, replace the entry + for node in the stack of open elements with an + entry for the clone, and let node be the clone. */ + if ($node->hasChildNodes()) { + $clone = $node->cloneNode(); + $s_pos = array_search($node, $this->stack, true); + $a_pos = array_search($node, $this->a_formatting, true); + + $this->stack[$s_pos] = $clone; + $this->a_formatting[$a_pos] = $clone; + $node = $clone; + } + + /* 7.6 Insert last node into node, first removing + it from its previous parent node if any. */ + if ($last_node->parentNode !== null) { + $last_node->parentNode->removeChild($last_node); + } + + $node->appendChild($last_node); + + /* 7.7 Let last node be node. */ + $last_node = $node; + } + + /* 8. Insert whatever last node ended up being in + the previous step into the common ancestor node, + first removing it from its previous parent node if + any. */ + if ($last_node->parentNode !== null) { + $last_node->parentNode->removeChild($last_node); + } + + $common_ancestor->appendChild($last_node); + + /* 9. Perform a shallow clone of the formatting + element. */ + $clone = $formatting_element->cloneNode(); + + /* 10. Take all of the child nodes of the furthest + block and append them to the clone created in the + last step. */ + while ($furthest_block->hasChildNodes()) { + $child = $furthest_block->firstChild; + $furthest_block->removeChild($child); + $clone->appendChild($child); + } + + /* 11. Append that clone to the furthest block. */ + $furthest_block->appendChild($clone); + + /* 12. Remove the formatting element from the list + of active formatting elements, and insert the clone + into the list of active formatting elements at the + position of the aforementioned bookmark. */ + $fe_af_pos = array_search($formatting_element, $this->a_formatting, true); + unset($this->a_formatting[$fe_af_pos]); + $this->a_formatting = array_merge($this->a_formatting); + + $af_part1 = array_slice($this->a_formatting, 0, $bookmark - 1); + $af_part2 = array_slice($this->a_formatting, $bookmark, count($this->a_formatting)); + $this->a_formatting = array_merge($af_part1, array($clone), $af_part2); + + /* 13. Remove the formatting element from the stack + of open elements, and insert the clone into the stack + of open elements immediately after (i.e. in a more + deeply nested position than) the position of the + furthest block in that stack. */ + $fe_s_pos = array_search($formatting_element, $this->stack, true); + $fb_s_pos = array_search($furthest_block, $this->stack, true); + unset($this->stack[$fe_s_pos]); + + $s_part1 = array_slice($this->stack, 0, $fb_s_pos); + $s_part2 = array_slice($this->stack, $fb_s_pos + 1, count($this->stack)); + $this->stack = array_merge($s_part1, array($clone), $s_part2); + + /* 14. Jump back to step 1 in this series of steps. */ + unset($formatting_element, $fe_af_pos, $fe_s_pos, $furthest_block); + } + break; + + /* An end tag token whose tag name is one of: "button", + "marquee", "object" */ + case 'button': + case 'marquee': + case 'object': + /* If the stack of open elements has an element in scope whose + tag name matches the tag name of the token, then generate implied + tags. */ + if ($this->elementInScope($token['name'])) { + $this->generateImpliedEndTags(); + + /* Now, if the current node is not an element with the same + tag name as the token, then this is a parse error. */ + // k + + /* Now, if the stack of open elements has an element in scope + whose tag name matches the tag name of the token, then pop + elements from the stack until that element has been popped from + the stack, and clear the list of active formatting elements up + to the last marker. */ + for ($n = count($this->stack) - 1; $n >= 0; $n--) { + if ($this->stack[$n]->nodeName === $token['name']) { + $n = -1; + } + + array_pop($this->stack); + } + + $marker = end(array_keys($this->a_formatting, self::MARKER, true)); + + for ($n = count($this->a_formatting) - 1; $n > $marker; $n--) { + array_pop($this->a_formatting); + } + } + break; + + /* Or an end tag whose tag name is one of: "area", "basefont", + "bgsound", "br", "embed", "hr", "iframe", "image", "img", + "input", "isindex", "noembed", "noframes", "param", "select", + "spacer", "table", "textarea", "wbr" */ + case 'area': + case 'basefont': + case 'bgsound': + case 'br': + case 'embed': + case 'hr': + case 'iframe': + case 'image': + case 'img': + case 'input': + case 'isindex': + case 'noembed': + case 'noframes': + case 'param': + case 'select': + case 'spacer': + case 'table': + case 'textarea': + case 'wbr': + // Parse error. Ignore the token. + break; + + /* An end tag token not covered by the previous entries */ + default: + for ($n = count($this->stack) - 1; $n >= 0; $n--) { + /* Initialise node to be the current node (the bottommost + node of the stack). */ + $node = end($this->stack); + + /* If node has the same tag name as the end tag token, + then: */ + if ($token['name'] === $node->nodeName) { + /* Generate implied end tags. */ + $this->generateImpliedEndTags(); + + /* If the tag name of the end tag token does not + match the tag name of the current node, this is a + parse error. */ + // k + + /* Pop all the nodes from the current node up to + node, including node, then stop this algorithm. */ + for ($x = count($this->stack) - $n; $x >= $n; $x--) { + array_pop($this->stack); + } + + } else { + $category = $this->getElementCategory($node); + + if ($category !== self::SPECIAL && $category !== self::SCOPING) { + /* Otherwise, if node is in neither the formatting + category nor the phrasing category, then this is a + parse error. Stop this algorithm. The end tag token + is ignored. */ + return false; + } + } + } + break; + } + break; + } + } + + private function inTable($token) + { + $clear = array('html', 'table'); + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + if ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Append the character to the current node. */ + $text = $this->dom->createTextNode($token['data']); + end($this->stack)->appendChild($text); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data + attribute set to the data given in the comment token. */ + $comment = $this->dom->createComment($token['data']); + end($this->stack)->appendChild($comment); + + /* A start tag whose tag name is "caption" */ + } elseif ($token['type'] === HTML5::STARTTAG && + $token['name'] === 'caption' + ) { + /* Clear the stack back to a table context. */ + $this->clearStackToTableContext($clear); + + /* Insert a marker at the end of the list of active + formatting elements. */ + $this->a_formatting[] = self::MARKER; + + /* Insert an HTML element for the token, then switch the + insertion mode to "in caption". */ + $this->insertElement($token); + $this->mode = self::IN_CAPTION; + + /* A start tag whose tag name is "colgroup" */ + } elseif ($token['type'] === HTML5::STARTTAG && + $token['name'] === 'colgroup' + ) { + /* Clear the stack back to a table context. */ + $this->clearStackToTableContext($clear); + + /* Insert an HTML element for the token, then switch the + insertion mode to "in column group". */ + $this->insertElement($token); + $this->mode = self::IN_CGROUP; + + /* A start tag whose tag name is "col" */ + } elseif ($token['type'] === HTML5::STARTTAG && + $token['name'] === 'col' + ) { + $this->inTable( + array( + 'name' => 'colgroup', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + $this->inColumnGroup($token); + + /* A start tag whose tag name is one of: "tbody", "tfoot", "thead" */ + } elseif ($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array('tbody', 'tfoot', 'thead') + ) + ) { + /* Clear the stack back to a table context. */ + $this->clearStackToTableContext($clear); + + /* Insert an HTML element for the token, then switch the insertion + mode to "in table body". */ + $this->insertElement($token); + $this->mode = self::IN_TBODY; + + /* A start tag whose tag name is one of: "td", "th", "tr" */ + } elseif ($token['type'] === HTML5::STARTTAG && + in_array($token['name'], array('td', 'th', 'tr')) + ) { + /* Act as if a start tag token with the tag name "tbody" had been + seen, then reprocess the current token. */ + $this->inTable( + array( + 'name' => 'tbody', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + return $this->inTableBody($token); + + /* A start tag whose tag name is "table" */ + } elseif ($token['type'] === HTML5::STARTTAG && + $token['name'] === 'table' + ) { + /* Parse error. Act as if an end tag token with the tag name "table" + had been seen, then, if that token wasn't ignored, reprocess the + current token. */ + $this->inTable( + array( + 'name' => 'table', + 'type' => HTML5::ENDTAG + ) + ); + + return $this->mainPhase($token); + + /* An end tag whose tag name is "table" */ + } elseif ($token['type'] === HTML5::ENDTAG && + $token['name'] === 'table' + ) { + /* If the stack of open elements does not have an element in table + scope with the same tag name as the token, this is a parse error. + Ignore the token. (innerHTML case) */ + if (!$this->elementInScope($token['name'], true)) { + return false; + + /* Otherwise: */ + } else { + /* Generate implied end tags. */ + $this->generateImpliedEndTags(); + + /* Now, if the current node is not a table element, then this + is a parse error. */ + // w/e + + /* Pop elements from this stack until a table element has been + popped from the stack. */ + while (true) { + $current = end($this->stack)->nodeName; + array_pop($this->stack); + + if ($current === 'table') { + break; + } + } + + /* Reset the insertion mode appropriately. */ + $this->resetInsertionMode(); + } + + /* An end tag whose tag name is one of: "body", "caption", "col", + "colgroup", "html", "tbody", "td", "tfoot", "th", "thead", "tr" */ + } elseif ($token['type'] === HTML5::ENDTAG && in_array( + $token['name'], + array( + 'body', + 'caption', + 'col', + 'colgroup', + 'html', + 'tbody', + 'td', + 'tfoot', + 'th', + 'thead', + 'tr' + ) + ) + ) { + // Parse error. Ignore the token. + + /* Anything else */ + } else { + /* Parse error. Process the token as if the insertion mode was "in + body", with the following exception: */ + + /* If the current node is a table, tbody, tfoot, thead, or tr + element, then, whenever a node would be inserted into the current + node, it must instead be inserted into the foster parent element. */ + if (in_array( + end($this->stack)->nodeName, + array('table', 'tbody', 'tfoot', 'thead', 'tr') + ) + ) { + /* The foster parent element is the parent element of the last + table element in the stack of open elements, if there is a + table element and it has such a parent element. If there is no + table element in the stack of open elements (innerHTML case), + then the foster parent element is the first element in the + stack of open elements (the html element). Otherwise, if there + is a table element in the stack of open elements, but the last + table element in the stack of open elements has no parent, or + its parent node is not an element, then the foster parent + element is the element before the last table element in the + stack of open elements. */ + for ($n = count($this->stack) - 1; $n >= 0; $n--) { + if ($this->stack[$n]->nodeName === 'table') { + $table = $this->stack[$n]; + break; + } + } + + if (isset($table) && $table->parentNode !== null) { + $this->foster_parent = $table->parentNode; + + } elseif (!isset($table)) { + $this->foster_parent = $this->stack[0]; + + } elseif (isset($table) && ($table->parentNode === null || + $table->parentNode->nodeType !== XML_ELEMENT_NODE) + ) { + $this->foster_parent = $this->stack[$n - 1]; + } + } + + $this->inBody($token); + } + } + + private function inCaption($token) + { + /* An end tag whose tag name is "caption" */ + if ($token['type'] === HTML5::ENDTAG && $token['name'] === 'caption') { + /* If the stack of open elements does not have an element in table + scope with the same tag name as the token, this is a parse error. + Ignore the token. (innerHTML case) */ + if (!$this->elementInScope($token['name'], true)) { + // Ignore + + /* Otherwise: */ + } else { + /* Generate implied end tags. */ + $this->generateImpliedEndTags(); + + /* Now, if the current node is not a caption element, then this + is a parse error. */ + // w/e + + /* Pop elements from this stack until a caption element has + been popped from the stack. */ + while (true) { + $node = end($this->stack)->nodeName; + array_pop($this->stack); + + if ($node === 'caption') { + break; + } + } + + /* Clear the list of active formatting elements up to the last + marker. */ + $this->clearTheActiveFormattingElementsUpToTheLastMarker(); + + /* Switch the insertion mode to "in table". */ + $this->mode = self::IN_TABLE; + } + + /* A start tag whose tag name is one of: "caption", "col", "colgroup", + "tbody", "td", "tfoot", "th", "thead", "tr", or an end tag whose tag + name is "table" */ + } elseif (($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array( + 'caption', + 'col', + 'colgroup', + 'tbody', + 'td', + 'tfoot', + 'th', + 'thead', + 'tr' + ) + )) || ($token['type'] === HTML5::ENDTAG && + $token['name'] === 'table') + ) { + /* Parse error. Act as if an end tag with the tag name "caption" + had been seen, then, if that token wasn't ignored, reprocess the + current token. */ + $this->inCaption( + array( + 'name' => 'caption', + 'type' => HTML5::ENDTAG + ) + ); + + return $this->inTable($token); + + /* An end tag whose tag name is one of: "body", "col", "colgroup", + "html", "tbody", "td", "tfoot", "th", "thead", "tr" */ + } elseif ($token['type'] === HTML5::ENDTAG && in_array( + $token['name'], + array( + 'body', + 'col', + 'colgroup', + 'html', + 'tbody', + 'tfoot', + 'th', + 'thead', + 'tr' + ) + ) + ) { + // Parse error. Ignore the token. + + /* Anything else */ + } else { + /* Process the token as if the insertion mode was "in body". */ + $this->inBody($token); + } + } + + private function inColumnGroup($token) + { + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + if ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Append the character to the current node. */ + $text = $this->dom->createTextNode($token['data']); + end($this->stack)->appendChild($text); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data + attribute set to the data given in the comment token. */ + $comment = $this->dom->createComment($token['data']); + end($this->stack)->appendChild($comment); + + /* A start tag whose tag name is "col" */ + } elseif ($token['type'] === HTML5::STARTTAG && $token['name'] === 'col') { + /* Insert a col element for the token. Immediately pop the current + node off the stack of open elements. */ + $this->insertElement($token); + array_pop($this->stack); + + /* An end tag whose tag name is "colgroup" */ + } elseif ($token['type'] === HTML5::ENDTAG && + $token['name'] === 'colgroup' + ) { + /* If the current node is the root html element, then this is a + parse error, ignore the token. (innerHTML case) */ + if (end($this->stack)->nodeName === 'html') { + // Ignore + + /* Otherwise, pop the current node (which will be a colgroup + element) from the stack of open elements. Switch the insertion + mode to "in table". */ + } else { + array_pop($this->stack); + $this->mode = self::IN_TABLE; + } + + /* An end tag whose tag name is "col" */ + } elseif ($token['type'] === HTML5::ENDTAG && $token['name'] === 'col') { + /* Parse error. Ignore the token. */ + + /* Anything else */ + } else { + /* Act as if an end tag with the tag name "colgroup" had been seen, + and then, if that token wasn't ignored, reprocess the current token. */ + $this->inColumnGroup( + array( + 'name' => 'colgroup', + 'type' => HTML5::ENDTAG + ) + ); + + return $this->inTable($token); + } + } + + private function inTableBody($token) + { + $clear = array('tbody', 'tfoot', 'thead', 'html'); + + /* A start tag whose tag name is "tr" */ + if ($token['type'] === HTML5::STARTTAG && $token['name'] === 'tr') { + /* Clear the stack back to a table body context. */ + $this->clearStackToTableContext($clear); + + /* Insert a tr element for the token, then switch the insertion + mode to "in row". */ + $this->insertElement($token); + $this->mode = self::IN_ROW; + + /* A start tag whose tag name is one of: "th", "td" */ + } elseif ($token['type'] === HTML5::STARTTAG && + ($token['name'] === 'th' || $token['name'] === 'td') + ) { + /* Parse error. Act as if a start tag with the tag name "tr" had + been seen, then reprocess the current token. */ + $this->inTableBody( + array( + 'name' => 'tr', + 'type' => HTML5::STARTTAG, + 'attr' => array() + ) + ); + + return $this->inRow($token); + + /* An end tag whose tag name is one of: "tbody", "tfoot", "thead" */ + } elseif ($token['type'] === HTML5::ENDTAG && + in_array($token['name'], array('tbody', 'tfoot', 'thead')) + ) { + /* If the stack of open elements does not have an element in table + scope with the same tag name as the token, this is a parse error. + Ignore the token. */ + if (!$this->elementInScope($token['name'], true)) { + // Ignore + + /* Otherwise: */ + } else { + /* Clear the stack back to a table body context. */ + $this->clearStackToTableContext($clear); + + /* Pop the current node from the stack of open elements. Switch + the insertion mode to "in table". */ + array_pop($this->stack); + $this->mode = self::IN_TABLE; + } + + /* A start tag whose tag name is one of: "caption", "col", "colgroup", + "tbody", "tfoot", "thead", or an end tag whose tag name is "table" */ + } elseif (($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array('caption', 'col', 'colgroup', 'tbody', 'tfoor', 'thead') + )) || + ($token['type'] === HTML5::STARTTAG && $token['name'] === 'table') + ) { + /* If the stack of open elements does not have a tbody, thead, or + tfoot element in table scope, this is a parse error. Ignore the + token. (innerHTML case) */ + if (!$this->elementInScope(array('tbody', 'thead', 'tfoot'), true)) { + // Ignore. + + /* Otherwise: */ + } else { + /* Clear the stack back to a table body context. */ + $this->clearStackToTableContext($clear); + + /* Act as if an end tag with the same tag name as the current + node ("tbody", "tfoot", or "thead") had been seen, then + reprocess the current token. */ + $this->inTableBody( + array( + 'name' => end($this->stack)->nodeName, + 'type' => HTML5::ENDTAG + ) + ); + + return $this->mainPhase($token); + } + + /* An end tag whose tag name is one of: "body", "caption", "col", + "colgroup", "html", "td", "th", "tr" */ + } elseif ($token['type'] === HTML5::ENDTAG && in_array( + $token['name'], + array('body', 'caption', 'col', 'colgroup', 'html', 'td', 'th', 'tr') + ) + ) { + /* Parse error. Ignore the token. */ + + /* Anything else */ + } else { + /* Process the token as if the insertion mode was "in table". */ + $this->inTable($token); + } + } + + private function inRow($token) + { + $clear = array('tr', 'html'); + + /* A start tag whose tag name is one of: "th", "td" */ + if ($token['type'] === HTML5::STARTTAG && + ($token['name'] === 'th' || $token['name'] === 'td') + ) { + /* Clear the stack back to a table row context. */ + $this->clearStackToTableContext($clear); + + /* Insert an HTML element for the token, then switch the insertion + mode to "in cell". */ + $this->insertElement($token); + $this->mode = self::IN_CELL; + + /* Insert a marker at the end of the list of active formatting + elements. */ + $this->a_formatting[] = self::MARKER; + + /* An end tag whose tag name is "tr" */ + } elseif ($token['type'] === HTML5::ENDTAG && $token['name'] === 'tr') { + /* If the stack of open elements does not have an element in table + scope with the same tag name as the token, this is a parse error. + Ignore the token. (innerHTML case) */ + if (!$this->elementInScope($token['name'], true)) { + // Ignore. + + /* Otherwise: */ + } else { + /* Clear the stack back to a table row context. */ + $this->clearStackToTableContext($clear); + + /* Pop the current node (which will be a tr element) from the + stack of open elements. Switch the insertion mode to "in table + body". */ + array_pop($this->stack); + $this->mode = self::IN_TBODY; + } + + /* A start tag whose tag name is one of: "caption", "col", "colgroup", + "tbody", "tfoot", "thead", "tr" or an end tag whose tag name is "table" */ + } elseif ($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array('caption', 'col', 'colgroup', 'tbody', 'tfoot', 'thead', 'tr') + ) + ) { + /* Act as if an end tag with the tag name "tr" had been seen, then, + if that token wasn't ignored, reprocess the current token. */ + $this->inRow( + array( + 'name' => 'tr', + 'type' => HTML5::ENDTAG + ) + ); + + return $this->inCell($token); + + /* An end tag whose tag name is one of: "tbody", "tfoot", "thead" */ + } elseif ($token['type'] === HTML5::ENDTAG && + in_array($token['name'], array('tbody', 'tfoot', 'thead')) + ) { + /* If the stack of open elements does not have an element in table + scope with the same tag name as the token, this is a parse error. + Ignore the token. */ + if (!$this->elementInScope($token['name'], true)) { + // Ignore. + + /* Otherwise: */ + } else { + /* Otherwise, act as if an end tag with the tag name "tr" had + been seen, then reprocess the current token. */ + $this->inRow( + array( + 'name' => 'tr', + 'type' => HTML5::ENDTAG + ) + ); + + return $this->inCell($token); + } + + /* An end tag whose tag name is one of: "body", "caption", "col", + "colgroup", "html", "td", "th" */ + } elseif ($token['type'] === HTML5::ENDTAG && in_array( + $token['name'], + array('body', 'caption', 'col', 'colgroup', 'html', 'td', 'th', 'tr') + ) + ) { + /* Parse error. Ignore the token. */ + + /* Anything else */ + } else { + /* Process the token as if the insertion mode was "in table". */ + $this->inTable($token); + } + } + + private function inCell($token) + { + /* An end tag whose tag name is one of: "td", "th" */ + if ($token['type'] === HTML5::ENDTAG && + ($token['name'] === 'td' || $token['name'] === 'th') + ) { + /* If the stack of open elements does not have an element in table + scope with the same tag name as that of the token, then this is a + parse error and the token must be ignored. */ + if (!$this->elementInScope($token['name'], true)) { + // Ignore. + + /* Otherwise: */ + } else { + /* Generate implied end tags, except for elements with the same + tag name as the token. */ + $this->generateImpliedEndTags(array($token['name'])); + + /* Now, if the current node is not an element with the same tag + name as the token, then this is a parse error. */ + // k + + /* Pop elements from this stack until an element with the same + tag name as the token has been popped from the stack. */ + while (true) { + $node = end($this->stack)->nodeName; + array_pop($this->stack); + + if ($node === $token['name']) { + break; + } + } + + /* Clear the list of active formatting elements up to the last + marker. */ + $this->clearTheActiveFormattingElementsUpToTheLastMarker(); + + /* Switch the insertion mode to "in row". (The current node + will be a tr element at this point.) */ + $this->mode = self::IN_ROW; + } + + /* A start tag whose tag name is one of: "caption", "col", "colgroup", + "tbody", "td", "tfoot", "th", "thead", "tr" */ + } elseif ($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array( + 'caption', + 'col', + 'colgroup', + 'tbody', + 'td', + 'tfoot', + 'th', + 'thead', + 'tr' + ) + ) + ) { + /* If the stack of open elements does not have a td or th element + in table scope, then this is a parse error; ignore the token. + (innerHTML case) */ + if (!$this->elementInScope(array('td', 'th'), true)) { + // Ignore. + + /* Otherwise, close the cell (see below) and reprocess the current + token. */ + } else { + $this->closeCell(); + return $this->inRow($token); + } + + /* A start tag whose tag name is one of: "caption", "col", "colgroup", + "tbody", "td", "tfoot", "th", "thead", "tr" */ + } elseif ($token['type'] === HTML5::STARTTAG && in_array( + $token['name'], + array( + 'caption', + 'col', + 'colgroup', + 'tbody', + 'td', + 'tfoot', + 'th', + 'thead', + 'tr' + ) + ) + ) { + /* If the stack of open elements does not have a td or th element + in table scope, then this is a parse error; ignore the token. + (innerHTML case) */ + if (!$this->elementInScope(array('td', 'th'), true)) { + // Ignore. + + /* Otherwise, close the cell (see below) and reprocess the current + token. */ + } else { + $this->closeCell(); + return $this->inRow($token); + } + + /* An end tag whose tag name is one of: "body", "caption", "col", + "colgroup", "html" */ + } elseif ($token['type'] === HTML5::ENDTAG && in_array( + $token['name'], + array('body', 'caption', 'col', 'colgroup', 'html') + ) + ) { + /* Parse error. Ignore the token. */ + + /* An end tag whose tag name is one of: "table", "tbody", "tfoot", + "thead", "tr" */ + } elseif ($token['type'] === HTML5::ENDTAG && in_array( + $token['name'], + array('table', 'tbody', 'tfoot', 'thead', 'tr') + ) + ) { + /* If the stack of open elements does not have an element in table + scope with the same tag name as that of the token (which can only + happen for "tbody", "tfoot" and "thead", or, in the innerHTML case), + then this is a parse error and the token must be ignored. */ + if (!$this->elementInScope($token['name'], true)) { + // Ignore. + + /* Otherwise, close the cell (see below) and reprocess the current + token. */ + } else { + $this->closeCell(); + return $this->inRow($token); + } + + /* Anything else */ + } else { + /* Process the token as if the insertion mode was "in body". */ + $this->inBody($token); + } + } + + private function inSelect($token) + { + /* Handle the token as follows: */ + + /* A character token */ + if ($token['type'] === HTML5::CHARACTR) { + /* Append the token's character to the current node. */ + $this->insertText($token['data']); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data + attribute set to the data given in the comment token. */ + $this->insertComment($token['data']); + + /* A start tag token whose tag name is "option" */ + } elseif ($token['type'] === HTML5::STARTTAG && + $token['name'] === 'option' + ) { + /* If the current node is an option element, act as if an end tag + with the tag name "option" had been seen. */ + if (end($this->stack)->nodeName === 'option') { + $this->inSelect( + array( + 'name' => 'option', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* A start tag token whose tag name is "optgroup" */ + } elseif ($token['type'] === HTML5::STARTTAG && + $token['name'] === 'optgroup' + ) { + /* If the current node is an option element, act as if an end tag + with the tag name "option" had been seen. */ + if (end($this->stack)->nodeName === 'option') { + $this->inSelect( + array( + 'name' => 'option', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* If the current node is an optgroup element, act as if an end tag + with the tag name "optgroup" had been seen. */ + if (end($this->stack)->nodeName === 'optgroup') { + $this->inSelect( + array( + 'name' => 'optgroup', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* An end tag token whose tag name is "optgroup" */ + } elseif ($token['type'] === HTML5::ENDTAG && + $token['name'] === 'optgroup' + ) { + /* First, if the current node is an option element, and the node + immediately before it in the stack of open elements is an optgroup + element, then act as if an end tag with the tag name "option" had + been seen. */ + $elements_in_stack = count($this->stack); + + if ($this->stack[$elements_in_stack - 1]->nodeName === 'option' && + $this->stack[$elements_in_stack - 2]->nodeName === 'optgroup' + ) { + $this->inSelect( + array( + 'name' => 'option', + 'type' => HTML5::ENDTAG + ) + ); + } + + /* If the current node is an optgroup element, then pop that node + from the stack of open elements. Otherwise, this is a parse error, + ignore the token. */ + if ($this->stack[$elements_in_stack - 1] === 'optgroup') { + array_pop($this->stack); + } + + /* An end tag token whose tag name is "option" */ + } elseif ($token['type'] === HTML5::ENDTAG && + $token['name'] === 'option' + ) { + /* If the current node is an option element, then pop that node + from the stack of open elements. Otherwise, this is a parse error, + ignore the token. */ + if (end($this->stack)->nodeName === 'option') { + array_pop($this->stack); + } + + /* An end tag whose tag name is "select" */ + } elseif ($token['type'] === HTML5::ENDTAG && + $token['name'] === 'select' + ) { + /* If the stack of open elements does not have an element in table + scope with the same tag name as the token, this is a parse error. + Ignore the token. (innerHTML case) */ + if (!$this->elementInScope($token['name'], true)) { + // w/e + + /* Otherwise: */ + } else { + /* Pop elements from the stack of open elements until a select + element has been popped from the stack. */ + while (true) { + $current = end($this->stack)->nodeName; + array_pop($this->stack); + + if ($current === 'select') { + break; + } + } + + /* Reset the insertion mode appropriately. */ + $this->resetInsertionMode(); + } + + /* A start tag whose tag name is "select" */ + } elseif ($token['name'] === 'select' && + $token['type'] === HTML5::STARTTAG + ) { + /* Parse error. Act as if the token had been an end tag with the + tag name "select" instead. */ + $this->inSelect( + array( + 'name' => 'select', + 'type' => HTML5::ENDTAG + ) + ); + + /* An end tag whose tag name is one of: "caption", "table", "tbody", + "tfoot", "thead", "tr", "td", "th" */ + } elseif (in_array( + $token['name'], + array( + 'caption', + 'table', + 'tbody', + 'tfoot', + 'thead', + 'tr', + 'td', + 'th' + ) + ) && $token['type'] === HTML5::ENDTAG + ) { + /* Parse error. */ + // w/e + + /* If the stack of open elements has an element in table scope with + the same tag name as that of the token, then act as if an end tag + with the tag name "select" had been seen, and reprocess the token. + Otherwise, ignore the token. */ + if ($this->elementInScope($token['name'], true)) { + $this->inSelect( + array( + 'name' => 'select', + 'type' => HTML5::ENDTAG + ) + ); + + $this->mainPhase($token); + } + + /* Anything else */ + } else { + /* Parse error. Ignore the token. */ + } + } + + private function afterBody($token) + { + /* Handle the token as follows: */ + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + if ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Process the token as it would be processed if the insertion mode + was "in body". */ + $this->inBody($token); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the first element in the stack of open + elements (the html element), with the data attribute set to the + data given in the comment token. */ + $comment = $this->dom->createComment($token['data']); + $this->stack[0]->appendChild($comment); + + /* An end tag with the tag name "html" */ + } elseif ($token['type'] === HTML5::ENDTAG && $token['name'] === 'html') { + /* If the parser was originally created in order to handle the + setting of an element's innerHTML attribute, this is a parse error; + ignore the token. (The element will be an html element in this + case.) (innerHTML case) */ + + /* Otherwise, switch to the trailing end phase. */ + $this->phase = self::END_PHASE; + + /* Anything else */ + } else { + /* Parse error. Set the insertion mode to "in body" and reprocess + the token. */ + $this->mode = self::IN_BODY; + return $this->inBody($token); + } + } + + private function inFrameset($token) + { + /* Handle the token as follows: */ + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + U+000D CARRIAGE RETURN (CR), or U+0020 SPACE */ + if ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Append the character to the current node. */ + $this->insertText($token['data']); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data + attribute set to the data given in the comment token. */ + $this->insertComment($token['data']); + + /* A start tag with the tag name "frameset" */ + } elseif ($token['name'] === 'frameset' && + $token['type'] === HTML5::STARTTAG + ) { + $this->insertElement($token); + + /* An end tag with the tag name "frameset" */ + } elseif ($token['name'] === 'frameset' && + $token['type'] === HTML5::ENDTAG + ) { + /* If the current node is the root html element, then this is a + parse error; ignore the token. (innerHTML case) */ + if (end($this->stack)->nodeName === 'html') { + // Ignore + + } else { + /* Otherwise, pop the current node from the stack of open + elements. */ + array_pop($this->stack); + + /* If the parser was not originally created in order to handle + the setting of an element's innerHTML attribute (innerHTML case), + and the current node is no longer a frameset element, then change + the insertion mode to "after frameset". */ + $this->mode = self::AFTR_FRAME; + } + + /* A start tag with the tag name "frame" */ + } elseif ($token['name'] === 'frame' && + $token['type'] === HTML5::STARTTAG + ) { + /* Insert an HTML element for the token. */ + $this->insertElement($token); + + /* Immediately pop the current node off the stack of open elements. */ + array_pop($this->stack); + + /* A start tag with the tag name "noframes" */ + } elseif ($token['name'] === 'noframes' && + $token['type'] === HTML5::STARTTAG + ) { + /* Process the token as if the insertion mode had been "in body". */ + $this->inBody($token); + + /* Anything else */ + } else { + /* Parse error. Ignore the token. */ + } + } + + private function afterFrameset($token) + { + /* Handle the token as follows: */ + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + U+000D CARRIAGE RETURN (CR), or U+0020 SPACE */ + if ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Append the character to the current node. */ + $this->insertText($token['data']); + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the current node with the data + attribute set to the data given in the comment token. */ + $this->insertComment($token['data']); + + /* An end tag with the tag name "html" */ + } elseif ($token['name'] === 'html' && + $token['type'] === HTML5::ENDTAG + ) { + /* Switch to the trailing end phase. */ + $this->phase = self::END_PHASE; + + /* A start tag with the tag name "noframes" */ + } elseif ($token['name'] === 'noframes' && + $token['type'] === HTML5::STARTTAG + ) { + /* Process the token as if the insertion mode had been "in body". */ + $this->inBody($token); + + /* Anything else */ + } else { + /* Parse error. Ignore the token. */ + } + } + + private function trailingEndPhase($token) + { + /* After the main phase, as each token is emitted from the tokenisation + stage, it must be processed as described in this section. */ + + /* A DOCTYPE token */ + if ($token['type'] === HTML5::DOCTYPE) { + // Parse error. Ignore the token. + + /* A comment token */ + } elseif ($token['type'] === HTML5::COMMENT) { + /* Append a Comment node to the Document object with the data + attribute set to the data given in the comment token. */ + $comment = $this->dom->createComment($token['data']); + $this->dom->appendChild($comment); + + /* A character token that is one of one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE */ + } elseif ($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data']) + ) { + /* Process the token as it would be processed in the main phase. */ + $this->mainPhase($token); + + /* A character token that is not one of U+0009 CHARACTER TABULATION, + U+000A LINE FEED (LF), U+000B LINE TABULATION, U+000C FORM FEED (FF), + or U+0020 SPACE. Or a start tag token. Or an end tag token. */ + } elseif (($token['type'] === HTML5::CHARACTR && + preg_match('/^[\t\n\x0b\x0c ]+$/', $token['data'])) || + $token['type'] === HTML5::STARTTAG || $token['type'] === HTML5::ENDTAG + ) { + /* Parse error. Switch back to the main phase and reprocess the + token. */ + $this->phase = self::MAIN_PHASE; + return $this->mainPhase($token); + + /* An end-of-file token */ + } elseif ($token['type'] === HTML5::EOF) { + /* OMG DONE!! */ + } + } + + private function insertElement($token, $append = true, $check = false) + { + // Proprietary workaround for libxml2's limitations with tag names + if ($check) { + // Slightly modified HTML5 tag-name modification, + // removing anything that's not an ASCII letter, digit, or hyphen + $token['name'] = preg_replace('/[^a-z0-9-]/i', '', $token['name']); + // Remove leading hyphens and numbers + $token['name'] = ltrim($token['name'], '-0..9'); + // In theory, this should ever be needed, but just in case + if ($token['name'] === '') { + $token['name'] = 'span'; + } // arbitrary generic choice + } + + $el = $this->dom->createElement($token['name']); + + foreach ($token['attr'] as $attr) { + if (!$el->hasAttribute($attr['name'])) { + $el->setAttribute($attr['name'], (string)$attr['value']); + } + } + + $this->appendToRealParent($el); + $this->stack[] = $el; + + return $el; + } + + private function insertText($data) + { + $text = $this->dom->createTextNode($data); + $this->appendToRealParent($text); + } + + private function insertComment($data) + { + $comment = $this->dom->createComment($data); + $this->appendToRealParent($comment); + } + + private function appendToRealParent($node) + { + if ($this->foster_parent === null) { + end($this->stack)->appendChild($node); + + } elseif ($this->foster_parent !== null) { + /* If the foster parent element is the parent element of the + last table element in the stack of open elements, then the new + node must be inserted immediately before the last table element + in the stack of open elements in the foster parent element; + otherwise, the new node must be appended to the foster parent + element. */ + for ($n = count($this->stack) - 1; $n >= 0; $n--) { + if ($this->stack[$n]->nodeName === 'table' && + $this->stack[$n]->parentNode !== null + ) { + $table = $this->stack[$n]; + break; + } + } + + if (isset($table) && $this->foster_parent->isSameNode($table->parentNode)) { + $this->foster_parent->insertBefore($node, $table); + } else { + $this->foster_parent->appendChild($node); + } + + $this->foster_parent = null; + } + } + + private function elementInScope($el, $table = false) + { + if (is_array($el)) { + foreach ($el as $element) { + if ($this->elementInScope($element, $table)) { + return true; + } + } + + return false; + } + + $leng = count($this->stack); + + for ($n = 0; $n < $leng; $n++) { + /* 1. Initialise node to be the current node (the bottommost node of + the stack). */ + $node = $this->stack[$leng - 1 - $n]; + + if ($node->tagName === $el) { + /* 2. If node is the target node, terminate in a match state. */ + return true; + + } elseif ($node->tagName === 'table') { + /* 3. Otherwise, if node is a table element, terminate in a failure + state. */ + return false; + + } elseif ($table === true && in_array( + $node->tagName, + array( + 'caption', + 'td', + 'th', + 'button', + 'marquee', + 'object' + ) + ) + ) { + /* 4. Otherwise, if the algorithm is the "has an element in scope" + variant (rather than the "has an element in table scope" variant), + and node is one of the following, terminate in a failure state. */ + return false; + + } elseif ($node === $node->ownerDocument->documentElement) { + /* 5. Otherwise, if node is an html element (root element), terminate + in a failure state. (This can only happen if the node is the topmost + node of the stack of open elements, and prevents the next step from + being invoked if there are no more elements in the stack.) */ + return false; + } + + /* Otherwise, set node to the previous entry in the stack of open + elements and return to step 2. (This will never fail, since the loop + will always terminate in the previous step if the top of the stack + is reached.) */ + } + } + + private function reconstructActiveFormattingElements() + { + /* 1. If there are no entries in the list of active formatting elements, + then there is nothing to reconstruct; stop this algorithm. */ + $formatting_elements = count($this->a_formatting); + + if ($formatting_elements === 0) { + return false; + } + + /* 3. Let entry be the last (most recently added) element in the list + of active formatting elements. */ + $entry = end($this->a_formatting); + + /* 2. If the last (most recently added) entry in the list of active + formatting elements is a marker, or if it is an element that is in the + stack of open elements, then there is nothing to reconstruct; stop this + algorithm. */ + if ($entry === self::MARKER || in_array($entry, $this->stack, true)) { + return false; + } + + for ($a = $formatting_elements - 1; $a >= 0; true) { + /* 4. If there are no entries before entry in the list of active + formatting elements, then jump to step 8. */ + if ($a === 0) { + $step_seven = false; + break; + } + + /* 5. Let entry be the entry one earlier than entry in the list of + active formatting elements. */ + $a--; + $entry = $this->a_formatting[$a]; + + /* 6. If entry is neither a marker nor an element that is also in + thetack of open elements, go to step 4. */ + if ($entry === self::MARKER || in_array($entry, $this->stack, true)) { + break; + } + } + + while (true) { + /* 7. Let entry be the element one later than entry in the list of + active formatting elements. */ + if (isset($step_seven) && $step_seven === true) { + $a++; + $entry = $this->a_formatting[$a]; + } + + /* 8. Perform a shallow clone of the element entry to obtain clone. */ + $clone = $entry->cloneNode(); + + /* 9. Append clone to the current node and push it onto the stack + of open elements so that it is the new current node. */ + end($this->stack)->appendChild($clone); + $this->stack[] = $clone; + + /* 10. Replace the entry for entry in the list with an entry for + clone. */ + $this->a_formatting[$a] = $clone; + + /* 11. If the entry for clone in the list of active formatting + elements is not the last entry in the list, return to step 7. */ + if (end($this->a_formatting) !== $clone) { + $step_seven = true; + } else { + break; + } + } + } + + private function clearTheActiveFormattingElementsUpToTheLastMarker() + { + /* When the steps below require the UA to clear the list of active + formatting elements up to the last marker, the UA must perform the + following steps: */ + + while (true) { + /* 1. Let entry be the last (most recently added) entry in the list + of active formatting elements. */ + $entry = end($this->a_formatting); + + /* 2. Remove entry from the list of active formatting elements. */ + array_pop($this->a_formatting); + + /* 3. If entry was a marker, then stop the algorithm at this point. + The list has been cleared up to the last marker. */ + if ($entry === self::MARKER) { + break; + } + } + } + + private function generateImpliedEndTags($exclude = array()) + { + /* When the steps below require the UA to generate implied end tags, + then, if the current node is a dd element, a dt element, an li element, + a p element, a td element, a th element, or a tr element, the UA must + act as if an end tag with the respective tag name had been seen and + then generate implied end tags again. */ + $node = end($this->stack); + $elements = array_diff(array('dd', 'dt', 'li', 'p', 'td', 'th', 'tr'), $exclude); + + while (in_array(end($this->stack)->nodeName, $elements)) { + array_pop($this->stack); + } + } + + private function getElementCategory($node) + { + $name = $node->tagName; + if (in_array($name, $this->special)) { + return self::SPECIAL; + } elseif (in_array($name, $this->scoping)) { + return self::SCOPING; + } elseif (in_array($name, $this->formatting)) { + return self::FORMATTING; + } else { + return self::PHRASING; + } + } + + private function clearStackToTableContext($elements) + { + /* When the steps above require the UA to clear the stack back to a + table context, it means that the UA must, while the current node is not + a table element or an html element, pop elements from the stack of open + elements. If this causes any elements to be popped from the stack, then + this is a parse error. */ + while (true) { + $node = end($this->stack)->nodeName; + + if (in_array($node, $elements)) { + break; + } else { + array_pop($this->stack); + } + } + } + + private function resetInsertionMode() + { + /* 1. Let last be false. */ + $last = false; + $leng = count($this->stack); + + for ($n = $leng - 1; $n >= 0; $n--) { + /* 2. Let node be the last node in the stack of open elements. */ + $node = $this->stack[$n]; + + /* 3. If node is the first node in the stack of open elements, then + set last to true. If the element whose innerHTML attribute is being + set is neither a td element nor a th element, then set node to the + element whose innerHTML attribute is being set. (innerHTML case) */ + if ($this->stack[0]->isSameNode($node)) { + $last = true; + } + + /* 4. If node is a select element, then switch the insertion mode to + "in select" and abort these steps. (innerHTML case) */ + if ($node->nodeName === 'select') { + $this->mode = self::IN_SELECT; + break; + + /* 5. If node is a td or th element, then switch the insertion mode + to "in cell" and abort these steps. */ + } elseif ($node->nodeName === 'td' || $node->nodeName === 'th') { + $this->mode = self::IN_CELL; + break; + + /* 6. If node is a tr element, then switch the insertion mode to + "in row" and abort these steps. */ + } elseif ($node->nodeName === 'tr') { + $this->mode = self::IN_ROW; + break; + + /* 7. If node is a tbody, thead, or tfoot element, then switch the + insertion mode to "in table body" and abort these steps. */ + } elseif (in_array($node->nodeName, array('tbody', 'thead', 'tfoot'))) { + $this->mode = self::IN_TBODY; + break; + + /* 8. If node is a caption element, then switch the insertion mode + to "in caption" and abort these steps. */ + } elseif ($node->nodeName === 'caption') { + $this->mode = self::IN_CAPTION; + break; + + /* 9. If node is a colgroup element, then switch the insertion mode + to "in column group" and abort these steps. (innerHTML case) */ + } elseif ($node->nodeName === 'colgroup') { + $this->mode = self::IN_CGROUP; + break; + + /* 10. If node is a table element, then switch the insertion mode + to "in table" and abort these steps. */ + } elseif ($node->nodeName === 'table') { + $this->mode = self::IN_TABLE; + break; + + /* 11. If node is a head element, then switch the insertion mode + to "in body" ("in body"! not "in head"!) and abort these steps. + (innerHTML case) */ + } elseif ($node->nodeName === 'head') { + $this->mode = self::IN_BODY; + break; + + /* 12. If node is a body element, then switch the insertion mode to + "in body" and abort these steps. */ + } elseif ($node->nodeName === 'body') { + $this->mode = self::IN_BODY; + break; + + /* 13. If node is a frameset element, then switch the insertion + mode to "in frameset" and abort these steps. (innerHTML case) */ + } elseif ($node->nodeName === 'frameset') { + $this->mode = self::IN_FRAME; + break; + + /* 14. If node is an html element, then: if the head element + pointer is null, switch the insertion mode to "before head", + otherwise, switch the insertion mode to "after head". In either + case, abort these steps. (innerHTML case) */ + } elseif ($node->nodeName === 'html') { + $this->mode = ($this->head_pointer === null) + ? self::BEFOR_HEAD + : self::AFTER_HEAD; + + break; + + /* 15. If last is true, then set the insertion mode to "in body" + and abort these steps. (innerHTML case) */ + } elseif ($last) { + $this->mode = self::IN_BODY; + break; + } + } + } + + private function closeCell() + { + /* If the stack of open elements has a td or th element in table scope, + then act as if an end tag token with that tag name had been seen. */ + foreach (array('td', 'th') as $cell) { + if ($this->elementInScope($cell, true)) { + $this->inCell( + array( + 'name' => $cell, + 'type' => HTML5::ENDTAG + ) + ); + + break; + } + } + } + + public function save() + { + return $this->dom; + } +} diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node.php new file mode 100644 index 0000000..3995fec --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node.php @@ -0,0 +1,49 @@ +data = $data; + $this->line = $line; + $this->col = $col; + } + + public function toTokenPair() { + return array(new HTMLPurifier_Token_Comment($this->data, $this->line, $this->col), null); + } +} diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Element.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Element.php new file mode 100644 index 0000000..6cbf56d --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Element.php @@ -0,0 +1,59 @@ + form or the form, i.e. + * is it a pair of start/end tokens or an empty token. + * @bool + */ + public $empty = false; + + public $endCol = null, $endLine = null, $endArmor = array(); + + public function __construct($name, $attr = array(), $line = null, $col = null, $armor = array()) { + $this->name = $name; + $this->attr = $attr; + $this->line = $line; + $this->col = $col; + $this->armor = $armor; + } + + public function toTokenPair() { + // XXX inefficiency here, normalization is not necessary + if ($this->empty) { + return array(new HTMLPurifier_Token_Empty($this->name, $this->attr, $this->line, $this->col, $this->armor), null); + } else { + $start = new HTMLPurifier_Token_Start($this->name, $this->attr, $this->line, $this->col, $this->armor); + $end = new HTMLPurifier_Token_End($this->name, array(), $this->endLine, $this->endCol, $this->endArmor); + //$end->start = $start; + return array($start, $end); + } + } +} + diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Text.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Text.php new file mode 100644 index 0000000..aec9166 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Node/Text.php @@ -0,0 +1,54 @@ +data = $data; + $this->is_whitespace = $is_whitespace; + $this->line = $line; + $this->col = $col; + } + + public function toTokenPair() { + return array(new HTMLPurifier_Token_Text($this->data, $this->line, $this->col), null); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PercentEncoder.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PercentEncoder.php new file mode 100644 index 0000000..18c8bbb --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PercentEncoder.php @@ -0,0 +1,111 @@ +preserve[$i] = true; + } + for ($i = 65; $i <= 90; $i++) { // upper-case + $this->preserve[$i] = true; + } + for ($i = 97; $i <= 122; $i++) { // lower-case + $this->preserve[$i] = true; + } + $this->preserve[45] = true; // Dash - + $this->preserve[46] = true; // Period . + $this->preserve[95] = true; // Underscore _ + $this->preserve[126]= true; // Tilde ~ + + // extra letters not to escape + if ($preserve !== false) { + for ($i = 0, $c = strlen($preserve); $i < $c; $i++) { + $this->preserve[ord($preserve[$i])] = true; + } + } + } + + /** + * Our replacement for urlencode, it encodes all non-reserved characters, + * as well as any extra characters that were instructed to be preserved. + * @note + * Assumes that the string has already been normalized, making any + * and all percent escape sequences valid. Percents will not be + * re-escaped, regardless of their status in $preserve + * @param string $string String to be encoded + * @return string Encoded string. + */ + public function encode($string) + { + $ret = ''; + for ($i = 0, $c = strlen($string); $i < $c; $i++) { + if ($string[$i] !== '%' && !isset($this->preserve[$int = ord($string[$i])])) { + $ret .= '%' . sprintf('%02X', $int); + } else { + $ret .= $string[$i]; + } + } + return $ret; + } + + /** + * Fix up percent-encoding by decoding unreserved characters and normalizing. + * @warning This function is affected by $preserve, even though the + * usual desired behavior is for this not to preserve those + * characters. Be careful when reusing instances of PercentEncoder! + * @param string $string String to normalize + * @return string + */ + public function normalize($string) + { + if ($string == '') { + return ''; + } + $parts = explode('%', $string); + $ret = array_shift($parts); + foreach ($parts as $part) { + $length = strlen($part); + if ($length < 2) { + $ret .= '%25' . $part; + continue; + } + $encoding = substr($part, 0, 2); + $text = substr($part, 2); + if (!ctype_xdigit($encoding)) { + $ret .= '%25' . $part; + continue; + } + $int = hexdec($encoding); + if (isset($this->preserve[$int])) { + $ret .= chr($int) . $text; + continue; + } + $encoding = strtoupper($encoding); + $ret .= '%' . $encoding . $text; + } + return $ret; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer.php new file mode 100644 index 0000000..549e4ce --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer.php @@ -0,0 +1,218 @@ +getAll(); + $context = new HTMLPurifier_Context(); + $this->generator = new HTMLPurifier_Generator($config, $context); + } + + /** + * Main function that renders object or aspect of that object + * @note Parameters vary depending on printer + */ + // function render() {} + + /** + * Returns a start tag + * @param string $tag Tag name + * @param array $attr Attribute array + * @return string + */ + protected function start($tag, $attr = array()) + { + return $this->generator->generateFromToken( + new HTMLPurifier_Token_Start($tag, $attr ? $attr : array()) + ); + } + + /** + * Returns an end tag + * @param string $tag Tag name + * @return string + */ + protected function end($tag) + { + return $this->generator->generateFromToken( + new HTMLPurifier_Token_End($tag) + ); + } + + /** + * Prints a complete element with content inside + * @param string $tag Tag name + * @param string $contents Element contents + * @param array $attr Tag attributes + * @param bool $escape whether or not to escape contents + * @return string + */ + protected function element($tag, $contents, $attr = array(), $escape = true) + { + return $this->start($tag, $attr) . + ($escape ? $this->escape($contents) : $contents) . + $this->end($tag); + } + + /** + * @param string $tag + * @param array $attr + * @return string + */ + protected function elementEmpty($tag, $attr = array()) + { + return $this->generator->generateFromToken( + new HTMLPurifier_Token_Empty($tag, $attr) + ); + } + + /** + * @param string $text + * @return string + */ + protected function text($text) + { + return $this->generator->generateFromToken( + new HTMLPurifier_Token_Text($text) + ); + } + + /** + * Prints a simple key/value row in a table. + * @param string $name Key + * @param mixed $value Value + * @return string + */ + protected function row($name, $value) + { + if (is_bool($value)) { + $value = $value ? 'On' : 'Off'; + } + return + $this->start('tr') . "\n" . + $this->element('th', $name) . "\n" . + $this->element('td', $value) . "\n" . + $this->end('tr'); + } + + /** + * Escapes a string for HTML output. + * @param string $string String to escape + * @return string + */ + protected function escape($string) + { + $string = HTMLPurifier_Encoder::cleanUTF8($string); + $string = htmlspecialchars($string, ENT_COMPAT, 'UTF-8'); + return $string; + } + + /** + * Takes a list of strings and turns them into a single list + * @param string[] $array List of strings + * @param bool $polite Bool whether or not to add an end before the last + * @return string + */ + protected function listify($array, $polite = false) + { + if (empty($array)) { + return 'None'; + } + $ret = ''; + $i = count($array); + foreach ($array as $value) { + $i--; + $ret .= $value; + if ($i > 0 && !($polite && $i == 1)) { + $ret .= ', '; + } + if ($polite && $i == 1) { + $ret .= 'and '; + } + } + return $ret; + } + + /** + * Retrieves the class of an object without prefixes, as well as metadata + * @param object $obj Object to determine class of + * @param string $sec_prefix Further prefix to remove + * @return string + */ + protected function getClass($obj, $sec_prefix = '') + { + static $five = null; + if ($five === null) { + $five = version_compare(PHP_VERSION, '5', '>='); + } + $prefix = 'HTMLPurifier_' . $sec_prefix; + if (!$five) { + $prefix = strtolower($prefix); + } + $class = str_replace($prefix, '', get_class($obj)); + $lclass = strtolower($class); + $class .= '('; + switch ($lclass) { + case 'enum': + $values = array(); + foreach ($obj->valid_values as $value => $bool) { + $values[] = $value; + } + $class .= implode(', ', $values); + break; + case 'css_composite': + $values = array(); + foreach ($obj->defs as $def) { + $values[] = $this->getClass($def, $sec_prefix); + } + $class .= implode(', ', $values); + break; + case 'css_multiple': + $class .= $this->getClass($obj->single, $sec_prefix) . ', '; + $class .= $obj->max; + break; + case 'css_denyelementdecorator': + $class .= $this->getClass($obj->def, $sec_prefix) . ', '; + $class .= $obj->element; + break; + case 'css_importantdecorator': + $class .= $this->getClass($obj->def, $sec_prefix); + if ($obj->allow) { + $class .= ', !important'; + } + break; + } + $class .= ')'; + return $class; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/CSSDefinition.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/CSSDefinition.php new file mode 100644 index 0000000..29505fe --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/CSSDefinition.php @@ -0,0 +1,44 @@ +def = $config->getCSSDefinition(); + $ret = ''; + + $ret .= $this->start('div', array('class' => 'HTMLPurifier_Printer')); + $ret .= $this->start('table'); + + $ret .= $this->element('caption', 'Properties ($info)'); + + $ret .= $this->start('thead'); + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Property', array('class' => 'heavy')); + $ret .= $this->element('th', 'Definition', array('class' => 'heavy', 'style' => 'width:auto;')); + $ret .= $this->end('tr'); + $ret .= $this->end('thead'); + + ksort($this->def->info); + foreach ($this->def->info as $property => $obj) { + $name = $this->getClass($obj, 'AttrDef_'); + $ret .= $this->row($property, $name); + } + + $ret .= $this->end('table'); + $ret .= $this->end('div'); + + return $ret; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.css b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.css new file mode 100644 index 0000000..3ff1a88 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.css @@ -0,0 +1,10 @@ + +.hp-config {} + +.hp-config tbody th {text-align:right; padding-right:0.5em;} +.hp-config thead, .hp-config .namespace {background:#3C578C; color:#FFF;} +.hp-config .namespace th {text-align:center;} +.hp-config .verbose {display:none;} +.hp-config .controls {text-align:center;} + +/* vim: et sw=4 sts=4 */ diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.js b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.js new file mode 100644 index 0000000..cba00c9 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.js @@ -0,0 +1,5 @@ +function toggleWriteability(id_of_patient, checked) { + document.getElementById(id_of_patient).disabled = checked; +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.php new file mode 100644 index 0000000..4c3ce17 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/ConfigForm.php @@ -0,0 +1,456 @@ +docURL = $doc_url; + $this->name = $name; + $this->compress = $compress; + // initialize sub-printers + $this->fields[0] = new HTMLPurifier_Printer_ConfigForm_default(); + $this->fields[HTMLPurifier_VarParser::C_BOOL] = new HTMLPurifier_Printer_ConfigForm_bool(); + } + + /** + * Sets default column and row size for textareas in sub-printers + * @param $cols Integer columns of textarea, null to use default + * @param $rows Integer rows of textarea, null to use default + */ + public function setTextareaDimensions($cols = null, $rows = null) + { + if ($cols) { + $this->fields['default']->cols = $cols; + } + if ($rows) { + $this->fields['default']->rows = $rows; + } + } + + /** + * Retrieves styling, in case it is not accessible by webserver + */ + public static function getCSS() + { + return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.css'); + } + + /** + * Retrieves JavaScript, in case it is not accessible by webserver + */ + public static function getJavaScript() + { + return file_get_contents(HTMLPURIFIER_PREFIX . '/HTMLPurifier/Printer/ConfigForm.js'); + } + + /** + * Returns HTML output for a configuration form + * @param HTMLPurifier_Config|array $config Configuration object of current form state, or an array + * where [0] has an HTML namespace and [1] is being rendered. + * @param array|bool $allowed Optional namespace(s) and directives to restrict form to. + * @param bool $render_controls + * @return string + */ + public function render($config, $allowed = true, $render_controls = true) + { + if (is_array($config) && isset($config[0])) { + $gen_config = $config[0]; + $config = $config[1]; + } else { + $gen_config = $config; + } + + $this->config = $config; + $this->genConfig = $gen_config; + $this->prepareGenerator($gen_config); + + $allowed = HTMLPurifier_Config::getAllowedDirectivesForForm($allowed, $config->def); + $all = array(); + foreach ($allowed as $key) { + list($ns, $directive) = $key; + $all[$ns][$directive] = $config->get($ns . '.' . $directive); + } + + $ret = ''; + $ret .= $this->start('table', array('class' => 'hp-config')); + $ret .= $this->start('thead'); + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Directive', array('class' => 'hp-directive')); + $ret .= $this->element('th', 'Value', array('class' => 'hp-value')); + $ret .= $this->end('tr'); + $ret .= $this->end('thead'); + foreach ($all as $ns => $directives) { + $ret .= $this->renderNamespace($ns, $directives); + } + if ($render_controls) { + $ret .= $this->start('tbody'); + $ret .= $this->start('tr'); + $ret .= $this->start('td', array('colspan' => 2, 'class' => 'controls')); + $ret .= $this->elementEmpty('input', array('type' => 'submit', 'value' => 'Submit')); + $ret .= '[Reset]'; + $ret .= $this->end('td'); + $ret .= $this->end('tr'); + $ret .= $this->end('tbody'); + } + $ret .= $this->end('table'); + return $ret; + } + + /** + * Renders a single namespace + * @param $ns String namespace name + * @param array $directives array of directives to values + * @return string + */ + protected function renderNamespace($ns, $directives) + { + $ret = ''; + $ret .= $this->start('tbody', array('class' => 'namespace')); + $ret .= $this->start('tr'); + $ret .= $this->element('th', $ns, array('colspan' => 2)); + $ret .= $this->end('tr'); + $ret .= $this->end('tbody'); + $ret .= $this->start('tbody'); + foreach ($directives as $directive => $value) { + $ret .= $this->start('tr'); + $ret .= $this->start('th'); + if ($this->docURL) { + $url = str_replace('%s', urlencode("$ns.$directive"), $this->docURL); + $ret .= $this->start('a', array('href' => $url)); + } + $attr = array('for' => "{$this->name}:$ns.$directive"); + + // crop directive name if it's too long + if (!$this->compress || (strlen($directive) < $this->compress)) { + $directive_disp = $directive; + } else { + $directive_disp = substr($directive, 0, $this->compress - 2) . '...'; + $attr['title'] = $directive; + } + + $ret .= $this->element( + 'label', + $directive_disp, + // component printers must create an element with this id + $attr + ); + if ($this->docURL) { + $ret .= $this->end('a'); + } + $ret .= $this->end('th'); + + $ret .= $this->start('td'); + $def = $this->config->def->info["$ns.$directive"]; + if (is_int($def)) { + $allow_null = $def < 0; + $type = abs($def); + } else { + $type = $def->type; + $allow_null = isset($def->allow_null); + } + if (!isset($this->fields[$type])) { + $type = 0; + } // default + $type_obj = $this->fields[$type]; + if ($allow_null) { + $type_obj = new HTMLPurifier_Printer_ConfigForm_NullDecorator($type_obj); + } + $ret .= $type_obj->render($ns, $directive, $value, $this->name, array($this->genConfig, $this->config)); + $ret .= $this->end('td'); + $ret .= $this->end('tr'); + } + $ret .= $this->end('tbody'); + return $ret; + } + +} + +/** + * Printer decorator for directives that accept null + */ +class HTMLPurifier_Printer_ConfigForm_NullDecorator extends HTMLPurifier_Printer +{ + /** + * Printer being decorated + * @type HTMLPurifier_Printer + */ + protected $obj; + + /** + * @param HTMLPurifier_Printer $obj Printer to decorate + */ + public function __construct($obj) + { + parent::__construct(); + $this->obj = $obj; + } + + /** + * @param string $ns + * @param string $directive + * @param string $value + * @param string $name + * @param HTMLPurifier_Config|array $config + * @return string + */ + public function render($ns, $directive, $value, $name, $config) + { + if (is_array($config) && isset($config[0])) { + $gen_config = $config[0]; + $config = $config[1]; + } else { + $gen_config = $config; + } + $this->prepareGenerator($gen_config); + + $ret = ''; + $ret .= $this->start('label', array('for' => "$name:Null_$ns.$directive")); + $ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose')); + $ret .= $this->text(' Null/Disabled'); + $ret .= $this->end('label'); + $attr = array( + 'type' => 'checkbox', + 'value' => '1', + 'class' => 'null-toggle', + 'name' => "$name" . "[Null_$ns.$directive]", + 'id' => "$name:Null_$ns.$directive", + 'onclick' => "toggleWriteability('$name:$ns.$directive',checked)" // INLINE JAVASCRIPT!!!! + ); + if ($this->obj instanceof HTMLPurifier_Printer_ConfigForm_bool) { + // modify inline javascript slightly + $attr['onclick'] = + "toggleWriteability('$name:Yes_$ns.$directive',checked);" . + "toggleWriteability('$name:No_$ns.$directive',checked)"; + } + if ($value === null) { + $attr['checked'] = 'checked'; + } + $ret .= $this->elementEmpty('input', $attr); + $ret .= $this->text(' or '); + $ret .= $this->elementEmpty('br'); + $ret .= $this->obj->render($ns, $directive, $value, $name, array($gen_config, $config)); + return $ret; + } +} + +/** + * Swiss-army knife configuration form field printer + */ +class HTMLPurifier_Printer_ConfigForm_default extends HTMLPurifier_Printer +{ + /** + * @type int + */ + public $cols = 18; + + /** + * @type int + */ + public $rows = 5; + + /** + * @param string $ns + * @param string $directive + * @param string $value + * @param string $name + * @param HTMLPurifier_Config|array $config + * @return string + */ + public function render($ns, $directive, $value, $name, $config) + { + if (is_array($config) && isset($config[0])) { + $gen_config = $config[0]; + $config = $config[1]; + } else { + $gen_config = $config; + } + $this->prepareGenerator($gen_config); + // this should probably be split up a little + $ret = ''; + $def = $config->def->info["$ns.$directive"]; + if (is_int($def)) { + $type = abs($def); + } else { + $type = $def->type; + } + if (is_array($value)) { + switch ($type) { + case HTMLPurifier_VarParser::LOOKUP: + $array = $value; + $value = array(); + foreach ($array as $val => $b) { + $value[] = $val; + } + //TODO does this need a break? + case HTMLPurifier_VarParser::ALIST: + $value = implode(PHP_EOL, $value); + break; + case HTMLPurifier_VarParser::HASH: + $nvalue = ''; + foreach ($value as $i => $v) { + if (is_array($v)) { + // HACK + $v = implode(";", $v); + } + $nvalue .= "$i:$v" . PHP_EOL; + } + $value = $nvalue; + break; + default: + $value = ''; + } + } + if ($type === HTMLPurifier_VarParser::C_MIXED) { + return 'Not supported'; + $value = serialize($value); + } + $attr = array( + 'name' => "$name" . "[$ns.$directive]", + 'id' => "$name:$ns.$directive" + ); + if ($value === null) { + $attr['disabled'] = 'disabled'; + } + if (isset($def->allowed)) { + $ret .= $this->start('select', $attr); + foreach ($def->allowed as $val => $b) { + $attr = array(); + if ($value == $val) { + $attr['selected'] = 'selected'; + } + $ret .= $this->element('option', $val, $attr); + } + $ret .= $this->end('select'); + } elseif ($type === HTMLPurifier_VarParser::TEXT || + $type === HTMLPurifier_VarParser::ITEXT || + $type === HTMLPurifier_VarParser::ALIST || + $type === HTMLPurifier_VarParser::HASH || + $type === HTMLPurifier_VarParser::LOOKUP) { + $attr['cols'] = $this->cols; + $attr['rows'] = $this->rows; + $ret .= $this->start('textarea', $attr); + $ret .= $this->text($value); + $ret .= $this->end('textarea'); + } else { + $attr['value'] = $value; + $attr['type'] = 'text'; + $ret .= $this->elementEmpty('input', $attr); + } + return $ret; + } +} + +/** + * Bool form field printer + */ +class HTMLPurifier_Printer_ConfigForm_bool extends HTMLPurifier_Printer +{ + /** + * @param string $ns + * @param string $directive + * @param string $value + * @param string $name + * @param HTMLPurifier_Config|array $config + * @return string + */ + public function render($ns, $directive, $value, $name, $config) + { + if (is_array($config) && isset($config[0])) { + $gen_config = $config[0]; + $config = $config[1]; + } else { + $gen_config = $config; + } + $this->prepareGenerator($gen_config); + $ret = ''; + $ret .= $this->start('div', array('id' => "$name:$ns.$directive")); + + $ret .= $this->start('label', array('for' => "$name:Yes_$ns.$directive")); + $ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose')); + $ret .= $this->text(' Yes'); + $ret .= $this->end('label'); + + $attr = array( + 'type' => 'radio', + 'name' => "$name" . "[$ns.$directive]", + 'id' => "$name:Yes_$ns.$directive", + 'value' => '1' + ); + if ($value === true) { + $attr['checked'] = 'checked'; + } + if ($value === null) { + $attr['disabled'] = 'disabled'; + } + $ret .= $this->elementEmpty('input', $attr); + + $ret .= $this->start('label', array('for' => "$name:No_$ns.$directive")); + $ret .= $this->element('span', "$ns.$directive:", array('class' => 'verbose')); + $ret .= $this->text(' No'); + $ret .= $this->end('label'); + + $attr = array( + 'type' => 'radio', + 'name' => "$name" . "[$ns.$directive]", + 'id' => "$name:No_$ns.$directive", + 'value' => '0' + ); + if ($value === false) { + $attr['checked'] = 'checked'; + } + if ($value === null) { + $attr['disabled'] = 'disabled'; + } + $ret .= $this->elementEmpty('input', $attr); + + $ret .= $this->end('div'); + + return $ret; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/HTMLDefinition.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/HTMLDefinition.php new file mode 100644 index 0000000..ae86391 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Printer/HTMLDefinition.php @@ -0,0 +1,324 @@ +config =& $config; + + $this->def = $config->getHTMLDefinition(); + + $ret .= $this->start('div', array('class' => 'HTMLPurifier_Printer')); + + $ret .= $this->renderDoctype(); + $ret .= $this->renderEnvironment(); + $ret .= $this->renderContentSets(); + $ret .= $this->renderInfo(); + + $ret .= $this->end('div'); + + return $ret; + } + + /** + * Renders the Doctype table + * @return string + */ + protected function renderDoctype() + { + $doctype = $this->def->doctype; + $ret = ''; + $ret .= $this->start('table'); + $ret .= $this->element('caption', 'Doctype'); + $ret .= $this->row('Name', $doctype->name); + $ret .= $this->row('XML', $doctype->xml ? 'Yes' : 'No'); + $ret .= $this->row('Default Modules', implode(', ', $doctype->modules)); + $ret .= $this->row('Default Tidy Modules', implode(', ', $doctype->tidyModules)); + $ret .= $this->end('table'); + return $ret; + } + + + /** + * Renders environment table, which is miscellaneous info + * @return string + */ + protected function renderEnvironment() + { + $def = $this->def; + + $ret = ''; + + $ret .= $this->start('table'); + $ret .= $this->element('caption', 'Environment'); + + $ret .= $this->row('Parent of fragment', $def->info_parent); + $ret .= $this->renderChildren($def->info_parent_def->child); + $ret .= $this->row('Block wrap name', $def->info_block_wrapper); + + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Global attributes'); + $ret .= $this->element('td', $this->listifyAttr($def->info_global_attr), null, 0); + $ret .= $this->end('tr'); + + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Tag transforms'); + $list = array(); + foreach ($def->info_tag_transform as $old => $new) { + $new = $this->getClass($new, 'TagTransform_'); + $list[] = "<$old> with $new"; + } + $ret .= $this->element('td', $this->listify($list)); + $ret .= $this->end('tr'); + + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Pre-AttrTransform'); + $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_pre)); + $ret .= $this->end('tr'); + + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Post-AttrTransform'); + $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_post)); + $ret .= $this->end('tr'); + + $ret .= $this->end('table'); + return $ret; + } + + /** + * Renders the Content Sets table + * @return string + */ + protected function renderContentSets() + { + $ret = ''; + $ret .= $this->start('table'); + $ret .= $this->element('caption', 'Content Sets'); + foreach ($this->def->info_content_sets as $name => $lookup) { + $ret .= $this->heavyHeader($name); + $ret .= $this->start('tr'); + $ret .= $this->element('td', $this->listifyTagLookup($lookup)); + $ret .= $this->end('tr'); + } + $ret .= $this->end('table'); + return $ret; + } + + /** + * Renders the Elements ($info) table + * @return string + */ + protected function renderInfo() + { + $ret = ''; + $ret .= $this->start('table'); + $ret .= $this->element('caption', 'Elements ($info)'); + ksort($this->def->info); + $ret .= $this->heavyHeader('Allowed tags', 2); + $ret .= $this->start('tr'); + $ret .= $this->element('td', $this->listifyTagLookup($this->def->info), array('colspan' => 2)); + $ret .= $this->end('tr'); + foreach ($this->def->info as $name => $def) { + $ret .= $this->start('tr'); + $ret .= $this->element('th', "<$name>", array('class' => 'heavy', 'colspan' => 2)); + $ret .= $this->end('tr'); + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Inline content'); + $ret .= $this->element('td', $def->descendants_are_inline ? 'Yes' : 'No'); + $ret .= $this->end('tr'); + if (!empty($def->excludes)) { + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Excludes'); + $ret .= $this->element('td', $this->listifyTagLookup($def->excludes)); + $ret .= $this->end('tr'); + } + if (!empty($def->attr_transform_pre)) { + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Pre-AttrTransform'); + $ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_pre)); + $ret .= $this->end('tr'); + } + if (!empty($def->attr_transform_post)) { + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Post-AttrTransform'); + $ret .= $this->element('td', $this->listifyObjectList($def->attr_transform_post)); + $ret .= $this->end('tr'); + } + if (!empty($def->auto_close)) { + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Auto closed by'); + $ret .= $this->element('td', $this->listifyTagLookup($def->auto_close)); + $ret .= $this->end('tr'); + } + $ret .= $this->start('tr'); + $ret .= $this->element('th', 'Allowed attributes'); + $ret .= $this->element('td', $this->listifyAttr($def->attr), array(), 0); + $ret .= $this->end('tr'); + + if (!empty($def->required_attr)) { + $ret .= $this->row('Required attributes', $this->listify($def->required_attr)); + } + + $ret .= $this->renderChildren($def->child); + } + $ret .= $this->end('table'); + return $ret; + } + + /** + * Renders a row describing the allowed children of an element + * @param HTMLPurifier_ChildDef $def HTMLPurifier_ChildDef of pertinent element + * @return string + */ + protected function renderChildren($def) + { + $context = new HTMLPurifier_Context(); + $ret = ''; + $ret .= $this->start('tr'); + $elements = array(); + $attr = array(); + if (isset($def->elements)) { + if ($def->type == 'strictblockquote') { + $def->validateChildren(array(), $this->config, $context); + } + $elements = $def->elements; + } + if ($def->type == 'chameleon') { + $attr['rowspan'] = 2; + } elseif ($def->type == 'empty') { + $elements = array(); + } elseif ($def->type == 'table') { + $elements = array_flip( + array( + 'col', + 'caption', + 'colgroup', + 'thead', + 'tfoot', + 'tbody', + 'tr' + ) + ); + } + $ret .= $this->element('th', 'Allowed children', $attr); + + if ($def->type == 'chameleon') { + + $ret .= $this->element( + 'td', + 'Block: ' . + $this->escape($this->listifyTagLookup($def->block->elements)), + null, + 0 + ); + $ret .= $this->end('tr'); + $ret .= $this->start('tr'); + $ret .= $this->element( + 'td', + 'Inline: ' . + $this->escape($this->listifyTagLookup($def->inline->elements)), + null, + 0 + ); + + } elseif ($def->type == 'custom') { + + $ret .= $this->element( + 'td', + '' . ucfirst($def->type) . ': ' . + $def->dtd_regex + ); + + } else { + $ret .= $this->element( + 'td', + '' . ucfirst($def->type) . ': ' . + $this->escape($this->listifyTagLookup($elements)), + null, + 0 + ); + } + $ret .= $this->end('tr'); + return $ret; + } + + /** + * Listifies a tag lookup table. + * @param array $array Tag lookup array in form of array('tagname' => true) + * @return string + */ + protected function listifyTagLookup($array) + { + ksort($array); + $list = array(); + foreach ($array as $name => $discard) { + if ($name !== '#PCDATA' && !isset($this->def->info[$name])) { + continue; + } + $list[] = $name; + } + return $this->listify($list); + } + + /** + * Listifies a list of objects by retrieving class names and internal state + * @param array $array List of objects + * @return string + * @todo Also add information about internal state + */ + protected function listifyObjectList($array) + { + ksort($array); + $list = array(); + foreach ($array as $obj) { + $list[] = $this->getClass($obj, 'AttrTransform_'); + } + return $this->listify($list); + } + + /** + * Listifies a hash of attributes to AttrDef classes + * @param array $array Array hash in form of array('attrname' => HTMLPurifier_AttrDef) + * @return string + */ + protected function listifyAttr($array) + { + ksort($array); + $list = array(); + foreach ($array as $name => $obj) { + if ($obj === false) { + continue; + } + $list[] = "$name = " . $this->getClass($obj, 'AttrDef_') . ''; + } + return $this->listify($list); + } + + /** + * Creates a heavy header row + * @param string $text + * @param int $num + * @return string + */ + protected function heavyHeader($text, $num = 1) + { + $ret = ''; + $ret .= $this->start('tr'); + $ret .= $this->element('th', $text, array('colspan' => $num, 'class' => 'heavy')); + $ret .= $this->end('tr'); + return $ret; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyList.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyList.php new file mode 100644 index 0000000..189348f --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyList.php @@ -0,0 +1,122 @@ +parent = $parent; + } + + /** + * Recursively retrieves the value for a key + * @param string $name + * @throws HTMLPurifier_Exception + */ + public function get($name) + { + if ($this->has($name)) { + return $this->data[$name]; + } + // possible performance bottleneck, convert to iterative if necessary + if ($this->parent) { + return $this->parent->get($name); + } + throw new HTMLPurifier_Exception("Key '$name' not found"); + } + + /** + * Sets the value of a key, for this plist + * @param string $name + * @param mixed $value + */ + public function set($name, $value) + { + $this->data[$name] = $value; + } + + /** + * Returns true if a given key exists + * @param string $name + * @return bool + */ + public function has($name) + { + return array_key_exists($name, $this->data); + } + + /** + * Resets a value to the value of it's parent, usually the default. If + * no value is specified, the entire plist is reset. + * @param string $name + */ + public function reset($name = null) + { + if ($name == null) { + $this->data = array(); + } else { + unset($this->data[$name]); + } + } + + /** + * Squashes this property list and all of its property lists into a single + * array, and returns the array. This value is cached by default. + * @param bool $force If true, ignores the cache and regenerates the array. + * @return array + */ + public function squash($force = false) + { + if ($this->cache !== null && !$force) { + return $this->cache; + } + if ($this->parent) { + return $this->cache = array_merge($this->parent->squash($force), $this->data); + } else { + return $this->cache = $this->data; + } + } + + /** + * Returns the parent plist. + * @return HTMLPurifier_PropertyList + */ + public function getParent() + { + return $this->parent; + } + + /** + * Sets the parent plist. + * @param HTMLPurifier_PropertyList $plist Parent plist + */ + public function setParent($plist) + { + $this->parent = $plist; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyListIterator.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyListIterator.php new file mode 100644 index 0000000..f68fc8c --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/PropertyListIterator.php @@ -0,0 +1,43 @@ +l = strlen($filter); + $this->filter = $filter; + } + + /** + * @return bool + */ + #[\ReturnTypeWillChange] + public function accept() + { + $key = $this->getInnerIterator()->key(); + if (strncmp($key, $this->filter, $this->l) !== 0) { + return false; + } + return true; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Queue.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Queue.php new file mode 100644 index 0000000..f58db90 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Queue.php @@ -0,0 +1,56 @@ +input = $input; + $this->output = array(); + } + + /** + * Shifts an element off the front of the queue. + */ + public function shift() { + if (empty($this->output)) { + $this->output = array_reverse($this->input); + $this->input = array(); + } + if (empty($this->output)) { + return NULL; + } + return array_pop($this->output); + } + + /** + * Pushes an element onto the front of the queue. + */ + public function push($x) { + array_push($this->input, $x); + } + + /** + * Checks if it's empty. + */ + public function isEmpty() { + return empty($this->input) && empty($this->output); + } +} diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy.php new file mode 100644 index 0000000..e1ff3b7 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy.php @@ -0,0 +1,26 @@ +strategies as $strategy) { + $tokens = $strategy->execute($tokens, $config, $context); + } + return $tokens; + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/Core.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/Core.php new file mode 100644 index 0000000..4414c17 --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/Core.php @@ -0,0 +1,17 @@ +strategies[] = new HTMLPurifier_Strategy_RemoveForeignElements(); + $this->strategies[] = new HTMLPurifier_Strategy_MakeWellFormed(); + $this->strategies[] = new HTMLPurifier_Strategy_FixNesting(); + $this->strategies[] = new HTMLPurifier_Strategy_ValidateAttributes(); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/FixNesting.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/FixNesting.php new file mode 100644 index 0000000..6fa673d --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/FixNesting.php @@ -0,0 +1,181 @@ +getHTMLDefinition(); + + $excludes_enabled = !$config->get('Core.DisableExcludes'); + + // setup the context variable 'IsInline', for chameleon processing + // is 'false' when we are not inline, 'true' when it must always + // be inline, and an integer when it is inline for a certain + // branch of the document tree + $is_inline = $definition->info_parent_def->descendants_are_inline; + $context->register('IsInline', $is_inline); + + // setup error collector + $e =& $context->get('ErrorCollector', true); + + //####################################################################// + // Loop initialization + + // stack that contains all elements that are excluded + // it is organized by parent elements, similar to $stack, + // but it is only populated when an element with exclusions is + // processed, i.e. there won't be empty exclusions. + $exclude_stack = array($definition->info_parent_def->excludes); + + // variable that contains the start token while we are processing + // nodes. This enables error reporting to do its job + $node = $top_node; + // dummy token + list($token, $d) = $node->toTokenPair(); + $context->register('CurrentNode', $node); + $context->register('CurrentToken', $token); + + //####################################################################// + // Loop + + // We need to implement a post-order traversal iteratively, to + // avoid running into stack space limits. This is pretty tricky + // to reason about, so we just manually stack-ify the recursive + // variant: + // + // function f($node) { + // foreach ($node->children as $child) { + // f($child); + // } + // validate($node); + // } + // + // Thus, we will represent a stack frame as array($node, + // $is_inline, stack of children) + // e.g. array_reverse($node->children) - already processed + // children. + + $parent_def = $definition->info_parent_def; + $stack = array( + array($top_node, + $parent_def->descendants_are_inline, + $parent_def->excludes, // exclusions + 0) + ); + + while (!empty($stack)) { + list($node, $is_inline, $excludes, $ix) = array_pop($stack); + // recursive call + $go = false; + $def = empty($stack) ? $definition->info_parent_def : $definition->info[$node->name]; + while (isset($node->children[$ix])) { + $child = $node->children[$ix++]; + if ($child instanceof HTMLPurifier_Node_Element) { + $go = true; + $stack[] = array($node, $is_inline, $excludes, $ix); + $stack[] = array($child, + // ToDo: I don't think it matters if it's def or + // child_def, but double check this... + $is_inline || $def->descendants_are_inline, + empty($def->excludes) ? $excludes + : array_merge($excludes, $def->excludes), + 0); + break; + } + }; + if ($go) continue; + list($token, $d) = $node->toTokenPair(); + // base case + if ($excludes_enabled && isset($excludes[$node->name])) { + $node->dead = true; + if ($e) $e->send(E_ERROR, 'Strategy_FixNesting: Node excluded'); + } else { + // XXX I suppose it would be slightly more efficient to + // avoid the allocation here and have children + // strategies handle it + $children = array(); + foreach ($node->children as $child) { + if (!$child->dead) $children[] = $child; + } + $result = $def->child->validateChildren($children, $config, $context); + if ($result === true) { + // nop + $node->children = $children; + } elseif ($result === false) { + $node->dead = true; + if ($e) $e->send(E_ERROR, 'Strategy_FixNesting: Node removed'); + } else { + $node->children = $result; + if ($e) { + // XXX This will miss mutations of internal nodes. Perhaps defer to the child validators + if (empty($result) && !empty($children)) { + $e->send(E_ERROR, 'Strategy_FixNesting: Node contents removed'); + } else if ($result != $children) { + $e->send(E_WARNING, 'Strategy_FixNesting: Node reorganized'); + } + } + } + } + } + + //####################################################################// + // Post-processing + + // remove context variables + $context->destroy('IsInline'); + $context->destroy('CurrentNode'); + $context->destroy('CurrentToken'); + + //####################################################################// + // Return + + return HTMLPurifier_Arborize::flatten($node, $config, $context); + } +} + +// vim: et sw=4 sts=4 diff --git a/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/MakeWellFormed.php b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/MakeWellFormed.php new file mode 100644 index 0000000..a6eb09e --- /dev/null +++ b/vendor/ezyang/htmlpurifier/library/HTMLPurifier/Strategy/MakeWellFormed.php @@ -0,0 +1,659 @@ +getHTMLDefinition(); + + // local variables + $generator = new HTMLPurifier_Generator($config, $context); + $escape_invalid_tags = $config->get('Core.EscapeInvalidTags'); + // used for autoclose early abortion + $global_parent_allowed_elements = $definition->info_parent_def->child->getAllowedElements($config); + $e = $context->get('ErrorCollector', true); + $i = false; // injector index + list($zipper, $token) = HTMLPurifier_Zipper::fromArray($tokens); + if ($token === NULL) { + return array(); + } + $reprocess = false; // whether or not to reprocess the same token + $stack = array(); + + // member variables + $this->stack =& $stack; + $this->tokens =& $tokens; + $this->token =& $token; + $this->zipper =& $zipper; + $this->config = $config; + $this->context = $context; + + // context variables + $context->register('CurrentNesting', $stack); + $context->register('InputZipper', $zipper); + $context->register('CurrentToken', $token); + + // -- begin INJECTOR -- + + $this->injectors = array(); + + $injectors = $config->getBatch('AutoFormat'); + $def_injectors = $definition->info_injector; + $custom_injectors = $injectors['Custom']; + unset($injectors['Custom']); // special case + foreach ($injectors as $injector => $b) { + // XXX: Fix with a legitimate lookup table of enabled filters + if (strpos($injector, '.') !== false) { + continue; + } + $injector = "HTMLPurifier_Injector_$injector"; + if (!$b) { + continue; + } + $this->injectors[] = new $injector; + } + foreach ($def_injectors as $injector) { + // assumed to be objects + $this->injectors[] = $injector; + } + foreach ($custom_injectors as $injector) { + if (!$injector) { + continue; + } + if (is_string($injector)) { + $injector = "HTMLPurifier_Injector_$injector"; + $injector = new $injector; + } + $this->injectors[] = $injector; + } + + // give the injectors references to the definition and context + // variables for performance reasons + foreach ($this->injectors as $ix => $injector) { + $error = $injector->prepare($config, $context); + if (!$error) { + continue; + } + array_splice($this->injectors, $ix, 1); // rm the injector + trigger_error("Cannot enable {$injector->name} injector because $error is not allowed", E_USER_WARNING); + } + + // -- end INJECTOR -- + + // a note on reprocessing: + // In order to reduce code duplication, whenever some code needs + // to make HTML changes in order to make things "correct", the + // new HTML gets sent through the purifier, regardless of its + // status. This means that if we add a start token, because it + // was totally necessary, we don't have to update nesting; we just + // punt ($reprocess = true; continue;) and it does that for us. + + // isset is in loop because $tokens size changes during loop exec + for (;; + // only increment if we don't need to reprocess + $reprocess ? $reprocess = false : $token = $zipper->next($token)) { + + // check for a rewind + if (is_int($i)) { + // possibility: disable rewinding if the current token has a + // rewind set on it already. This would offer protection from + // infinite loop, but might hinder some advanced rewinding. + $rewind_offset = $this->injectors[$i]->getRewindOffset(); + if (is_int($rewind_offset)) { + for ($j = 0; $j < $rewind_offset; $j++) { + if (empty($zipper->front)) break; + $token = $zipper->prev($token); + // indicate that other injectors should not process this token, + // but we need to reprocess it. See Note [Injector skips] + unset($token->skip[$i]); + $token->rewind = $i; + if ($token instanceof HTMLPurifier_Token_Start) { + array_pop($this->stack); + } elseif ($token instanceof HTMLPurifier_Token_End) { + $this->stack[] = $token->start; + } + } + } + $i = false; + } + + // handle case of document end + if ($token === NULL) { + // kill processing if stack is empty + if (empty($this->stack)) { + break; + } + + // peek + $top_nesting = array_pop($this->stack); + $this->stack[] = $top_nesting; + + // send error [TagClosedSuppress] + if ($e && !isset($top_nesting->armor['MakeWellFormed_TagClosedError'])) { + $e->send(E_NOTICE, 'Strategy_MakeWellFormed: Tag closed by document end', $top_nesting); + } + + // append, don't splice, since this is the end + $token = new HTMLPurifier_Token_End($top_nesting->name); + + // punt! + $reprocess = true; + continue; + } + + //echo '
'; printZipper($zipper, $token);//printTokens($this->stack); + //flush(); + + // quick-check: if it's not a tag, no need to process + if (empty($token->is_tag)) { + if ($token instanceof HTMLPurifier_Token_Text) { + foreach ($this->injectors as $i => $injector) { + if (isset($token->skip[$i])) { + // See Note [Injector skips] + continue; + } + if ($token->rewind !== null && $token->rewind !== $i) { + continue; + } + // XXX fuckup + $r = $token; + $injector->handleText($r); + $token = $this->processToken($r, $i); + $reprocess = true; + break; + } + } + // another possibility is a comment + continue; + } + + if (isset($definition->info[$token->name])) { + $type = $definition->info[$token->name]->child->type; + } else { + $type = false; // Type is unknown, treat accordingly + } + + // quick tag checks: anything that's *not* an end tag + $ok = false; + if ($type === 'empty' && $token instanceof HTMLPurifier_Token_Start) { + // claims to be a start tag but is empty + $token = new HTMLPurifier_Token_Empty( + $token->name, + $token->attr, + $token->line, + $token->col, + $token->armor + ); + $ok = true; + } elseif ($type && $type !== 'empty' && $token instanceof HTMLPurifier_Token_Empty) { + // claims to be empty but really is a start tag + // NB: this assignment is required + $old_token = $token; + $token = new HTMLPurifier_Token_End($token->name); + $token = $this->insertBefore( + new HTMLPurifier_Token_Start($old_token->name, $old_token->attr, $old_token->line, $old_token->col, $old_token->armor) + ); + // punt (since we had to modify the input stream in a non-trivial way) + $reprocess = true; + continue; + } elseif ($token instanceof HTMLPurifier_Token_Empty) { + // real empty token + $ok = true; + } elseif ($token instanceof HTMLPurifier_Token_Start) { + // start tag + + // ...unless they also have to close their parent + if (!empty($this->stack)) { + + // Performance note: you might think that it's rather + // inefficient, recalculating the autoclose information + // for every tag that a token closes (since when we + // do an autoclose, we push a new token into the + // stream and then /process/ that, before + // re-processing this token.) But this is + // necessary, because an injector can make an + // arbitrary transformations to the autoclosing + // tokens we introduce, so things may have changed + // in the meantime. Also, doing the inefficient thing is + // "easy" to reason about (for certain perverse definitions + // of "easy") + + $parent = array_pop($this->stack); + $this->stack[] = $parent; + + $parent_def = null; + $parent_elements = null; + $autoclose = false; + if (isset($definition->info[$parent->name])) { + $parent_def = $definition->info[$parent->name]; + $parent_elements = $parent_def->child->getAllowedElements($config); + $autoclose = !isset($parent_elements[$token->name]); + } + + if ($autoclose && $definition->info[$token->name]->wrap) { + // Check if an element can be wrapped by another + // element to make it valid in a context (for + // example,