mirror of
https://github.com/typecho/plugins.git
synced 2024-12-21 20:40:08 +08:00
阿里云存储插件
This commit is contained in:
parent
5ced5651aa
commit
0896db47b4
662
AliUpload/Plugin.php
Executable file
662
AliUpload/Plugin.php
Executable file
@ -0,0 +1,662 @@
|
||||
<?php
|
||||
|
||||
if(!defined('OSS_API_PATH'))
|
||||
define('OSS_API_PATH', dirname(__FILE__));
|
||||
|
||||
//ACCESS_ID
|
||||
define('OSS_ACCESS_ID', '');
|
||||
|
||||
//ACCESS_KEY
|
||||
define('OSS_ACCESS_KEY', '');
|
||||
|
||||
//是否记录日志
|
||||
define('ALI_LOG', FALSE);
|
||||
|
||||
//自定义日志路径,如果没有设置,则使用系统默认路径,在./logs/
|
||||
define('ALI_LOG_PATH',OSS_API_PATH.'/logs/');
|
||||
|
||||
//是否显示LOG输出
|
||||
define('ALI_DISPLAY_LOG', FALSE);
|
||||
|
||||
require_once 'lib/sdk.class.php';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <a href="http://loftor.com/" target="_blank">Alioss</a>专用的文件上传插件。
|
||||
*
|
||||
* @package AliUpload
|
||||
* @author loftor
|
||||
* @version 1.0.0 Beta
|
||||
* @link http://loftor.com/
|
||||
*/
|
||||
class AliUpload_Plugin implements Typecho_Plugin_Interface
|
||||
{
|
||||
|
||||
//上传文件目录
|
||||
const UPLOAD_PATH = 'usr/uploads';
|
||||
/**
|
||||
* 激活插件方法,如果激活失败,直接抛出异常
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @throws Typecho_Plugin_Exception
|
||||
*/
|
||||
public static function activate()
|
||||
{
|
||||
Typecho_Plugin::factory('Widget_Upload')->uploadHandle = array('AliUpload_Plugin', 'uploadHandle');
|
||||
Typecho_Plugin::factory('Widget_Upload')->modifyHandle = array('AliUpload_Plugin', 'modifyHandle');
|
||||
Typecho_Plugin::factory('Widget_Upload')->deleteHandle = array('AliUpload_Plugin', 'deleteHandle');
|
||||
Typecho_Plugin::factory('Widget_Upload')->attachmentHandle = array('AliUpload_Plugin', 'attachmentHandle');
|
||||
Typecho_Plugin::factory('Widget_Upload')->attachmentDataHandle = array('AliUpload_Plugin', 'attachmentDataHandle');
|
||||
|
||||
return _t('启用成功,请进行相应设置!');
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁用插件方法,如果禁用失败,直接抛出异常
|
||||
*
|
||||
* @static
|
||||
* @access public
|
||||
* @return void
|
||||
* @throws Typecho_Plugin_Exception
|
||||
*/
|
||||
public static function deactivate(){}
|
||||
|
||||
/**
|
||||
* 获取插件配置面板
|
||||
*
|
||||
* @access public
|
||||
* @param Typecho_Widget_Helper_Form $form 配置面板
|
||||
* @return void
|
||||
*/
|
||||
public static function config(Typecho_Widget_Helper_Form $form)
|
||||
{
|
||||
$buketName = new Typecho_Widget_Helper_Form_Element_Text('bucket', NULL, 'loftor',
|
||||
_t('Bucket名称'), _t('请填写Buket名称!'));
|
||||
$form->addInput($buketName);
|
||||
|
||||
$accessID = new Typecho_Widget_Helper_Form_Element_Text('access_id', NULL, '',
|
||||
_t('ACCESS_ID'), _t('请填写ACCESS_ID!'));
|
||||
$form->addInput($accessID);
|
||||
|
||||
$accessKEY = new Typecho_Widget_Helper_Form_Element_Text('access_key', NULL, '',
|
||||
_t('ACCESS_KEY'), _t('请填写请填写ACCESS_KEY!'));
|
||||
$form->addInput($accessKEY);
|
||||
|
||||
$domianName = new Typecho_Widget_Helper_Form_Element_Text('domian', NULL, 'http://oss.loftor.com/',
|
||||
_t('域名名称'), _t('请填写域名名称!'));
|
||||
$form->addInput($domianName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人用户的配置面板
|
||||
*
|
||||
* @access public
|
||||
* @param Typecho_Widget_Helper_Form $form
|
||||
* @return void
|
||||
*/
|
||||
public static function personalConfig(Typecho_Widget_Helper_Form $form){}
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件处理函数
|
||||
*
|
||||
* @access public
|
||||
* @param array $file 上传的文件
|
||||
* @return mixed
|
||||
*/
|
||||
public static function uploadHandle($file)
|
||||
{
|
||||
|
||||
|
||||
if (empty($file['name'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$fileName = preg_split("(\/|\\|:)", $file['name']);
|
||||
$file['name'] = array_pop($fileName);
|
||||
|
||||
//获取扩展名
|
||||
$ext = '';
|
||||
$part = explode('.', $file['name']);
|
||||
if (($length = count($part)) > 1) {
|
||||
$ext = strtolower($part[$length - 1]);
|
||||
}
|
||||
|
||||
if (!self::checkFileType($ext)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$options = Typecho_Widget::widget('Widget_Options');
|
||||
$date = new Typecho_Date($options->gmtTime);
|
||||
$path = self::UPLOAD_PATH;
|
||||
|
||||
|
||||
$options = Typecho_Widget::widget('Widget_Options');
|
||||
|
||||
$access_id=$options->plugin('AliUpload')->access_id;
|
||||
$access_key=$options->plugin('AliUpload')->access_key;
|
||||
$bucket = $options->plugin('AliUpload')->bucket;
|
||||
|
||||
$oss_service = new ALIOSS($access_id,$access_key);
|
||||
|
||||
$path = $path . '/' . $date->year . '/' . $date->month;
|
||||
|
||||
//获取文件名
|
||||
$fileName = sprintf('%u', crc32(uniqid())) . '.' . $ext;
|
||||
$path = $path . '/' . $fileName;//add for mkdir
|
||||
|
||||
$response;
|
||||
if (isset($file['tmp_name'])) {
|
||||
//移动上传文件
|
||||
$response = $oss_service->upload_file_by_file($bucket,$path,$file['tmp_name']);
|
||||
|
||||
if (!$response->isOk()) {
|
||||
return false;
|
||||
}
|
||||
} else if (isset($file['bits'])) {
|
||||
//直接写入文件
|
||||
$upload_file_options = array(
|
||||
'content' => $file['bits'],
|
||||
'length' => strlen($file['bits'])
|
||||
);
|
||||
|
||||
$response = $oss_service->upload_file_by_content($bucket,$path,$upload_file_options);
|
||||
|
||||
if (!$response->isOk()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($file['size'])) {
|
||||
|
||||
$file['size'] = $response->header['_info']['size_upload'];
|
||||
}
|
||||
|
||||
$path=$response->header['x-oss-request-url'];
|
||||
|
||||
//返回相对存储路径
|
||||
return array(
|
||||
'name' => $file['name'],
|
||||
'path' => self::UPLOAD_PATH . '/' . $date->year . '/' . $date->month . '/' . $fileName,
|
||||
'size' => $file['size'],
|
||||
'type' => $ext,
|
||||
'mime' => self::mimeContentType($ext)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改文件处理函数
|
||||
*
|
||||
* @access public
|
||||
* @param array $content 老文件
|
||||
* @param array $file 新上传的文件
|
||||
* @return mixed
|
||||
*/
|
||||
public static function modifyHandle($content, $file)
|
||||
{
|
||||
|
||||
if (empty($file['name'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$fileName = preg_split("(\/|\\|:)", $file['name']);
|
||||
$file['name'] = array_pop($fileName);
|
||||
|
||||
//获取扩展名
|
||||
$ext = '';
|
||||
$part = explode('.', $file['name']);
|
||||
if (($length = count($part)) > 1) {
|
||||
$ext = strtolower($part[$length - 1]);
|
||||
}
|
||||
|
||||
if ($content['attachment']->type != $ext) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取文件名
|
||||
$fileName = $content['attachment']->path;
|
||||
$path = $path . '/' . $fileName;//add for mkdir
|
||||
$path=substr($path, 1);
|
||||
|
||||
$options = Typecho_Widget::widget('Widget_Options');
|
||||
|
||||
$access_id=$options->plugin('AliUpload')->access_id;
|
||||
$access_key=$options->plugin('AliUpload')->access_key;
|
||||
$bucket = $options->plugin('AliUpload')->bucket;
|
||||
|
||||
$oss_service = new ALIOSS($access_id,$access_key);
|
||||
|
||||
|
||||
|
||||
if (isset($file['tmp_name'])) {
|
||||
//移动上传文件
|
||||
$response = $oss_service->upload_file_by_file($bucket,$path,$file['tmp_name']);
|
||||
if (!$response->isOk()) {
|
||||
return false;
|
||||
}
|
||||
} else if (isset($file['bits'])) {
|
||||
//直接写入文件
|
||||
$upload_file_options = array(
|
||||
'content' => $file['bits'],
|
||||
'length' => strlen($file['bits'])
|
||||
);
|
||||
|
||||
$response = $oss_service->upload_file_by_content($bucket,$path,$upload_file_options);
|
||||
|
||||
if (!$response->isOk()) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($file['size'])) {
|
||||
$file['size'] = $response->header['_info']['size_upload'];
|
||||
}
|
||||
|
||||
//返回相对存储路径
|
||||
return array(
|
||||
'name' => $content['attachment']->name,
|
||||
'path' => $content['attachment']->path,
|
||||
'size' => $file['size'],
|
||||
'type' => $content['attachment']->type,
|
||||
'mime' => $content['attachment']->mime
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件
|
||||
*
|
||||
* @access public
|
||||
* @param array $content 文件相关信息
|
||||
* @return string
|
||||
*/
|
||||
public static function deleteHandle(array $content)
|
||||
{
|
||||
$options = Typecho_Widget::widget('Widget_Options');
|
||||
|
||||
$access_id=$options->plugin('AliUpload')->access_id;
|
||||
$access_key=$options->plugin('AliUpload')->access_key;
|
||||
$bucket = $options->plugin('AliUpload')->bucket;
|
||||
|
||||
$oss_service = new ALIOSS($access_id,$access_key);
|
||||
|
||||
$response = $oss_service->delete_object($bucket,$content['attachment']->path);
|
||||
return $response->isOk();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取实际文件绝对访问路径
|
||||
*
|
||||
* @access public
|
||||
* @param array $content 文件相关信息
|
||||
* @return string
|
||||
*/
|
||||
public static function attachmentHandle(array $content)
|
||||
{
|
||||
$options = Typecho_Widget::widget('Widget_Options');
|
||||
$domian = $options->plugin('AliUpload')->domian;
|
||||
return $domian.$content['attachment']->path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取实际文件数据
|
||||
*
|
||||
* @access public
|
||||
* @param array $content
|
||||
* @return string
|
||||
*/
|
||||
public static function attachmentDataHandle(array $content)
|
||||
{
|
||||
$options = Typecho_Widget::widget('Widget_Options');
|
||||
$domian = $options->plugin('AliUpload')->domian;
|
||||
return file_get_contents($domian.$content['attachment']->path);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查文件名
|
||||
*
|
||||
* @access private
|
||||
* @param string $ext 扩展名
|
||||
* @return boolean
|
||||
*/
|
||||
public static function checkFileType($ext)
|
||||
{
|
||||
$options = Typecho_Widget::widget('Widget_Options');
|
||||
return in_array($ext, $options->allowedAttachmentTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图片
|
||||
*
|
||||
* @access public
|
||||
* @param string $fileName 文件名
|
||||
* @return string
|
||||
*/
|
||||
public static function mimeContentType($ext)
|
||||
{
|
||||
$mimeTypes = array(
|
||||
'ez' => 'application/andrew-inset',
|
||||
'csm' => 'application/cu-seeme',
|
||||
'cu' => 'application/cu-seeme',
|
||||
'tsp' => 'application/dsptype',
|
||||
'spl' => 'application/x-futuresplash',
|
||||
'hta' => 'application/hta',
|
||||
'cpt' => 'image/x-corelphotopaint',
|
||||
'hqx' => 'application/mac-binhex40',
|
||||
'nb' => 'application/mathematica',
|
||||
'mdb' => 'application/msaccess',
|
||||
'doc' => 'application/msword',
|
||||
'dot' => 'application/msword',
|
||||
'bin' => 'application/octet-stream',
|
||||
'oda' => 'application/oda',
|
||||
'ogg' => 'application/ogg',
|
||||
'prf' => 'application/pics-rules',
|
||||
'key' => 'application/pgp-keys',
|
||||
'pdf' => 'application/pdf',
|
||||
'pgp' => 'application/pgp-signature',
|
||||
'ps' => 'application/postscript',
|
||||
'ai' => 'application/postscript',
|
||||
'eps' => 'application/postscript',
|
||||
'rss' => 'application/rss+xml',
|
||||
'rtf' => 'text/rtf',
|
||||
'smi' => 'application/smil',
|
||||
'smil' => 'application/smil',
|
||||
'wp5' => 'application/wordperfect5.1',
|
||||
'xht' => 'application/xhtml+xml',
|
||||
'xhtml' => 'application/xhtml+xml',
|
||||
'zip' => 'application/zip',
|
||||
'cdy' => 'application/vnd.cinderella',
|
||||
'mif' => 'application/x-mif',
|
||||
'xls' => 'application/vnd.ms-excel',
|
||||
'xlb' => 'application/vnd.ms-excel',
|
||||
'cat' => 'application/vnd.ms-pki.seccat',
|
||||
'stl' => 'application/vnd.ms-pki.stl',
|
||||
'ppt' => 'application/vnd.ms-powerpoint',
|
||||
'pps' => 'application/vnd.ms-powerpoint',
|
||||
'pot' => 'application/vnd.ms-powerpoint',
|
||||
'sdc' => 'application/vnd.stardivision.calc',
|
||||
'sda' => 'application/vnd.stardivision.draw',
|
||||
'sdd' => 'application/vnd.stardivision.impress',
|
||||
'sdp' => 'application/vnd.stardivision.impress',
|
||||
'smf' => 'application/vnd.stardivision.math',
|
||||
'sdw' => 'application/vnd.stardivision.writer',
|
||||
'vor' => 'application/vnd.stardivision.writer',
|
||||
'sgl' => 'application/vnd.stardivision.writer-global',
|
||||
'sxc' => 'application/vnd.sun.xml.calc',
|
||||
'stc' => 'application/vnd.sun.xml.calc.template',
|
||||
'sxd' => 'application/vnd.sun.xml.draw',
|
||||
'std' => 'application/vnd.sun.xml.draw.template',
|
||||
'sxi' => 'application/vnd.sun.xml.impress',
|
||||
'sti' => 'application/vnd.sun.xml.impress.template',
|
||||
'sxm' => 'application/vnd.sun.xml.math',
|
||||
'sxw' => 'application/vnd.sun.xml.writer',
|
||||
'sxg' => 'application/vnd.sun.xml.writer.global',
|
||||
'stw' => 'application/vnd.sun.xml.writer.template',
|
||||
'sis' => 'application/vnd.symbian.install',
|
||||
'wbxml' => 'application/vnd.wap.wbxml',
|
||||
'wmlc' => 'application/vnd.wap.wmlc',
|
||||
'wmlsc' => 'application/vnd.wap.wmlscriptc',
|
||||
'wk' => 'application/x-123',
|
||||
'dmg' => 'application/x-apple-diskimage',
|
||||
'bcpio' => 'application/x-bcpio',
|
||||
'torrent' => 'application/x-bittorrent',
|
||||
'cdf' => 'application/x-cdf',
|
||||
'vcd' => 'application/x-cdlink',
|
||||
'pgn' => 'application/x-chess-pgn',
|
||||
'cpio' => 'application/x-cpio',
|
||||
'csh' => 'text/x-csh',
|
||||
'deb' => 'application/x-debian-package',
|
||||
'dcr' => 'application/x-director',
|
||||
'dir' => 'application/x-director',
|
||||
'dxr' => 'application/x-director',
|
||||
'wad' => 'application/x-doom',
|
||||
'dms' => 'application/x-dms',
|
||||
'dvi' => 'application/x-dvi',
|
||||
'pfa' => 'application/x-font',
|
||||
'pfb' => 'application/x-font',
|
||||
'gsf' => 'application/x-font',
|
||||
'pcf' => 'application/x-font',
|
||||
'pcf.Z' => 'application/x-font',
|
||||
'gnumeric' => 'application/x-gnumeric',
|
||||
'sgf' => 'application/x-go-sgf',
|
||||
'gcf' => 'application/x-graphing-calculator',
|
||||
'gtar' => 'application/x-gtar',
|
||||
'tgz' => 'application/x-gtar',
|
||||
'taz' => 'application/x-gtar',
|
||||
'gz' => 'application/x-gtar',
|
||||
'hdf' => 'application/x-hdf',
|
||||
'phtml' => 'application/x-httpd-php',
|
||||
'pht' => 'application/x-httpd-php',
|
||||
'php' => 'application/x-httpd-php',
|
||||
'phps' => 'application/x-httpd-php-source',
|
||||
'php3' => 'application/x-httpd-php3',
|
||||
'php3p' => 'application/x-httpd-php3-preprocessed',
|
||||
'php4' => 'application/x-httpd-php4',
|
||||
'ica' => 'application/x-ica',
|
||||
'ins' => 'application/x-internet-signup',
|
||||
'isp' => 'application/x-internet-signup',
|
||||
'iii' => 'application/x-iphone',
|
||||
'jar' => 'application/x-java-archive',
|
||||
'jnlp' => 'application/x-java-jnlp-file',
|
||||
'ser' => 'application/x-java-serialized-object',
|
||||
'class' => 'application/x-java-vm',
|
||||
'js' => 'application/x-javascript',
|
||||
'chrt' => 'application/x-kchart',
|
||||
'kil' => 'application/x-killustrator',
|
||||
'kpr' => 'application/x-kpresenter',
|
||||
'kpt' => 'application/x-kpresenter',
|
||||
'skp' => 'application/x-koan',
|
||||
'skd' => 'application/x-koan',
|
||||
'skt' => 'application/x-koan',
|
||||
'skm' => 'application/x-koan',
|
||||
'ksp' => 'application/x-kspread',
|
||||
'kwd' => 'application/x-kword',
|
||||
'kwt' => 'application/x-kword',
|
||||
'latex' => 'application/x-latex',
|
||||
'lha' => 'application/x-lha',
|
||||
'lzh' => 'application/x-lzh',
|
||||
'lzx' => 'application/x-lzx',
|
||||
'frm' => 'application/x-maker',
|
||||
'maker' => 'application/x-maker',
|
||||
'frame' => 'application/x-maker',
|
||||
'fm' => 'application/x-maker',
|
||||
'fb' => 'application/x-maker',
|
||||
'book' => 'application/x-maker',
|
||||
'fbdoc' => 'application/x-maker',
|
||||
'wmz' => 'application/x-ms-wmz',
|
||||
'wmd' => 'application/x-ms-wmd',
|
||||
'com' => 'application/x-msdos-program',
|
||||
'exe' => 'application/x-msdos-program',
|
||||
'bat' => 'application/x-msdos-program',
|
||||
'dll' => 'application/x-msdos-program',
|
||||
'msi' => 'application/x-msi',
|
||||
'nc' => 'application/x-netcdf',
|
||||
'pac' => 'application/x-ns-proxy-autoconfig',
|
||||
'nwc' => 'application/x-nwc',
|
||||
'o' => 'application/x-object',
|
||||
'oza' => 'application/x-oz-application',
|
||||
'pl' => 'application/x-perl',
|
||||
'pm' => 'application/x-perl',
|
||||
'p7r' => 'application/x-pkcs7-certreqresp',
|
||||
'crl' => 'application/x-pkcs7-crl',
|
||||
'qtl' => 'application/x-quicktimeplayer',
|
||||
'rpm' => 'audio/x-pn-realaudio-plugin',
|
||||
'shar' => 'application/x-shar',
|
||||
'swf' => 'application/x-shockwave-flash',
|
||||
'swfl' => 'application/x-shockwave-flash',
|
||||
'sh' => 'text/x-sh',
|
||||
'sit' => 'application/x-stuffit',
|
||||
'sv4cpio' => 'application/x-sv4cpio',
|
||||
'sv4crc' => 'application/x-sv4crc',
|
||||
'tar' => 'application/x-tar',
|
||||
'tcl' => 'text/x-tcl',
|
||||
'tex' => 'text/x-tex',
|
||||
'gf' => 'application/x-tex-gf',
|
||||
'pk' => 'application/x-tex-pk',
|
||||
'texinfo' => 'application/x-texinfo',
|
||||
'texi' => 'application/x-texinfo',
|
||||
'~' => 'application/x-trash',
|
||||
'%' => 'application/x-trash',
|
||||
'bak' => 'application/x-trash',
|
||||
'old' => 'application/x-trash',
|
||||
'sik' => 'application/x-trash',
|
||||
't' => 'application/x-troff',
|
||||
'tr' => 'application/x-troff',
|
||||
'roff' => 'application/x-troff',
|
||||
'man' => 'application/x-troff-man',
|
||||
'me' => 'application/x-troff-me',
|
||||
'ms' => 'application/x-troff-ms',
|
||||
'ustar' => 'application/x-ustar',
|
||||
'src' => 'application/x-wais-source',
|
||||
'wz' => 'application/x-wingz',
|
||||
'crt' => 'application/x-x509-ca-cert',
|
||||
'fig' => 'application/x-xfig',
|
||||
'au' => 'audio/basic',
|
||||
'snd' => 'audio/basic',
|
||||
'mid' => 'audio/midi',
|
||||
'midi' => 'audio/midi',
|
||||
'kar' => 'audio/midi',
|
||||
'mpga' => 'audio/mpeg',
|
||||
'mpega' => 'audio/mpeg',
|
||||
'mp2' => 'audio/mpeg',
|
||||
'mp3' => 'audio/mpeg',
|
||||
'm3u' => 'audio/x-mpegurl',
|
||||
'sid' => 'audio/prs.sid',
|
||||
'aif' => 'audio/x-aiff',
|
||||
'aiff' => 'audio/x-aiff',
|
||||
'aifc' => 'audio/x-aiff',
|
||||
'gsm' => 'audio/x-gsm',
|
||||
'wma' => 'audio/x-ms-wma',
|
||||
'wax' => 'audio/x-ms-wax',
|
||||
'ra' => 'audio/x-realaudio',
|
||||
'rm' => 'audio/x-pn-realaudio',
|
||||
'ram' => 'audio/x-pn-realaudio',
|
||||
'pls' => 'audio/x-scpls',
|
||||
'sd2' => 'audio/x-sd2',
|
||||
'wav' => 'audio/x-wav',
|
||||
'pdb' => 'chemical/x-pdb',
|
||||
'xyz' => 'chemical/x-xyz',
|
||||
'bmp' => 'image/x-ms-bmp',
|
||||
'gif' => 'image/gif',
|
||||
'ief' => 'image/ief',
|
||||
'jpeg' => 'image/jpeg',
|
||||
'jpg' => 'image/jpeg',
|
||||
'jpe' => 'image/jpeg',
|
||||
'pcx' => 'image/pcx',
|
||||
'png' => 'image/png',
|
||||
'svg' => 'image/svg+xml',
|
||||
'svgz' => 'image/svg+xml',
|
||||
'tiff' => 'image/tiff',
|
||||
'tif' => 'image/tiff',
|
||||
'wbmp' => 'image/vnd.wap.wbmp',
|
||||
'ras' => 'image/x-cmu-raster',
|
||||
'cdr' => 'image/x-coreldraw',
|
||||
'pat' => 'image/x-coreldrawpattern',
|
||||
'cdt' => 'image/x-coreldrawtemplate',
|
||||
'djvu' => 'image/x-djvu',
|
||||
'djv' => 'image/x-djvu',
|
||||
'ico' => 'image/x-icon',
|
||||
'art' => 'image/x-jg',
|
||||
'jng' => 'image/x-jng',
|
||||
'psd' => 'image/x-photoshop',
|
||||
'pnm' => 'image/x-portable-anymap',
|
||||
'pbm' => 'image/x-portable-bitmap',
|
||||
'pgm' => 'image/x-portable-graymap',
|
||||
'ppm' => 'image/x-portable-pixmap',
|
||||
'rgb' => 'image/x-rgb',
|
||||
'xbm' => 'image/x-xbitmap',
|
||||
'xpm' => 'image/x-xpixmap',
|
||||
'xwd' => 'image/x-xwindowdump',
|
||||
'igs' => 'model/iges',
|
||||
'iges' => 'model/iges',
|
||||
'msh' => 'model/mesh',
|
||||
'mesh' => 'model/mesh',
|
||||
'silo' => 'model/mesh',
|
||||
'wrl' => 'x-world/x-vrml',
|
||||
'vrml' => 'x-world/x-vrml',
|
||||
'csv' => 'text/comma-separated-values',
|
||||
'css' => 'text/css',
|
||||
'323' => 'text/h323',
|
||||
'htm' => 'text/html',
|
||||
'html' => 'text/html',
|
||||
'uls' => 'text/iuls',
|
||||
'mml' => 'text/mathml',
|
||||
'asc' => 'text/plain',
|
||||
'txt' => 'text/plain',
|
||||
'text' => 'text/plain',
|
||||
'diff' => 'text/plain',
|
||||
'rtx' => 'text/richtext',
|
||||
'sct' => 'text/scriptlet',
|
||||
'wsc' => 'text/scriptlet',
|
||||
'tm' => 'text/texmacs',
|
||||
'ts' => 'text/texmacs',
|
||||
'tsv' => 'text/tab-separated-values',
|
||||
'jad' => 'text/vnd.sun.j2me.app-descriptor',
|
||||
'wml' => 'text/vnd.wap.wml',
|
||||
'wmls' => 'text/vnd.wap.wmlscript',
|
||||
'xml' => 'text/xml',
|
||||
'xsl' => 'text/xml',
|
||||
'h++' => 'text/x-c++hdr',
|
||||
'hpp' => 'text/x-c++hdr',
|
||||
'hxx' => 'text/x-c++hdr',
|
||||
'hh' => 'text/x-c++hdr',
|
||||
'c++' => 'text/x-c++src',
|
||||
'cpp' => 'text/x-c++src',
|
||||
'cxx' => 'text/x-c++src',
|
||||
'cc' => 'text/x-c++src',
|
||||
'h' => 'text/x-chdr',
|
||||
'c' => 'text/x-csrc',
|
||||
'java' => 'text/x-java',
|
||||
'moc' => 'text/x-moc',
|
||||
'p' => 'text/x-pascal',
|
||||
'pas' => 'text/x-pascal',
|
||||
'***' => 'text/x-pcs-***',
|
||||
'shtml' => 'text/x-server-parsed-html',
|
||||
'etx' => 'text/x-setext',
|
||||
'tk' => 'text/x-tcl',
|
||||
'ltx' => 'text/x-tex',
|
||||
'sty' => 'text/x-tex',
|
||||
'cls' => 'text/x-tex',
|
||||
'vcs' => 'text/x-vcalendar',
|
||||
'vcf' => 'text/x-vcard',
|
||||
'dl' => 'video/dl',
|
||||
'fli' => 'video/fli',
|
||||
'gl' => 'video/gl',
|
||||
'mpeg' => 'video/mpeg',
|
||||
'mpg' => 'video/mpeg',
|
||||
'mpe' => 'video/mpeg',
|
||||
'qt' => 'video/quicktime',
|
||||
'mov' => 'video/quicktime',
|
||||
'mxu' => 'video/vnd.mpegurl',
|
||||
'dif' => 'video/x-dv',
|
||||
'dv' => 'video/x-dv',
|
||||
'lsf' => 'video/x-la-asf',
|
||||
'lsx' => 'video/x-la-asf',
|
||||
'mng' => 'video/x-mng',
|
||||
'asf' => 'video/x-ms-asf',
|
||||
'asx' => 'video/x-ms-asf',
|
||||
'wm' => 'video/x-ms-wm',
|
||||
'wmv' => 'video/x-ms-wmv',
|
||||
'wmx' => 'video/x-ms-wmx',
|
||||
'wvx' => 'video/x-ms-wvx',
|
||||
'avi' => 'video/x-msvideo',
|
||||
'movie' => 'video/x-sgi-movie',
|
||||
'ice' => 'x-conference/x-cooltalk',
|
||||
'vrm' => 'x-world/x-vrml',
|
||||
'rar' => 'application/x-rar-compressed',
|
||||
'cab' => 'application/vnd.ms-cab-compressed'
|
||||
);
|
||||
|
||||
$ext=strtolower($ext);
|
||||
if (isset($mimeTypes[$ext])) {
|
||||
return $mimeTypes[$ext];
|
||||
}
|
||||
|
||||
return 'application/octet-stream';
|
||||
}
|
||||
}
|
121
AliUpload/lib/mimetypes.class.php
Executable file
121
AliUpload/lib/mimetypes.class.php
Executable file
@ -0,0 +1,121 @@
|
||||
<?php
|
||||
/**
|
||||
* 获得文件的mime type类型
|
||||
* @author xiaobing.meng
|
||||
*
|
||||
*/
|
||||
class MimeTypes {
|
||||
public static $mime_types = array (
|
||||
'apk' => 'application/vnd.android.package-archive',
|
||||
'3gp' => 'video/3gpp', 'ai' => 'application/postscript',
|
||||
'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff',
|
||||
'aiff' => 'audio/x-aiff', 'asc' => 'text/plain',
|
||||
'atom' => 'application/atom+xml', 'au' => 'audio/basic',
|
||||
'avi' => 'video/x-msvideo', 'bcpio' => 'application/x-bcpio',
|
||||
'bin' => 'application/octet-stream', 'bmp' => 'image/bmp',
|
||||
'cdf' => 'application/x-netcdf', 'cgm' => 'image/cgm',
|
||||
'class' => 'application/octet-stream',
|
||||
'cpio' => 'application/x-cpio',
|
||||
'cpt' => 'application/mac-compactpro',
|
||||
'csh' => 'application/x-csh', 'css' => 'text/css',
|
||||
'dcr' => 'application/x-director', 'dif' => 'video/x-dv',
|
||||
'dir' => 'application/x-director', 'djv' => 'image/vnd.djvu',
|
||||
'djvu' => 'image/vnd.djvu',
|
||||
'dll' => 'application/octet-stream',
|
||||
'dmg' => 'application/octet-stream',
|
||||
'dms' => 'application/octet-stream',
|
||||
'doc' => 'application/msword', 'dtd' => 'application/xml-dtd',
|
||||
'dv' => 'video/x-dv', 'dvi' => 'application/x-dvi',
|
||||
'dxr' => 'application/x-director',
|
||||
'eps' => 'application/postscript', 'etx' => 'text/x-setext',
|
||||
'exe' => 'application/octet-stream',
|
||||
'ez' => 'application/andrew-inset', 'flv' => 'video/x-flv',
|
||||
'gif' => 'image/gif', 'gram' => 'application/srgs',
|
||||
'grxml' => 'application/srgs+xml',
|
||||
'gtar' => 'application/x-gtar', 'gz' => 'application/x-gzip',
|
||||
'hdf' => 'application/x-hdf',
|
||||
'hqx' => 'application/mac-binhex40', 'htm' => 'text/html',
|
||||
'html' => 'text/html', 'ice' => 'x-conference/x-cooltalk',
|
||||
'ico' => 'image/x-icon', 'ics' => 'text/calendar',
|
||||
'ief' => 'image/ief', 'ifb' => 'text/calendar',
|
||||
'iges' => 'model/iges', 'igs' => 'model/iges',
|
||||
'jnlp' => 'application/x-java-jnlp-file', 'jp2' => 'image/jp2',
|
||||
'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg',
|
||||
'jpg' => 'image/jpeg', 'js' => 'application/x-javascript',
|
||||
'kar' => 'audio/midi', 'latex' => 'application/x-latex',
|
||||
'lha' => 'application/octet-stream',
|
||||
'lzh' => 'application/octet-stream',
|
||||
'm3u' => 'audio/x-mpegurl', 'm4a' => 'audio/mp4a-latm',
|
||||
'm4p' => 'audio/mp4a-latm', 'm4u' => 'video/vnd.mpegurl',
|
||||
'm4v' => 'video/x-m4v', 'mac' => 'image/x-macpaint',
|
||||
'man' => 'application/x-troff-man',
|
||||
'mathml' => 'application/mathml+xml',
|
||||
'me' => 'application/x-troff-me', 'mesh' => 'model/mesh',
|
||||
'mid' => 'audio/midi', 'midi' => 'audio/midi',
|
||||
'mif' => 'application/vnd.mif', 'mov' => 'video/quicktime',
|
||||
'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/mpeg',
|
||||
'mp3' => 'audio/mpeg', 'mp4' => 'video/mp4',
|
||||
'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg',
|
||||
'mpg' => 'video/mpeg', 'mpga' => 'audio/mpeg',
|
||||
'ms' => 'application/x-troff-ms', 'msh' => 'model/mesh',
|
||||
'mxu' => 'video/vnd.mpegurl', 'nc' => 'application/x-netcdf',
|
||||
'oda' => 'application/oda', 'ogg' => 'application/ogg',
|
||||
'ogv' => 'video/ogv', 'pbm' => 'image/x-portable-bitmap',
|
||||
'pct' => 'image/pict', 'pdb' => 'chemical/x-pdb',
|
||||
'pdf' => 'application/pdf',
|
||||
'pgm' => 'image/x-portable-graymap',
|
||||
'pgn' => 'application/x-chess-pgn', 'pic' => 'image/pict',
|
||||
'pict' => 'image/pict', 'png' => 'image/png',
|
||||
'pnm' => 'image/x-portable-anymap',
|
||||
'pnt' => 'image/x-macpaint', 'pntg' => 'image/x-macpaint',
|
||||
'ppm' => 'image/x-portable-pixmap',
|
||||
'ppt' => 'application/vnd.ms-powerpoint',
|
||||
'ps' => 'application/postscript', 'qt' => 'video/quicktime',
|
||||
'qti' => 'image/x-quicktime', 'qtif' => 'image/x-quicktime',
|
||||
'ra' => 'audio/x-pn-realaudio',
|
||||
'ram' => 'audio/x-pn-realaudio', 'ras' => 'image/x-cmu-raster',
|
||||
'rdf' => 'application/rdf+xml', 'rgb' => 'image/x-rgb',
|
||||
'rm' => 'application/vnd.rn-realmedia',
|
||||
'roff' => 'application/x-troff', 'rtf' => 'text/rtf',
|
||||
'rtx' => 'text/richtext', 'sgm' => 'text/sgml',
|
||||
'sgml' => 'text/sgml', 'sh' => 'application/x-sh',
|
||||
'shar' => 'application/x-shar', 'silo' => 'model/mesh',
|
||||
'sit' => 'application/x-stuffit',
|
||||
'skd' => 'application/x-koan', 'skm' => 'application/x-koan',
|
||||
'skp' => 'application/x-koan', 'skt' => 'application/x-koan',
|
||||
'smi' => 'application/smil', 'smil' => 'application/smil',
|
||||
'snd' => 'audio/basic', 'so' => 'application/octet-stream',
|
||||
'spl' => 'application/x-futuresplash',
|
||||
'src' => 'application/x-wais-source',
|
||||
'sv4cpio' => 'application/x-sv4cpio',
|
||||
'sv4crc' => 'application/x-sv4crc', 'svg' => 'image/svg+xml',
|
||||
'swf' => 'application/x-shockwave-flash',
|
||||
't' => 'application/x-troff', 'tar' => 'application/x-tar',
|
||||
'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex',
|
||||
'texi' => 'application/x-texinfo',
|
||||
'texinfo' => 'application/x-texinfo', 'tif' => 'image/tiff',
|
||||
'tiff' => 'image/tiff', 'tr' => 'application/x-troff',
|
||||
'tsv' => 'text/tab-separated-values', 'txt' => 'text/plain',
|
||||
'ustar' => 'application/x-ustar',
|
||||
'vcd' => 'application/x-cdlink', 'vrml' => 'model/vrml',
|
||||
'vxml' => 'application/voicexml+xml', 'wav' => 'audio/x-wav',
|
||||
'wbmp' => 'image/vnd.wap.wbmp',
|
||||
'wbxml' => 'application/vnd.wap.wbxml', 'webm' => 'video/webm',
|
||||
'wml' => 'text/vnd.wap.wml',
|
||||
'wmlc' => 'application/vnd.wap.wmlc',
|
||||
'wmls' => 'text/vnd.wap.wmlscript',
|
||||
'wmlsc' => 'application/vnd.wap.wmlscriptc',
|
||||
'wmv' => 'video/x-ms-wmv', 'wrl' => 'model/vrml',
|
||||
'xbm' => 'image/x-xbitmap', 'xht' => 'application/xhtml+xml',
|
||||
'xhtml' => 'application/xhtml+xml',
|
||||
'xls' => 'application/vnd.ms-excel',
|
||||
'xml' => 'application/xml', 'xpm' => 'image/x-xpixmap',
|
||||
'xsl' => 'application/xml', 'xslt' => 'application/xslt+xml',
|
||||
'xul' => 'application/vnd.mozilla.xul+xml',
|
||||
'xwd' => 'image/x-xwindowdump', 'xyz' => 'chemical/x-xyz',
|
||||
'zip' => 'application/zip' );
|
||||
|
||||
public static function get_mimetype($ext) {
|
||||
return (isset ( self::$mime_types [$ext] ) ? self::$mime_types [$ext] : 'application/octet-stream');
|
||||
}
|
||||
}
|
1030
AliUpload/lib/requestcore.class.php
Executable file
1030
AliUpload/lib/requestcore.class.php
Executable file
File diff suppressed because it is too large
Load Diff
2302
AliUpload/lib/sdk.class.php
Executable file
2302
AliUpload/lib/sdk.class.php
Executable file
File diff suppressed because it is too large
Load Diff
96
AliUpload/lib/zh.inc.php
Executable file
96
AliUpload/lib/zh.inc.php
Executable file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/*%*************************************************************************************%*/
|
||||
//access id & access key 相关
|
||||
define('NOT_SET_OSS_ACCESS_ID', '未设置OSS服务的ACCESS ID');
|
||||
define('NOT_SET_OSS_ACCESS_KEY', '未设置OSS服务的ACCESS KEY');
|
||||
define('NOT_SET_OSS_ACCESS_ID_AND_ACCESS_KEY', '没有设置ACCESS ID & ACCESS KEY');
|
||||
define('OSS_ACCESS_ID_OR_ACCESS_KEY_EMPTY', 'ACCESS ID或ACCESS KEY为空');
|
||||
|
||||
/*%*************************************************************************************%*/
|
||||
//OSS语言包以及文件相关
|
||||
define('OSS_LANG_FILE_NOT_EXIST', 'OSS语言包文件不存在');
|
||||
define('OSS_CONFIG_FILE_NOT_EXIST',OSS_API_PATH.DIRECTORY_SEPARATOR.'conf.inc.php不存在');
|
||||
define('OSS_UTILS_FILE_NOT_EXIST',OSS_API_PATH.DIRECTORY_SEPARATOR.'util'.DIRECTORY_SEPARATOR.'utils.php不存在');
|
||||
define('OSS_CURL_EXTENSION_MUST_BE_LOAD','系统没有安装CURL扩展');
|
||||
define('OSS_NO_ANY_EXTENSIONS_LOADED','系统没有安装任何扩展,请检查系统配置');
|
||||
|
||||
|
||||
/*%*************************************************************************************%*/
|
||||
//日志文件相关
|
||||
define('OSS_WRITE_LOG_TO_FILE_FAILED','日志写入失败,请检查日志文件是否存在或者日志文件的权限');
|
||||
define('OSS_LOG_PATH_NOT_EXIST','日志路径不存在');
|
||||
|
||||
/*%**************************************************************************************%*/
|
||||
//OSS bucket操作相关
|
||||
define('OSS_OPTIONS_MUST_BE_ARRAY', '$option必须为数组');
|
||||
define('OSS_GET_BUCKET_LIST_SUCCESS','获取Bucket列表成功!');
|
||||
define('OSS_GET_BUCKET_LIST_FAILED', '获取Bucket列表失败!');
|
||||
define('OSS_CREATE_BUCKET_SUCCESS', '创建Bucket成功');
|
||||
define('OSS_CREATE_BUCKET_FAILED', '创建Bucket失败');
|
||||
define('OSS_DELETE_BUCKET_SUCCESS', '删除Bucket成功');
|
||||
define('OSS_DELETE_BUCKET_FAILED', '删除Bucket失败');
|
||||
define('OSS_BUCKET_NAME_INVALID', '未通过Bucket名称规则校验');
|
||||
define('OSS_GET_BUCKET_ACL_SUCCESS','获取Bucket ACL成功');
|
||||
define('OSS_GET_BUCKET_ACL_FAILED','获取Bucket ACL失败');
|
||||
define('OSS_SET_BUCKET_ACL_SUCCESS','设置Bucket ACL成功');
|
||||
define('OSS_SET_BUCKET_ACL_FAILED','设置Bucket ACL失败');
|
||||
define('OSS_ACL_INVALID','ACL不在允许范围,目前仅允许(private,public-read,public-read-write三种权限)');
|
||||
define('OSS_BUCKET_IS_NOT_ALLOWED_EMPTY', 'Bucket不允许为空');
|
||||
|
||||
/*%****************************************************************************************%*/
|
||||
//OSS object操作相关
|
||||
define('OSS_GET_OBJECT_LIST_SUCCESS','获得OBJECT列表成功');
|
||||
define('OSS_GET_OBJECT_LIST_FAILED','获得OBJECT列表失败');
|
||||
define('OSS_CREATE_OBJECT_DIR_SUCCESS','创建OBJECT目录成功');
|
||||
define('OSS_CREATE_OBJECT_DIR_FAILED','创建OBJECT目录失败');
|
||||
define('OSS_DELETE_OBJECT_SUCCESS','删除OBJECT成功');
|
||||
define('OSS_DELETE_OBJECT_FAILED','删除OBJECT失败');
|
||||
define('OSS_UPLOAD_FILE_BY_CONTENT_SUCCESS','通过Http Body上传文件成功');
|
||||
define('OSS_UPLOAD_FILE_BY_CONTENT_FAILED','通过Http Body上传文件失败');
|
||||
define('OSS_GET_OBJECT_META_SUCCESS','获得OBJECT META成功');
|
||||
define('OSS_GET_OBJECT_META_FAILED','获得OBJECT META失败');
|
||||
define('OSS_OBJECT_NAME_INVALID','未通过Object名称规则校验');
|
||||
define('OSS_OBJECT_IS_NOT_ALLOWED_EMPTY','Object不允许为空');
|
||||
define('OSS_INVALID_HTTP_BODY_CONTENT','Http Body的内容非法');
|
||||
define('OSS_GET_OBJECT_SUCCESS','获得Object成功');
|
||||
define('OSS_GET_OBJECT_FAILED','获得Object失败');
|
||||
define('OSS_OBJECT_EXIST','Object存在');
|
||||
define('OSS_OBJECT_NOT_EXIST','Object不存在');
|
||||
define('OSS_NOT_SET_HTTP_CONTENT','为设置Http Body');
|
||||
define('OSS_INVALID_CONTENT_LENGTH','非法的Content-Length值');
|
||||
define('OSS_CONTENT_LENGTH_MUST_MORE_THAN_ZERO','Content-Length必须大于0');
|
||||
define('OSS_UPLOAD_FILE_NOT_EXIST','上传文件不存在');
|
||||
define('OSS_COPY_OBJECT_SUCCESS','拷贝Object成功');
|
||||
define('OSS_COPY_OBJECT_FAILED', '拷贝Object失败');
|
||||
define('OSS_FILE_NOT_EXIST','文件不存在');
|
||||
define('OSS_FILE_PATH_IS_NOT_ALLOWED_EMPTY', '上传文件路径为空');
|
||||
|
||||
/*%****************************************************************************************%*/
|
||||
//OSS object Group操作相关
|
||||
define('OSS_CREATE_OBJECT_GROUP_SUCCESS','创建Object Group成功');
|
||||
define('OSS_CREATE_OBJECT_GROUP_FAILED','创建Object Group失败');
|
||||
define('OSS_GET_OBJECT_GROUP_SUCCESS','获取Object Group成功');
|
||||
define('OSS_GET_OBJECT_GROUP_FAILED','获取Object Group失败');
|
||||
define('OSS_GET_OBJECT_GROUP_INDEX_SUCCESS','获取Object Group Index成功');
|
||||
define('OSS_GET_OBJECT_GROUP_INDEX_FAILED','获取Object Group Index失败');
|
||||
define('OSS_GET_OBJECT_GROUP_META_SUCCESS','获取Object Group Group Meta成功');
|
||||
define('OSS_GET_OBJECT_GROUP_META_FAILED','获取Object Group Group Meta失败');
|
||||
define('OSS_DELETE_OBJECT_GROUP_SUCCESS','删除Object Group Group成功');
|
||||
define('OSS_DELETE_OBJECT_GROUP_FAILED','删除Object Group Group失败');
|
||||
define('OSS_OBJECT_GROUP_IS_NOT_ALLOWED_EMPTY', 'Object Group不允许为空');
|
||||
define('OSS_OBJECT_ARRAY_IS_EMPTY','创建Object Group的Object不允许为空');
|
||||
define('OSS_OBJECT_GROUP_TOO_MANY_OBJECT','每个Object Group最多包含1000个Object');
|
||||
|
||||
/*%****************************************************************************************%*/
|
||||
//OSS Multi-Part Upload相关
|
||||
define('OSS_INITIATE_MULTI_PART_SUCCESS', '初始化Multi-Part Upload成功');
|
||||
define('OSS_INITIATE_MULTI_PART_FAILED', '初始化Multi-Part Upload失败');
|
||||
|
||||
/*%*******************************************************************************************%*/
|
||||
//其他
|
||||
define('OSS_INVALID_OPTION_HEADERS', 'OPTIONS不是数组');
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -2250,7 +2250,7 @@ var zen_editor = (function(){
|
||||
* @include "editor.js"
|
||||
* @include "../../aptana/lib/html_matcher.js"
|
||||
* @include "../../aptana/lib/zen_coding.js"
|
||||
*/
|
||||
*/
|
||||
|
||||
/**
|
||||
* Search for abbreviation in editor from current caret position
|
||||
|
Loading…
Reference in New Issue
Block a user