Пример #1
0
function SaeStorageSetDomainAttr($Attr)
{
    //目前支持的Domain属性:
    //expires: 浏览器缓存超时 说明:expires 格式:[modified] TIME_DELTA,例如modified 1y或者1y,modified关键字用于指定expire时间相对于文件的修改时间。
    //默认expire时间是相对于access time。如果TIME_DELTA为负, Cache-Control header会被设置为no-cache。
    //TIME_DELTA,TIME_DELTA是一个表示时间的字符串,例如: 1y3M 48d 5s,目前支持s/m/h/d/w/M/y
    //expires_type 格式:TYPE [modified] TIME_DELTA,TYPE为文件的mimetype,例如text/html, text/plain, image/gif。多条expires-type规则之间以 , 隔开,例如:text/html 48h,image/png modified 1y
    //allowReferer: 根据Referer防盗链
    //private: 是否私有Domain
    //404Redirect: 404跳转页面,只能是本应用页面,或本应用Storage中文件。例如http://appname.sinaapp.com/404.html或http://appname-domain.stor.sinaapp.com/404.png
    //tag: Domain简介。格式:array('tag1', 'tag2')
    //示例代码:
    //$expires = '1 d';// 缓存过期设置
    //$allowReferer = array();// 防盗链设置
    //$allowReferer['hosts'][] = '*.elmerzhang.com';       // 允许访问的来源域名,千万不要带 http://。支持通配符*和?
    //$allowReferer['hosts'][] = 'elmer.sinaapp.com';
    //$allowReferer['hosts'][] = '?.elmer.sinaapp.com';
    //$allowReferer['redirect'] = 'http://elmer.sinaapp.com/'; // 盗链时跳转到的地址,仅允许跳转到本APP的页面,且不可使用独立域名。如果不设置或者设置错误,则直接拒绝访问。
    //$allowReferer = false;  // 如果要关闭一个Domain的防盗链功能,直接将allowReferer设置为false即可
    //$stor = new SaeStorage();
    //$attr = array('expires'=>$expires, 'allowReferer'=>$allowReferer);
    //$ret = $stor->setDomainAttr("test", $attr);
    //if ($ret === false) {var_dump($stor->errno(), $stor->errmsg());}
    $storage = new SaeStorage();
    $domain = Sae_Storage_Domain_Name;
    $result = $storage->setDomainAttr($domain, $Attr);
    return $result;
}