Commit 9846dee5 by biao

Merge branch 'master' of http://gitlib.occloud.net/biao/ZhiNanZhen

* 'master' of http://gitlib.occloud.net/biao/ZhiNanZhen:
  1

# Conflicts:
#	doc/DB/compass_db_schema.sql
#	doc/DB/compass_db_schema.xlsx
#	doc/小程序文件命名以及接口调用说明.xlsx
#	doc/接口文档 V1.0.xls
parents 571058ab 78541f4f
开发服务器:
考拉开发服务器:
111.230.198.141
默认账户为 root ,初始密码:FS3y_e7pZYT?
目录:/var/www/html/compass
管理端:http://manager.koala-online.cn
数据库:http://manager.koala-online.cn/phpMyAdmin
管理端开发地址
http://compass.koala-online.cn/manager
......
1. 小程序开发者账号
1. 小程序开发者账号
......@@ -2,5 +2,4 @@
2.小程序开发者后台开通地图插件
3.腾讯lbs账号
4.阿里云oss key
5.小程序绑定对应公众号
6.
\ No newline at end of file
5.小程序绑定对应公众号
\ No newline at end of file
<?php
/**
* AccountMst Entity
* $Id: AccountMst.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: AccountMst.inc,v 1.1 2020/2/13 10:54:23 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* CertificateMst Entity
* $Id: CertificateMst.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: CertificateMst.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......@@ -10,8 +10,7 @@ class CertificateMst extends CompassDynamicData
{
var $title;
var $front_image;
var $point;
var $status;
var $display_order;
var $delete_flg;
/**
......@@ -24,11 +23,10 @@ class CertificateMst extends CompassDynamicData
{
parent::constructor($record);
$this->title = $record["title"];
$this->front_image = $record["front_image"];
$this->point = $record["point"];
$this->status = $record["status"];
$this->delete_flg = $record["delete_flg"];
$this->title = $record["title"];
$this->front_image = $record["front_image"];
$this->display_order = $record["display_order"];
$this->delete_flg = $record["delete_flg"];
}
/**
......@@ -94,8 +92,7 @@ class CertificateMst extends CompassDynamicData
ParamUtil::copyObj2Array($v_param, $this, "title");
ParamUtil::copyObj2Array($v_param, $this, "front_image");
ParamUtil::copyObj2ArrayNullField($v_param, $this, "point");
ParamUtil::copyObj2Array($v_param, $this, "status");
ParamUtil::copyObj2Array($v_param, $this, "display_order");
ParamUtil::copyObj2Array($v_param, $this, "delete_flg");
// 保存
......
<?php
/**
* CircleDat Entity
* $Id: CircleDat.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: CircleDat.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......@@ -14,6 +14,7 @@ class CircleDat extends CompassDynamicData
var $comment;
var $longitude;
var $latitude;
var $address;
var $owner_id;
var $delete_flg;
......@@ -33,6 +34,7 @@ class CircleDat extends CompassDynamicData
$this->comment = $record["comment"];
$this->longitude = $record["longitude"];
$this->latitude = $record["latitude"];
$this->address = $record["address"];
$this->owner_id = $record["owner_id"];
$this->delete_flg = $record["delete_flg"];
}
......@@ -104,6 +106,7 @@ class CircleDat extends CompassDynamicData
ParamUtil::copyObj2Array($v_param, $this, "comment");
ParamUtil::copyObj2Array($v_param, $this, "longitude");
ParamUtil::copyObj2Array($v_param, $this, "latitude");
ParamUtil::copyObj2Array($v_param, $this, "address");
ParamUtil::copyObj2Array($v_param, $this, "owner_id");
ParamUtil::copyObj2Array($v_param, $this, "delete_flg");
......
<?php
/**
* CircleMemberDat Entity
* $Id: CircleMemberDat.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: CircleMemberDat.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* ClassMst Entity
* $Id: ClassMst.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: ClassMst.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* CourseCategoryDat Entity
* $Id: CourseCategoryDat.inc,v 1.1 2020/1/17 14:38:28 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
*/
class CourseCategoryDat extends CompassDynamicData
{
var $parent_id;
var $title;
var $delete_flg;
/**
* 构造实现。course_category_dat创建实例。
*
* @access public
* @param mixed course_category_dat
*/
function constructor($record)
{
parent::constructor($record);
$this->parent_id = $record["parent_id"];
$this->title = $record["title"];
$this->delete_flg = $record["delete_flg"];
}
/**
* 根据条件,获取数据列表。
* 条件与DBManager的doSelect相同。
* @access public
* @static
* @param array 检索条件
* @return array Entity的队列
*/
public static function getList($w_param = null, $orderkey = null, $direction = "ASC", $offset = null, $limit = null)
{
if ($w_param == null) {
$w_param = array();
$w_param["delete_flg"] = "false";
}
return CompassDBHandler::getList("CourseCategoryDat", "course_category_dat", $w_param, $orderkey, $direction, $offset, $limit);
}
/**
* 根据条件,获取数据列表的件数。
* 条件与DBManager的doSelect相同。
* @access public
* @static
* @param array 检索条件
* @return array Entity的队列
*/
public static function getListCount($w_param = null)
{
if ($w_param == null) {
$w_param = array();
$w_param["delete_flg"] = "false";
}
$db = CompassDBManager::getInstance();
$result = $db->doSelect("course_category_dat", $w_param, null, null, null, null, "count(*) as count");
return $result[0]["count"];
}
/**
* 获得此类指定ID的实例。
*/
public static function getById($id)
{
// delete_flg
$param = array();
$param["delete_flg"] = false;
return CompassDBHandler::getById("CourseCategoryDat", "course_category_dat", $id, $param);
}
// -- 这里开始Dynamic ---
/**
* 将此实例写入DB。
* DynamicData共用的保存方法。
* @access public
* @return int 写入实例的ID
*/
public function save()
{
$v_param = array();
ParamUtil::copyObj2Array($v_param, $this, "parent_id");
ParamUtil::copyObj2Array($v_param, $this, "title");
ParamUtil::copyObj2Array($v_param, $this, "delete_flg");
// 保存
parent::_save("course_category_dat", $v_param);
}
}
\ No newline at end of file
<?php
/**
* CourseMediaDat Entity
* $Id: CourseMediaDat.inc,v 1.1 2020/1/17 14:38:28 Exp $
* $Id: CourseMediaDat.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* CourseMst Entity
* $Id: CourseMst.inc,v 1.1 2020/1/17 14:38:28 Exp $
* $Id: CourseMst.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......@@ -27,10 +27,10 @@ class CourseMst extends CompassDynamicData
$this->parent_category_id = $record["parent_category_id"];
$this->sub_category_id = $record["sub_category_id"];
$this->title = $record["title"];
$this->front_image = $record["front_image"];
$this->teacher_profile = $record["teacher_profile"];
$this->delete_flg = $record["delete_flg"];
$this->title = $record["title"];
$this->front_image = $record["front_image"];
$this->teacher_profile = $record["teacher_profile"];
$this->delete_flg = $record["delete_flg"];
}
/**
......
<?php
/**
* FamilyEventDat Entity
* $Id: FamilyEventDat.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: FamilyEventDat.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......@@ -10,10 +10,12 @@ class FamilyEventDat extends CompassDynamicData
{
var $school_no;
var $class_no;
var $event_id;
var $original_source;
var $title;
var $author;
var $publish_time;
var $images;
var $content;
var $scope;
var $delete_flg;
......@@ -30,10 +32,12 @@ class FamilyEventDat extends CompassDynamicData
$this->school_no = $record["school_no"];
$this->class_no = $record["class_no"];
$this->event_id = $record["event_id"];
$this->original_source = $record["original_source"];
$this->title = $record["title"];
$this->author = $record["author"];
$this->publish_time = $record["publish_time"];
$this->images = $record["images"];
$this->content = $record["content"];
$this->scope = $record["scope"];
$this->delete_flg = $record["delete_flg"];
......@@ -102,10 +106,12 @@ class FamilyEventDat extends CompassDynamicData
ParamUtil::copyObj2Array($v_param, $this, "school_no");
ParamUtil::copyObj2Array($v_param, $this, "class_no");
ParamUtil::copyObj2Array($v_param, $this, "event_id");
ParamUtil::copyObj2Array($v_param, $this, "original_source");
ParamUtil::copyObj2Array($v_param, $this, "title");
ParamUtil::copyObj2Array($v_param, $this, "author");
ParamUtil::copyObj2Array($v_param, $this, "publish_time");
ParamUtil::copyObj2ArrayNullField($v_param, $this, "images");
ParamUtil::copyObj2Array($v_param, $this, "content");
ParamUtil::copyObj2Array($v_param, $this, "scope");
ParamUtil::copyObj2Array($v_param, $this, "delete_flg");
......
<?php
/**
* FamilyEventMemberDat Entity
* $Id: FamilyEventMemberDat.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: FamilyEventMemberDat.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* GovernmentMst Entity
* $Id: GovernmentMst.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: GovernmentMst.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* GovernmentQrDat Entity
* $Id: GovernmentQrDat.inc,v 1.1 2020/1/17 14:38:28 Exp $
* $Id: GovernmentQrDat.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* GradeMst Entity
* $Id: GradeMst.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: GradeMst.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* MediaTagDat Entity
* $Id: MediaTagDat.inc,v 1.1 2020/1/17 14:38:28 Exp $
* $Id: MediaTagDat.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* SchoolMst Entity
* $Id: SchoolMst.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: SchoolMst.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......@@ -121,8 +121,8 @@ class SchoolMst extends CompassDynamicData
ParamUtil::copyObj2ArrayNullField($v_param, $this, "city");
ParamUtil::copyObj2ArrayNullField($v_param, $this, "district");
ParamUtil::copyObj2ArrayNullField($v_param, $this, "street");
ParamUtil::copyObj2Array($v_param, $this, "longitude");
ParamUtil::copyObj2Array($v_param, $this, "latitude");
ParamUtil::copyObj2ArrayNullField($v_param, $this, "longitude");
ParamUtil::copyObj2ArrayNullField($v_param, $this, "latitude");
ParamUtil::copyObj2Array($v_param, $this, "delete_flg");
// 保存
......
<?php
/**
* SocialEventDat Entity
* $Id: SocialEventDat.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: SocialEventDat.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......@@ -10,6 +10,7 @@ class SocialEventDat extends CompassDynamicData
{
var $school_no;
var $class_no;
var $event_id;
var $original_source;
var $title;
var $author;
......@@ -30,6 +31,7 @@ class SocialEventDat extends CompassDynamicData
$this->school_no = $record["school_no"];
$this->class_no = $record["class_no"];
$this->event_id = $record["event_id"];
$this->original_source = $record["original_source"];
$this->title = $record["title"];
$this->author = $record["author"];
......@@ -102,6 +104,7 @@ class SocialEventDat extends CompassDynamicData
ParamUtil::copyObj2Array($v_param, $this, "school_no");
ParamUtil::copyObj2Array($v_param, $this, "class_no");
ParamUtil::copyObj2Array($v_param, $this, "event_id");
ParamUtil::copyObj2Array($v_param, $this, "original_source");
ParamUtil::copyObj2Array($v_param, $this, "title");
ParamUtil::copyObj2Array($v_param, $this, "author");
......
<?php
/**
* SocialEventMemberDat Entity
* $Id: SocialEventMemberDat.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: SocialEventMemberDat.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* SystemConstantDat Entity
* $Id: SystemConstantDat.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: SystemConstantDat.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* UserCertificateDat Entity
* $Id: UserCertificateDat.inc,v 1.1 2020/1/17 14:38:28 Exp $
* $Id: UserCertificateDat.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* UserMediaDat Entity
* $Id: UserMediaDat.inc,v 1.1 2020/1/17 14:38:28 Exp $
* $Id: UserMediaDat.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* UserMst Entity
* $Id: UserMst.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: UserMst.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
*/
class UserMst extends CompassDynamicData
{
var $school_id;
var $class_id;
var $name;
var $tel_no;
var $school_no;
var $class_no;
var $original_source;
var $openid;
var $unionid;
var $status;
var $name;
var $mobile;
var $account_id;
var $child_age;
var $role;
var $point;
var $longitude;
var $latitude;
var $organization_submit_date;
......@@ -44,16 +44,16 @@ class UserMst extends CompassDynamicData
{
parent::constructor($record);
$this->school_id = $record["school_id"];
$this->class_id = $record["class_id"];
$this->name = $record["name"];
$this->tel_no = $record["tel_no"];
$this->school_no = $record["school_no"];
$this->class_no = $record["class_no"];
$this->original_source = $record["original_source"];
$this->openid = $record["openid"];
$this->unionid = $record["unionid"];
$this->status = $record["status"];
$this->name = $record["name"];
$this->mobile = $record["mobile"];
$this->account_id = $record["account_id"];
$this->child_age = $record["child_age"];
$this->role = $record["role"];
$this->point = $record["point"];
$this->longitude = $record["longitude"];
$this->latitude = $record["latitude"];
$this->organization_submit_date = $record["organization_submit_date"];
......@@ -132,16 +132,16 @@ class UserMst extends CompassDynamicData
{
$v_param = array();
ParamUtil::copyObj2Array($v_param, $this, "school_id");
ParamUtil::copyObj2Array($v_param, $this, "class_id");
ParamUtil::copyObj2Array($v_param, $this, "name");
ParamUtil::copyObj2Array($v_param, $this, "tel_no");
ParamUtil::copyObj2Array($v_param, $this, "school_no");
ParamUtil::copyObj2Array($v_param, $this, "class_no");
ParamUtil::copyObj2Array($v_param, $this, "original_source");
ParamUtil::copyObj2Array($v_param, $this, "openid");
ParamUtil::copyObj2Array($v_param, $this, "unionid");
ParamUtil::copyObj2Array($v_param, $this, "status");
ParamUtil::copyObj2ArrayNullField($v_param, $this, "name");
ParamUtil::copyObj2ArrayNullField($v_param, $this, "mobile");
ParamUtil::copyObj2Array($v_param, $this, "account_id");
ParamUtil::copyObj2ArrayNullField($v_param, $this, "child_age");
ParamUtil::copyObj2Array($v_param, $this, "child_age");
ParamUtil::copyObj2Array($v_param, $this, "role");
ParamUtil::copyObj2Array($v_param, $this, "point");
ParamUtil::copyObj2Array($v_param, $this, "longitude");
ParamUtil::copyObj2Array($v_param, $this, "latitude");
ParamUtil::copyObj2ArrayNullField($v_param, $this, "organization_submit_date");
......
<?php
/**
* UserPointLog Entity
* $Id: UserPointLog.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: UserPointLog.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* VolunteerEventDat Entity
* $Id: VolunteerEventDat.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: VolunteerEventDat.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
<?php
/**
* VolunteerEventMemberDat Entity
* $Id: VolunteerEventMemberDat.inc,v 1.1 2020/1/16 11:09:00 Exp $
* $Id: VolunteerEventMemberDat.inc,v 1.1 2020/2/13 11:17:48 Exp $
* @author lixq
* @package jp.compass.entity
* @access public
......
......@@ -96,17 +96,5 @@ class AccountRole
return null;
}
/**
*
* @return AccountRole
*/
public static function getByTitle($title) {
$list = AccountRole::getList();
foreach ($list as $tmp) {
if ($tmp->title == $title) {
return $tmp;
}
}
return null;
}
}
\ No newline at end of file
<?php
/**
* 用户角色
* $Id$
* @author huangliang
* @package cn.compass.entity.definition
*/
class CourseParentCategory
{
public $id;
public $title;
public $subCategorys;
function __construct($record) {
$this->id = $record["id"];
$this->title = $record["title"];
}
/**
*
* @return array CourseParentCategory
*/
public static function getList() {
static $result;
if ((!is_array($result)) || (count($result) < 1)) {
$data = array();
$tmp = array("id"=>1, "title"=>"科学课堂");
array_push($data, $tmp);
$tmp = array("id"=>2, "title"=>"专题课堂");
array_push($data, $tmp);
$result = array();
foreach ($data as $row) {
$tmp2 = new CourseParentCategory($row);
array_push($result, $tmp2);
}
}
return $result;
}
/**
*
* @return CourseParentCategory
*/
public static function getById($id) {
$list = CourseParentCategory::getList();
foreach ($list as $tmp) {
if ($tmp->id == $id) {
return $tmp;
}
}
return null;
}
/**
*
* @return CourseParentCategory
*/
public static function getTitleById($id) {
$list = CourseParentCategory::getList();
foreach ($list as $tmp) {
if ($tmp->id == $id) {
return $tmp->title;
}
}
return null;
}
}
\ No newline at end of file
......@@ -29,7 +29,7 @@ class EventScope
$tmp = array("id"=>1, "title"=>"全部对象");
array_push($data, $tmp);
$tmp = array("id"=>2, "title"=>"校(园)内");
$tmp = array("id"=>2, "title"=>"校内");
array_push($data, $tmp);
$tmp = array("id"=>3, "title"=>"社会机构");
......
......@@ -2,7 +2,7 @@
/**
* 系统流水记录表
* $Id: PointActionType.inc 81583 2015-04-02 08:59:46Z wanggb $
* @author 用户积分
* @author wanggb
* @access public
* @package jp.fishow.entity.definition
*/
......@@ -41,12 +41,19 @@ class PointActionType {
$data = array();
$tmp = array("id"=>1, "title"=>"用户注册");
array_push($data, $tmp);
$tmp = array("id"=>2, "title"=>"社会实践获得");
$tmp = array("id"=>2, "title"=>"签到奖励");
array_push($data, $tmp);
$tmp = array("id"=>3, "title"=>"亲子活动获得");
$tmp = array("id"=>3, "title"=>"邀请好友奖励");
array_push($data, $tmp);
$tmp = array("id"=>4, "title"=>"兑换商品");
$tmp = array("id"=>4, "title"=>"购买课程奖励");
array_push($data, $tmp);
$tmp = array("id"=>5, "title"=>"兑换代金券");
array_push($data, $tmp);
$tmp = array("id"=>6, "title"=>"兑换商品");
array_push($data, $tmp);
$tmp = array("id"=>7, "title"=>"系统赠送[抽奖等]");
array_push($data, $tmp);
$result = array();
foreach ($data as $row) {
$tmp2 = new PointActionType($row);
......
......@@ -26,12 +26,19 @@ class SchoolType
$data = array();
$tmp = array("id"=>1, "title"=>"幼儿");
$tmp = array("id"=>1, "title"=>"幼儿");
array_push($data, $tmp);
$tmp = array("id"=>2, "title"=>"小初高");
$tmp = array("id"=>2, "title"=>"小");
array_push($data, $tmp);
$tmp = array("id"=>3, "title"=>"初中");
array_push($data, $tmp);
$tmp = array("id"=>4, "title"=>"高中");
array_push($data, $tmp);
$result = array();
foreach ($data as $row) {
$tmp2 = new SchoolType($row);
......
......@@ -26,26 +26,16 @@ class UserRole
$data = array();
$tmp = array("id"=>1, "title"=>"社会人士");
$tmp = array("id"=>1, "title"=>"校长");
array_push($data, $tmp);
$tmp = array("id"=>2, "title"=>"机构用户");
$tmp = array("id"=>2, "title"=>"教师");
array_push($data, $tmp);
//家园用户:园长/教师/家长/学生
$tmp = array("id"=>3, "title"=>"家校用户");
array_push($data, $tmp);
//家园用户:校长/教师/家长/学生
$tmp = array("id"=>4, "title"=>"家园用户");
array_push($data, $tmp);
$tmp = array("id"=>5, "title"=>"省厅领导");
array_push($data, $tmp);
$tmp = array("id"=>6, "title"=>"市局领导");
array_push($data, $tmp);
$tmp = array("id"=>7, "title"=>"县局领导");
array_push($data, $tmp);
$tmp = array("id"=>8, "title"=>"高职用户");
$tmp = array("id"=>3, "title"=>"学生");
array_push($data, $tmp);
$result = array();
foreach ($data as $row) {
$tmp2 = new UserRole($row);
......
<?php
use OSS\OssClient;
USE OSS\Core\OssException;
require_once (dirname ( __FILE__ ) . '/../../extralib/autoload.php');
Class AliUploadHandler{
var $Access_Key ;
var $Secret_Key ;
var $bucket ;
var $endpoint ;
public function __construct(){
$this->init();
}
public function init(){
$this->Access_Key = OSS_ACCESS_KEY;
$this->Secret_Key = OSS_ACCESS_SECRET;
$this->bucket = OSS_BUCKET;
$this->endpoint = OSS_END_POINT;
}
/**
* 上传接口
* @Author
* @DateTime 2017-03-08
* @param string $bucket bucket name
* @param string $object object name
* @param string $file local file path
* @param array $options
* @throws OssException [文件类型]
*/
public function uploadImg($dst,$src){
//获取对象
$auth = new OssClient($this->Access_Key,$this->Secret_Key,$this->endpoint);
try {
//上传图片
$result = $auth->uploadFile($this->bucket,$dst,$src);
return $result['info']['url'];
} catch (OssException $e) {
ErrorLogger::doOutput(__FUNCTION__ . "uploadImg: FAILED\n");
ErrorLogger::doOutput($e->getMessage() . "\n");
return $e->getMessage();
}
ErrorLogger::doOutput(__FUNCTION__ . "uploadImg: OK" . "\n");
}
/**
* @Author
* @DateTime 2018-03-08
* @return [type] [description]
*/
public function uploadVideo($dst,$src){
$ossClient = new OssClient($this->Access_Key,$this->Secret_Key,$this->endpoint);
try{
$result = $ossClient->multiuploadFile($this->bucket,$dst,$src);
return $result['info']['url'];
} catch(OssException $e) {
ErrorLogger::doOutput(__FUNCTION__ . "uploadVideo: FAILED\n");
ErrorLogger::doOutput($e->getMessage() . "\n");
return;
}
ErrorLogger::doOutput(__FUNCTION__ . "uploadVideo: OK" . "\n");
}
/**
* 删除文件
*
* @param $srcFile 文件路径
*
*/
public function delete($desPath)
{
$ossClient = new OssClient($this->Access_Key,$this->Secret_Key,$this->endpoint);
try{
$ossClient->deleteObject($this->bucket, $desPath);
} catch(OssException $e) {
ErrorLogger::doOutput(__FUNCTION__ . "delete: FAILED\n");
ErrorLogger::doOutput($e->getMessage() . "\n");
return;
}
ErrorLogger::doOutput(__FUNCTION__ . "delete: OK" . "\n");
}
}
\ No newline at end of file
......@@ -7,6 +7,25 @@
* @package jp.fishow.handler
*/
class CompassHandler{
/**
* API请求时发生错误
*/
public static function responseApiNg($error_code = 0, $error_message = null) {
$arr = ["status"=>"NG", "error_code"=>$error_code, "error_message"=>$error_message];
echo json_encode($arr);
exit;
}
/**
* API请求时返回正常结果
*/
public static function responseApiOk($result = []) {
$arr = ["status"=>"OK", "data"=>$result];
echo json_encode($arr);
exit;
}
/**
* 图片显示URL取得
* child_path(不包含"/")
......@@ -416,6 +435,95 @@ class CompassHandler{
}
return $return;
}
/**
* 根据条件查询government list
*/
public static function getGovernmentlList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select * from government_mst";
$sql_where =" where true";
$sql_where.=" order by ".$order_key.' '.$sort.' limit '.$limit.' OFFSET '.$offset;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
$return = [];
if(count($result) > 0){
foreach ($result as $tmp){
array_push($return, new GovernmentMst($tmp));
}
}
return $return;
}
/**
* 根据条件查询school list
*/
public static function getSchoollList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select * from school_mst";
$sql_where =" where true";
$sql_where.=" order by ".$order_key.' '.$sort.' limit '.$limit.' OFFSET '.$offset;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
$return = [];
if(count($result) > 0){
foreach ($result as $tmp){
array_push($return, new SchoolMst($tmp));
}
}
return $return;
}
/**
* 根据条件查询班级 list
*/
public static function getClassList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select cm.*,gm.title as grade_title from class_mst cm left join grade_mst gm on cm.grade_id=gm.id";
$sql_where =" where cm.delete_flg=false";
if (isset($param["school_id"]) && !empty($param["school_id"])) {
$sql_where .= " and cm.school_id=".$param["school_id"];
}
$sql_where.=" order by ".$order_key.' '.$sort;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result;
}
/**
* 根据条件查询合集视频 list
*/
public static function getCourseList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select cm.*,gm.title as grade_title from course_mst cm left join grade_mst gm on cm.grade_id=gm.id";
$sql_where =" where cm.delete_flg=false";
if (isset($param["school_id"]) && !empty($param["school_id"])) {
$sql_where .= " and cm.school_id=".$param["school_id"];
}
$sql_where.=" order by ".$order_key.' '.$sort;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
return $result;
}
/**
* 根据条件查询certificate list
*/
public static function getCertificatelList($param, $order_key = "id", $sort = "DESC", $offset = null, $limit = null) {
$from = "select * from certificate_mst";
$sql_where =" where true";
$sql_where.=" order by ".$order_key.' '.$sort.' limit '.$limit.' OFFSET '.$offset;
// 検索を行う
$db = &CompassDBManager::getInstance();
$result = $db->executeQuery($from.$sql_where);
$return = [];
if(count($result) > 0){
foreach ($result as $tmp){
array_push($return, new CertificateMst($tmp));
}
}
return $return;
}
}
?>
\ No newline at end of file
<?php
namespace OSS\Core;
/**
* Class OssException
*
* This is the class that OSSClient is expected to thrown, which the caller needs to handle properly.
* It has the OSS specific errors which is useful for troubleshooting.
*
* @package OSS\Core
*/
class OssException extends \Exception
{
private $details = array();
function __construct($details)
{
if (is_array($details)) {
$message = $details['code'] . ': ' . $details['message']
. ' RequestId: ' . $details['request-id'];
parent::__construct($message);
$this->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'] : '';
}
}
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.
<?php
namespace OSS\Http;
class RequestCore_Exception extends \Exception
{
}
\ No newline at end of file
<?php
namespace OSS\Http;
/**
* Container for all response-related methods.
*/
class ResponseCore
{
/**
* Store the HTTP header information.
*/
public $header;
/**
* Store the SimpleXML response.
*/
public $body;
/**
* Store the HTTP response code.
*/
public $status;
/**
* Construct a new instance of this class.
*
* @param array $header (Required) Associative array of HTTP headers (typically returned by <RequestCore::get_response_header()>).
* @param string $body (Required) XML-formatted response from OSS.
* @param integer $status (Optional) HTTP response status code from the request.
* @return Mixed Contains an <php:array> `header` property (HTTP headers as an associative array), a <php:SimpleXMLElement> or <php:string> `body` property, and an <php:integer> `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 <php:integer> for a single acceptable value, or an <php:array> 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
<?php
namespace OSS\Model;
/**
* Bucket information class. This is the type of element in BucketListInfo's
*
* Class BucketInfo
* @package OSS\Model
*/
class BucketInfo
{
/**
* BucketInfo constructor.
*
* @param string $location
* @param string $name
* @param string $createDate
*/
public function __construct($location, $name, $createDate)
{
$this->location = $location;
$this->name = $name;
$this->createDate = $createDate;
}
/**
* 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;
}
/**
* bucket region
*
* @var string
*/
private $location;
/**
* bucket name
*
* @var string
*/
private $name;
/**
* bucket creation time
*
* @var string
*/
private $createDate;
}
\ No newline at end of file
<?php
namespace OSS\Model;
/**
* Class BucketListInfo
*
* It's the type of return value of ListBuckets.
*
* @package OSS\Model
*/
class BucketListInfo
{
/**
* BucketListInfo constructor.
* @param array $bucketList
*/
public function __construct(array $bucketList)
{
$this->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
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class CnameConfig
* @package OSS\Model
*
* TODO: fix link
* @link http://help.aliyun.com/document_detail/oss/api-reference/cors/PutBucketcors.html
*/
class CnameConfig implements XmlConfig
{
public function __construct()
{
$this->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 version="1.0" encoding="utf-8"?>
<BucketCnameConfiguration>
</BucketCnameConfiguration>
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
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class CorsConfig
* @package OSS\Model
*
* @link http://help.aliyun.com/document_detail/oss/api-reference/cors/PutBucketcors.html
*/
class CorsConfig implements XmlConfig
{
/**
* CorsConfig constructor.
*/
public function __construct()
{
$this->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;
}
/**
* Parse CorsConfig from the xml.
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
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);
}
return;
}
/**
* Serialize the object into xml string.
*
* @return string
*/
public function serializeToXml()
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><CORSConfiguration></CORSConfiguration>');
foreach ($this->rules as $rule) {
$xmlRule = $xml->addChild('CORSRule');
$rule->appendToXml($xmlRule);
}
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();
}
\ No newline at end of file
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class CorsRule
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/cors/PutBucketcors.html
*/
class CorsRule
{
/**
* Add an allowedOrigin rule
*
* @param string $allowedOrigin
*/
public function addAllowedOrigin($allowedOrigin)
{
if (!empty($allowedOrigin)) {
$this->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
<?php
namespace OSS\Model;
/**
* Class GetLiveChannelHistory
* @package OSS\Model
*/
class GetLiveChannelHistory implements XmlConfig
{
public function getLiveRecordList()
{
return $this->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();
}
<?php
namespace OSS\Model;
/**
* Class GetLiveChannelInfo
* @package OSS\Model
*/
class GetLiveChannelInfo implements XmlConfig
{
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);
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;
}
<?php
namespace OSS\Model;
/**
* Class GetLiveChannelStatus
* @package OSS\Model
*/
class GetLiveChannelStatus implements XmlConfig
{
public function getStatus()
{
return $this->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;
}
<?php
namespace OSS\Model;
/**
* Class LifecycleAction
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLifecycle.html
*/
class LifecycleAction
{
/**
* LifecycleAction constructor.
* @param string $action
* @param string $timeSpec
* @param string $timeValue
*/
public function __construct($action, $timeSpec, $timeValue)
{
$this->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
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class BucketLifecycleConfig
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLifecycle.html
*/
class LifecycleConfig implements XmlConfig
{
/**
* Parse the xml into this object.
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
$this->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('<?xml version="1.0" encoding="utf-8"?><LifecycleConfiguration></LifecycleConfiguration>');
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;
}
<?php
namespace OSS\Model;
/**
* Class LifecycleRule
* @package OSS\Model
*
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLifecycle.html
*/
class LifecycleRule
{
/**
* Get Id
*
* @return string
*/
public function getId()
{
return $this->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
<?php
namespace OSS\Model;
/**
* Class ListMultipartUploadInfo
* @package OSS\Model
*
* @link http://help.aliyun.com/document_detail/oss/api-reference/multipart-upload/ListMultipartUploads.html
*/
class ListMultipartUploadInfo
{
/**
* ListMultipartUploadInfo constructor.
*
* @param string $bucket
* @param string $keyMarker
* @param string $uploadIdMarker
* @param string $nextKeyMarker
* @param string $nextUploadIdMarker
* @param string $delimiter
* @param string $prefix
* @param int $maxUploads
* @param string $isTruncated
* @param array $uploads
*/
public function __construct($bucket, $keyMarker, $uploadIdMarker, $nextKeyMarker, $nextUploadIdMarker, $delimiter, $prefix, $maxUploads, $isTruncated, array $uploads)
{
$this->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
<?php
namespace OSS\Model;
/**
* Class ListPartsInfo
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/multipart-upload/ListParts.html
*/
class ListPartsInfo
{
/**
* ListPartsInfo constructor.
* @param string $bucket
* @param string $key
* @param string $uploadId
* @param int $nextPartNumberMarker
* @param int $maxParts
* @param string $isTruncated
* @param array $listPart
*/
public function __construct($bucket, $key, $uploadId, $nextPartNumberMarker, $maxParts, $isTruncated, array $listPart)
{
$this->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
<?php
namespace OSS\Model;
/**
* Class LiveChannelConfig
* @package OSS\Model
*/
class LiveChannelConfig implements XmlConfig
{
public function __construct($option = array())
{
if (isset($option['description'])) {
$this->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 version="1.0" encoding="utf-8"?>
<LiveChannelConfiguration>
</LiveChannelConfiguration>
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";
}
<?php
namespace OSS\Model;
/**
* Class LiveChannelHistory
* @package OSS\Model
*
*/
class LiveChannelHistory implements XmlConfig
{
public function __construct()
{
}
public function getStartTime()
{
return $this->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;
}
<?php
namespace OSS\Model;
/**
* Class LiveChannelInfo
* @package OSS\Model
*
*/
class LiveChannelInfo implements XmlConfig
{
public function __construct($name = null, $description = null)
{
$this->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;
}
<?php
namespace OSS\Model;
/**
* Class LiveChannelListInfo
*
* The data returned by ListBucketLiveChannels
*
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html
*/
class LiveChannelListInfo implements XmlConfig
{
/**
* @return string
*/
public function getBucketName()
{
return $this->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();
}
<?php
namespace OSS\Model;
/**
* Class LoggingConfig
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLogging.html
*/
class LoggingConfig implements XmlConfig
{
/**
* LoggingConfig constructor.
* @param null $targetBucket
* @param null $targetPrefix
*/
public function __construct($targetBucket = null, $targetPrefix = null)
{
$this->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('<?xml version="1.0" encoding="utf-8"?><BucketLoggingStatus></BucketLoggingStatus>');
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
<?php
namespace OSS\Model;
/**
*
* Class ObjectInfo
*
* The element type of ObjectListInfo, which is the return value type of listObjects
*
* The return value of listObjects includes two arrays
* One is the returned ObjectListInfo, which is similar to a file list in a file system.
* The other is the returned prefix list, which is similar to a folder list in a file system.
*
* @package OSS\Model
*/
class ObjectInfo
{
/**
* ObjectInfo constructor.
*
* @param string $key
* @param string $lastModified
* @param string $eTag
* @param string $type
* @param int $size
* @param string $storageClass
*/
public function __construct($key, $lastModified, $eTag, $type, $size, $storageClass)
{
$this->key = $key;
$this->lastModified = $lastModified;
$this->eTag = $eTag;
$this->type = $type;
$this->size = $size;
$this->storageClass = $storageClass;
}
/**
* @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;
}
/**
* @return int
*/
public function getSize()
{
return $this->size;
}
/**
* @return string
*/
public function getStorageClass()
{
return $this->storageClass;
}
private $key = "";
private $lastModified = "";
private $eTag = "";
private $type = "";
private $size = 0;
private $storageClass = "";
}
\ No newline at end of file
<?php
namespace OSS\Model;
/**
* Class ObjectListInfo
*
* The class of return value of ListObjects
*
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html
*/
class ObjectListInfo
{
/**
* ObjectListInfo constructor.
*
* @param string $bucketName
* @param string $prefix
* @param string $marker
* @param string $nextMarker
* @param string $maxKeys
* @param string $delimiter
* @param null $isTruncated
* @param array $objectList
* @param array $prefixList
*/
public function __construct($bucketName, $prefix, $marker, $nextMarker, $maxKeys, $delimiter, $isTruncated, array $objectList, array $prefixList)
{
$this->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
<?php
namespace OSS\Model;
/**
* Class PartInfo
* @package OSS\Model
*/
class PartInfo
{
/**
* PartInfo constructor.
*
* @param int $partNumber
* @param string $lastModified
* @param string $eTag
* @param int $size
*/
public function __construct($partNumber, $lastModified, $eTag, $size)
{
$this->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;
}
/**
* @return int
*/
public function getSize()
{
return $this->size;
}
private $partNumber = 0;
private $lastModified = "";
private $eTag = "";
private $size = 0;
}
\ No newline at end of file
<?php
namespace OSS\Model;
/**
* Class PrefixInfo
*
* ListObjects return Prefix list of classes
* The returned data contains two arrays
* One is to get the list of objects【Can be understood as the corresponding file system file list】
* One is to get Prefix list【Can be understood as the corresponding file system directory list】
*
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html
*/
class PrefixInfo
{
/**
* PrefixInfo constructor.
* @param string $prefix
*/
public function __construct($prefix)
{
$this->prefix = $prefix;
}
/**
* @return string
*/
public function getPrefix()
{
return $this->prefix;
}
private $prefix;
}
\ No newline at end of file
<?php
namespace OSS\Model;
/**
* Class RefererConfig
*
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketReferer.html
*/
class RefererConfig implements XmlConfig
{
/**
* @param string $strXml
* @return null
*/
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (!isset($xml->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('<?xml version="1.0" encoding="utf-8"?><RefererConfiguration></RefererConfiguration>');
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
<?php
namespace OSS\Model;
/**
* Class StorageCapacityConfig
*
* @package OSS\Model
* @link http://docs.alibaba-inc.com/pages/viewpage.action?pageId=271614763
*/
class StorageCapacityConfig implements XmlConfig
{
/**
* StorageCapacityConfig constructor.
*
* @param int $storageCapacity
*/
public function __construct($storageCapacity)
{
$this->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 version="1.0" encoding="utf-8"?><BucketUserQos></BucketUserQos>');
$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
<?php
namespace OSS\Model;
/**
* Class UploadInfo
*
* The return value of ListMultipartUpload
*
* @package OSS\Model
*/
class UploadInfo
{
/**
* UploadInfo constructor.
*
* @param string $key
* @param string $uploadId
* @param string $initiated
*/
public function __construct($key, $uploadId, $initiated)
{
$this->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
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class WebsiteConfig
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketWebsite.html
*/
class WebsiteConfig implements XmlConfig
{
/**
* WebsiteConfig constructor.
* @param string $indexDocument
* @param string $errorDocument
*/
public function __construct($indexDocument = "", $errorDocument = "")
{
$this->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('<?xml version="1.0" encoding="utf-8"?><WebsiteConfiguration></WebsiteConfiguration>');
$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
<?php
namespace OSS\Model;
/**
* Interface XmlConfig
* @package OSS\Model
*/
interface XmlConfig
{
/**
* Interface method: Parse the object from the xml.
*
* @param string $strXml
* @return null
*/
public function parseFromXml($strXml);
/**
* Interface method: Serialize the object into xml.
*
* @return string
*/
public function serializeToXml();
}
This source diff could not be displayed because it is too large. You can view the blob instead.
<?php
namespace OSS\Result;
use OSS\Core\OssException;
/**
* The type of the return value of getBucketAcl, it wraps the data parsed from xml.
*
* @package OSS\Result
*/
class AclResult extends Result
{
/**
* @return string
* @throws OssException
*/
protected function parseDataFromResponse()
{
$content = $this->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
<?php
namespace OSS\Result;
use OSS\Core\OssException;
/**
* Class AppendResult
* @package OSS\Result
*/
class AppendResult extends Result
{
/**
* Get the value of next-append-position from append's response headers
*
* @return int
* @throws OssException
*/
protected function parseDataFromResponse()
{
$header = $this->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
<?php
namespace OSS\Result;
/**
* Class BodyResult
* @package OSS\Result
*/
class BodyResult extends Result
{
/**
* @return string
*/
protected function parseDataFromResponse()
{
return empty($this->rawResponse->body) ? "" : $this->rawResponse->body;
}
}
\ No newline at end of file
<?php
namespace OSS\Result;
/**
* Class CallbackResult
* @package OSS\Result
*/
class CallbackResult extends PutSetDeleteResult
{
protected function isResponseOk()
{
$status = $this->rawResponse->status;
if ((int)(intval($status) / 100) == 2 && (int)(intval($status)) !== 203) {
return true;
}
return false;
}
}
<?php
namespace OSS\Result;
/**
* Class CopyObjectResult
* @package OSS\Result
*/
class CopyObjectResult extends Result
{
/**
* @return array()
*/
protected function parseDataFromResponse()
{
$body = $this->rawResponse->body;
$xml = simplexml_load_string($body);
$result = array();
if (isset($xml->LastModified)) {
$result[] = $xml->LastModified;
}
if (isset($xml->ETag)) {
$result[] = $xml->ETag;
}
return $result;
}
}
<?php
namespace OSS\Result;
/**
* Class DeleteObjectsResult
* @package OSS\Result
*/
class DeleteObjectsResult extends Result
{
/**
* @return array()
*/
protected function parseDataFromResponse()
{
$body = $this->rawResponse->body;
$xml = simplexml_load_string($body);
$objects = array();
if (isset($xml->Deleted)) {
foreach($xml->Deleted as $deleteKey)
$objects[] = $deleteKey->Key;
}
return $objects;
}
}
<?php
namespace OSS\Result;
/**
* Class ExistResult checks if bucket or object exists, according to the http status in response headers.
* @package OSS\Result
*/
class ExistResult extends Result
{
/**
* @return bool
*/
protected function parseDataFromResponse()
{
return intval($this->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
<?php
namespace OSS\Result;
use OSS\Model\CnameConfig;
class GetCnameResult extends Result
{
/**
* @return CnameConfig
*/
protected function parseDataFromResponse()
{
$content = $this->rawResponse->body;
$config = new CnameConfig();
$config->parseFromXml($content);
return $config;
}
}
\ No newline at end of file
<?php
namespace OSS\Result;
use OSS\Model\CorsConfig;
class GetCorsResult extends Result
{
/**
* @return CorsConfig
*/
protected function parseDataFromResponse()
{
$content = $this->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
<?php
namespace OSS\Result;
use OSS\Model\LifecycleConfig;
/**
* Class GetLifecycleResult
* @package OSS\Result
*/
class GetLifecycleResult extends Result
{
/**
* Parse the LifecycleConfig object from the response
*
* @return LifecycleConfig
*/
protected function parseDataFromResponse()
{
$content = $this->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;
}
}
<?php
namespace OSS\Result;
use OSS\Model\GetLiveChannelHistory;
class GetLiveChannelHistoryResult extends Result
{
/**
* @return
*/
protected function parseDataFromResponse()
{
$content = $this->rawResponse->body;
$channelList = new GetLiveChannelHistory();
$channelList->parseFromXml($content);
return $channelList;
}
}
<?php
namespace OSS\Result;
use OSS\Model\GetLiveChannelInfo;
class GetLiveChannelInfoResult extends Result
{
/**
* @return
*/
protected function parseDataFromResponse()
{
$content = $this->rawResponse->body;
$channelList = new GetLiveChannelInfo();
$channelList->parseFromXml($content);
return $channelList;
}
}
<?php
namespace OSS\Result;
use OSS\Model\GetLiveChannelStatus;
class GetLiveChannelStatusResult extends Result
{
/**
* @return
*/
protected function parseDataFromResponse()
{
$content = $this->rawResponse->body;
$channelList = new GetLiveChannelStatus();
$channelList->parseFromXml($content);
return $channelList;
}
}
<?php
namespace OSS\Result;
use OSS\Core\OssException;
/**
* Class GetLocationResult getBucketLocation interface returns the result class, encapsulated
* The returned xml data is parsed
*
* @package OSS\Result
*/
class GetLocationResult extends Result
{
/**
* Parse data from response
*
* @return string
* @throws OssException
*/
protected function parseDataFromResponse()
{
$content = $this->rawResponse->body;
if (empty($content)) {
throw new OssException("body is null");
}
$xml = simplexml_load_string($content);
return $xml;
}
}
\ No newline at end of file
<?php
namespace OSS\Result;
use OSS\Model\LoggingConfig;
/**
* Class GetLoggingResult
* @package OSS\Result
*/
class GetLoggingResult extends Result
{
/**
* Parse LoggingConfig data
*
* @return LoggingConfig
*/
protected function parseDataFromResponse()
{
$content = $this->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
<?php
namespace OSS\Result;
use OSS\Model\RefererConfig;
/**
* Class GetRefererResult
* @package OSS\Result
*/
class GetRefererResult extends Result
{
/**
* Parse RefererConfig data
*
* @return RefererConfig
*/
protected function parseDataFromResponse()
{
$content = $this->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
<?php
namespace OSS\Result;
use OSS\Core\OssException;
/**
* Class AclResult GetBucketAcl interface returns the result class, encapsulated
* The returned xml data is parsed
*
* @package OSS\Result
*/
class GetStorageCapacityResult extends Result
{
/**
* Parse data from response
*
* @return string
* @throws OssException
*/
protected function parseDataFromResponse()
{
$content = $this->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
<?php
namespace OSS\Result;
use OSS\Model\WebsiteConfig;
/**
* Class GetWebsiteResult
* @package OSS\Result
*/
class GetWebsiteResult extends Result
{
/**
* Parse WebsiteConfig data
*
* @return WebsiteConfig
*/
protected function parseDataFromResponse()
{
$content = $this->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
<?php
namespace OSS\Result;
/**
* Class HeaderResult
* @package OSS\Result
* @link https://docs.aliyun.com/?spm=5176.383663.13.7.HgUIqL#/pub/oss/api-reference/object&GetObjectMeta
*/
class HeaderResult extends Result
{
/**
* The returned ResponseCore header is used as the return data
*
* @return array
*/
protected function parseDataFromResponse()
{
return empty($this->rawResponse->header) ? array() : $this->rawResponse->header;
}
}
\ No newline at end of file
<?php
namespace OSS\Result;
use OSS\Core\OssException;
/**
* Class initiateMultipartUploadResult
* @package OSS\Result
*/
class InitiateMultipartUploadResult extends Result
{
/**
* Get uploadId in result and return
*
* @throws OssException
* @return string
*/
protected function parseDataFromResponse()
{
$content = $this->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
<?php
namespace OSS\Result;
use OSS\Model\BucketInfo;
use OSS\Model\BucketListInfo;
/**
* Class ListBucketsResult
*
* @package OSS\Result
*/
class ListBucketsResult extends Result
{
/**
* @return BucketListInfo
*/
protected function parseDataFromResponse()
{
$bucketList = array();
$content = $this->rawResponse->body;
$xml = new \SimpleXMLElement($content);
if (isset($xml->Buckets) && isset($xml->Buckets->Bucket)) {
foreach ($xml->Buckets->Bucket as $bucket) {
$bucketInfo = new BucketInfo(strval($bucket->Location),
strval($bucket->Name),
strval($bucket->CreationDate));
$bucketList[] = $bucketInfo;
}
}
return new BucketListInfo($bucketList);
}
}
\ No newline at end of file
<?php
namespace OSS\Result;
use OSS\Model\LiveChannelListInfo;
class ListLiveChannelResult extends Result
{
protected function parseDataFromResponse()
{
$content = $this->rawResponse->body;
$channelList = new LiveChannelListInfo();
$channelList->parseFromXml($content);
return $channelList;
}
}
<?php
namespace OSS\Result;
use OSS\Core\OssUtil;
use OSS\Model\ListMultipartUploadInfo;
use OSS\Model\UploadInfo;
/**
* Class ListMultipartUploadResult
* @package OSS\Result
*/
class ListMultipartUploadResult extends Result
{
/**
* Parse the return data from the ListMultipartUpload interface
*
* @return ListMultipartUploadInfo
*/
protected function parseDataFromResponse()
{
$content = $this->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
<?php
namespace OSS\Result;
use OSS\Core\OssUtil;
use OSS\Model\ObjectInfo;
use OSS\Model\ObjectListInfo;
use OSS\Model\PrefixInfo;
/**
* Class ListObjectsResult
* @package OSS\Result
*/
class ListObjectsResult extends Result
{
/**
* Parse the xml data returned by the ListObjects interface
*
* return ObjectListInfo
*/
protected function parseDataFromResponse()
{
$xml = new \SimpleXMLElement($this->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) ? intval($content->Size) : 0;
$storageClass = isset($content->StorageClass) ? strval($content->StorageClass) : "";
$retList[] = new ObjectInfo($key, $lastModified, $eTag, $type, $size, $storageClass);
}
}
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
<?php
namespace OSS\Result;
use OSS\Model\ListPartsInfo;
use OSS\Model\PartInfo;
/**
* Class ListPartsResult
* @package OSS\Result
*/
class ListPartsResult extends Result
{
/**
* Parse the xml data returned by the ListParts interface
*
* @return ListPartsInfo
*/
protected function parseDataFromResponse()
{
$content = $this->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) ? intval($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
<?php
namespace OSS\Result;
use OSS\Model\LiveChannelInfo;
class PutLiveChannelResult extends Result
{
protected function parseDataFromResponse()
{
$content = $this->rawResponse->body;
$channel = new LiveChannelInfo();
$channel->parseFromXml($content);
return $channel;
}
}
<?php
namespace OSS\Result;
/**
* Class PutSetDeleteResult
* @package OSS\Result
*/
class PutSetDeleteResult extends Result
{
/**
* @return array()
*/
protected function parseDataFromResponse()
{
$body = array('body' => $this->rawResponse->body);
return array_merge($this->rawResponse->header, $body);
}
}
<?php
namespace OSS\Result;
use OSS\Core\OssException;
use OSS\Http\ResponseCore;
/**
* Class Result, The result class of The operation of the base class, different requests in dealing with the return of data have different logic,
* The specific parsing logic postponed to subclass implementation
*
* @package OSS\Model
*/
abstract class Result
{
/**
* Result constructor.
* @param $response ResponseCore
* @throws OssException
*/
public function __construct($response)
{
if ($response === null) {
throw new OssException("raw response is null");
}
$this->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, '<?xml')) {
return '';
}
$xml = simplexml_load_string($body);
if (isset($xml->Message)) {
return strval($xml->Message);
}
return '';
}
/**
* Try to get the error Code from body
*
* @param $body
* @return string
*/
private function retrieveErrorCode($body)
{
if (empty($body) || false === strpos($body, '<?xml')) {
return '';
}
$xml = simplexml_load_string($body);
if (isset($xml->Code)) {
return strval($xml->Code);
}
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
<?php
namespace OSS\Result;
use OSS\Core\OssException;
use OSS\OssClient;
/**
*
* @package OSS\Result
*/
class SymlinkResult extends Result
{
/**
* @return string
* @throws OssException
*/
protected function parseDataFromResponse()
{
$this->rawResponse->header[OssClient::OSS_SYMLINK_TARGET] = rawurldecode($this->rawResponse->header[OssClient::OSS_SYMLINK_TARGET]);
return $this->rawResponse->header;
}
}
<?php
namespace OSS\Result;
use OSS\Core\OssException;
/**
* Class UploadPartResult
* @package OSS\Result
*/
class UploadPartResult extends Result
{
/**
* 结果中part的ETag
*
* @return string
* @throws OssException
*/
protected function parseDataFromResponse()
{
$header = $this->rawResponse->header;
if (isset($header["etag"])) {
return $header["etag"];
}
throw new OssException("cannot get ETag");
}
}
\ No newline at end of file
<?php
function classLoader($class)
{
$path = str_replace('\\', DIRECTORY_SEPARATOR, $class);
$file = __DIR__ . DIRECTORY_SEPARATOR . $path . '.php';
if (file_exists($file)) {
require_once $file;
}
}
spl_autoload_register('classLoader');
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment