国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

614 lines
21KB

  1. <?php
  2. if (!defined('DEDEINC')) exit ('dedebiz');
  3. /**
  4. * 系统存放函数
  5. *
  6. * @version $id:common.func.php 4 16:39 2010年7月6日 tianya $
  7. * @package DedeBIZ.Libraries
  8. * @copyright Copyright (c) 2022 DedeBIZ.COM
  9. * @license GNU GPL v2 (https://www.dedebiz.com/license)
  10. * @link https://www.dedebiz.com
  11. */
  12. if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
  13. if (!function_exists('mysql_connect') and function_exists('mysqli_connect')) {
  14. function mysql_connect($server, $username, $password)
  15. {
  16. return mysqli_connect($server, $username, $password);
  17. }
  18. }
  19. if (!function_exists('mysql_query') and function_exists('mysqli_query')) {
  20. function mysql_query($query, $link)
  21. {
  22. return mysqli_query($link, $query);
  23. }
  24. }
  25. if (!function_exists('mysql_select_db') and function_exists('mysqli_select_db')) {
  26. function mysql_select_db($database_name, $link)
  27. {
  28. return mysqli_select_db($link, $database_name);
  29. }
  30. }
  31. if (!function_exists('mysql_fetch_array') and function_exists('mysqli_fetch_array')) {
  32. function mysql_fetch_array($result)
  33. {
  34. return mysqli_fetch_array($result);
  35. }
  36. }
  37. if (!function_exists('mysql_close') and function_exists('mysqli_close')) {
  38. function mysql_close($link)
  39. {
  40. if ($link) {
  41. return @mysqli_close($link);
  42. } else {
  43. return false;
  44. }
  45. }
  46. }
  47. if (!function_exists('mysql_error') and function_exists('mysqli_connect_error')) {
  48. function mysql_error($link)
  49. {
  50. if (mysqli_connect_errno()) {
  51. return mysqli_connect_error();
  52. }
  53. if ($link) {
  54. return @mysqli_error($link);
  55. } else {
  56. return false;
  57. }
  58. }
  59. }
  60. if (!function_exists('mysql_free_result') and function_exists('mysqli_free_result')) {
  61. function mysql_free_result($result)
  62. {
  63. return mysqli_free_result($result);
  64. }
  65. }
  66. if (!function_exists('split')) {
  67. function split($pattern, $string)
  68. {
  69. return explode($pattern, $string);
  70. }
  71. }
  72. }
  73. //一个支持在PHP Cli Server打印的方法
  74. function var_dump_cli($val,...$values)
  75. {
  76. ob_start();
  77. var_dump($val,$values);
  78. error_log(ob_get_clean(), 4);
  79. }
  80. function get_mime_type($filename)
  81. {
  82. if (!function_exists('finfo_open')) {
  83. return 'unknow/octet-stream';
  84. }
  85. $finfo = finfo_open(FILEINFO_MIME_TYPE);
  86. $mimeType = finfo_file($finfo, $filename);
  87. if (preg_match('#\.(php|pl|cgi|asp|aspx|jsp|php5|php4|php3|shtm|shtml|htm)$#i', trim($filename))) {
  88. return 'forbid/octet-stream';
  89. }
  90. finfo_close($finfo);
  91. return $mimeType;
  92. }
  93. function is_all_numeric(array $array)
  94. {
  95. foreach ($array as $item) {
  96. if (!is_numeric($item)) return false;
  97. }
  98. return true;
  99. }
  100. function make_hash()
  101. {
  102. $rand = dede_random_bytes(16);
  103. $_SESSION['token'] = ($rand === FALSE) ? md5(uniqid(mt_rand(), TRUE)) : bin2hex($rand);
  104. return $_SESSION['token'];
  105. }
  106. function dede_random_bytes($length)
  107. {
  108. if (empty($length) or !ctype_digit((string) $length)) {
  109. return FALSE;
  110. }
  111. if (function_exists('openssl_random_pseudo_bytes')) {
  112. return openssl_random_pseudo_bytes($length);
  113. }
  114. if (function_exists('random_bytes')) {
  115. try {
  116. return random_bytes((int) $length);
  117. } catch (Exception $e) {
  118. return FALSE;
  119. }
  120. }
  121. if (is_readable('/dev/urandom') && ($fp = fopen('/dev/urandom', 'rb')) !== FALSE) {
  122. version_compare(PHP_VERSION, '5.4.0', '>=') && stream_set_chunk_size($fp, $length);
  123. $output = fread($fp, $length);
  124. fclose($fp);
  125. if ($output !== FALSE) {
  126. return $output;
  127. }
  128. }
  129. return FALSE;
  130. }
  131. //SQL语句过滤程序,由80sec提供,这里作了适当的修改
  132. if (!function_exists('CheckSql')) {
  133. function CheckSql($db_string, $querytype = 'select')
  134. {
  135. global $cfg_cookie_encode;
  136. $clean = '';
  137. $error = '';
  138. $old_pos = 0;
  139. $pos = -1;
  140. $enkey = substr(md5(substr($cfg_cookie_encode.'dedebiz', 0, 5)), 0, 10);
  141. $log_file = DEDEDATA.'/checksql_'.$enkey.'_safe.txt';
  142. $userIP = GetIP();
  143. $getUrl = GetCurUrl();
  144. //如果是普通查询语句,直接过滤一些特殊语法
  145. if ($querytype == 'select') {
  146. $notallow1 = "[^0-9a-z@\._-]{1,}(union|sleep|benchmark|load_file|outfile)[^0-9a-z@\.-]{1,}";
  147. if (preg_match("/".$notallow1."/i", $db_string)) {
  148. fputs(fopen($log_file, 'a+'), "$userIP||$getUrl||$db_string||SelectBreak\r\n");
  149. exit("<span>Safe Alert: Request Error step 1 !</span>");
  150. }
  151. }
  152. //完整的SQL检查
  153. while (TRUE) {
  154. $pos = strpos($db_string, '\'', $pos + 1);
  155. if ($pos === FALSE) {
  156. break;
  157. }
  158. $clean .= substr($db_string, $old_pos, $pos - $old_pos);
  159. while (TRUE) {
  160. $pos1 = strpos($db_string, '\'', $pos + 1);
  161. $pos2 = strpos($db_string, '\\', $pos + 1);
  162. if ($pos1 === FALSE) {
  163. break;
  164. } elseif ($pos2 == FALSE || $pos2 > $pos1) {
  165. $pos = $pos1;
  166. break;
  167. }
  168. $pos = $pos2 + 1;
  169. }
  170. $clean .= '$s$';
  171. $old_pos = $pos + 1;
  172. }
  173. $clean .= substr($db_string, $old_pos);
  174. $clean = trim(strtolower(preg_replace(array('~\s+~s'), array(' '), $clean)));
  175. if (
  176. strpos($clean, '@') !== FALSE or strpos($clean, 'char(') !== FALSE or strpos($clean, '"') !== FALSE
  177. or strpos($clean, '$s$$s$') !== FALSE
  178. ) {
  179. $fail = TRUE;
  180. if (preg_match("#^create table#i", $clean)) $fail = FALSE;
  181. $error = "unusual character";
  182. }
  183. //老版本数据库不支持union,程序不使用union,但黑客使用它,所以检查它
  184. if (strpos($clean, 'union') !== FALSE && preg_match('~(^|[^a-z])union($|[^[a-z])~s', $clean) != 0) {
  185. $fail = TRUE;
  186. $error = "union detect";
  187. }
  188. //发布版本的程序比较少包括--,#这样的注释,但黑客经常使用它们
  189. elseif (strpos($clean, '/*') > 2 || strpos($clean, '--') !== FALSE || strpos($clean, '#') !== FALSE) {
  190. $fail = TRUE;
  191. $error = "comment detect";
  192. }
  193. //这些函数不会被使用,但是黑客会用它来操作文件,down掉数据库
  194. elseif (strpos($clean, 'sleep') !== FALSE && preg_match('~(^|[^a-z])sleep($|[^[a-z])~s', $clean) != 0) {
  195. $fail = TRUE;
  196. $error = "slown down detect";
  197. } elseif (strpos($clean, 'benchmark') !== FALSE && preg_match('~(^|[^a-z])benchmark($|[^[a-z])~s', $clean) != 0) {
  198. $fail = TRUE;
  199. $error = "slown down detect";
  200. } elseif (strpos($clean, 'load_file') !== FALSE && preg_match('~(^|[^a-z])load_file($|[^[a-z])~s', $clean) != 0) {
  201. $fail = TRUE;
  202. $error = "file fun detect";
  203. } elseif (strpos($clean, 'into outfile') !== FALSE && preg_match('~(^|[^a-z])into\s+outfile($|[^[a-z])~s', $clean) != 0) {
  204. $fail = TRUE;
  205. $error = "file fun detect";
  206. }
  207. //老版本数据库不支持子查询,该功能也用得少,但黑客可以使用它来查询数据库敏感信息
  208. elseif (preg_match('~\([^)]*?select~s', $clean) != 0) {
  209. $fail = TRUE;
  210. $error = "sub select detect";
  211. }
  212. if (!empty($fail)) {
  213. fputs(fopen($log_file, 'a+'), "$userIP||$getUrl||$db_string||$error\r\n");
  214. exit("<span>Safe Alert: Request Error step 2!</span>");
  215. } else {
  216. return $db_string;
  217. }
  218. }
  219. }
  220. /**
  221. * 载入助手,系统默认载入助手示例
  222. * <code>
  223. * if (!function_exists('HelloDede'))
  224. * {
  225. * function HelloDede()
  226. * {
  227. * echo "Hello! Dede";
  228. * }
  229. * }
  230. * </code>
  231. * 开发中使用这个助手的时候直接使用函数helper('test');初始化它,然后在文件中就可以直接使用:HelloDede();调用
  232. *
  233. * @access public
  234. * @param mix $helpers 助手名称,可以是数组,可以是单个字符串
  235. * @return void
  236. */
  237. $_helpers = array();
  238. function helper($helpers)
  239. {
  240. //如果是数组,则进行递归操作
  241. if (is_array($helpers)) {
  242. foreach ($helpers as $dede) {
  243. helper($dede);
  244. }
  245. return;
  246. }
  247. if (isset($_helpers[$helpers])) {
  248. return;
  249. }
  250. if (file_exists(DEDEINC.'/helpers/'.$helpers.'.helper.php')) {
  251. include_once(DEDEINC.'/helpers/'.$helpers.'.helper.php');
  252. $_helpers[$helpers] = TRUE;
  253. }
  254. //无法载入助手
  255. if (!isset($_helpers[$helpers])) {
  256. exit('Unable to load the requested file: helpers/'.$helpers.'.helper.php');
  257. }
  258. }
  259. function dede_htmlspecialchars($str)
  260. {
  261. global $cfg_soft_lang;
  262. if (version_compare(PHP_VERSION, '5.4.0', '<')) return htmlspecialchars($str);
  263. if ($cfg_soft_lang == 'gb2312') return htmlspecialchars($str, ENT_COMPAT, 'ISO-8859-1');
  264. else return htmlspecialchars($str);
  265. }
  266. /**
  267. * 载入助手,这里会员载入用helps载入多个助手
  268. *
  269. * @access public
  270. * @param string
  271. * @return void
  272. */
  273. function helpers($helpers)
  274. {
  275. helper($helpers);
  276. }
  277. //兼容php4的file_put_contents
  278. if (!function_exists('file_put_contents')) {
  279. function file_put_contents($n, $d)
  280. {
  281. $f = @fopen($n, "w");
  282. if (!$f) {
  283. return FALSE;
  284. } else {
  285. fwrite($f, $d);
  286. fclose($f);
  287. return TRUE;
  288. }
  289. }
  290. }
  291. /**
  292. * 短消息函数,可以在某个动作处理后友好的系统提示
  293. *
  294. * @param string $msg 消息系统提示
  295. * @param string $gourl 跳转地址
  296. * @param int $onlymsg 仅显示信息
  297. * @param int $limittime 限制时间
  298. * @param string $btnmsg 按钮提示
  299. * @param string $target 跳转类型
  300. * @return void
  301. */
  302. function ShowMsg($msg, $gourl, $onlymsg = 0, $limittime = 0)
  303. {
  304. if (defined('DEDE_DIALOG_UPLOAD') && !isset($GLOBALS['noeditor'])) {
  305. echo json_encode(array(
  306. "uploaded"=>0,
  307. "error"=>array(
  308. "message" => $msg,
  309. ),
  310. ));
  311. return;
  312. }
  313. if (isset($GLOBALS['format']) && strtolower($GLOBALS['format'])==='json') {
  314. echo json_encode(array(
  315. "code"=>0,
  316. "msg"=>$msg,
  317. "gourl"=>$gourl,
  318. ));
  319. return;
  320. }
  321. if (empty($GLOBALS['cfg_plus_dir'])) $GLOBALS['cfg_plus_dir'] = '..';
  322. $htmlhead = "<!DOCTYPE html><html><head><meta charset='utf-8'><meta http-equiv='X-UA-Compatible' content='IE=Edge,chrome=1'><meta name='viewport' content='width=device-width,initial-scale=1'><title>系统提示</title><link rel='stylesheet' href='/static/web/css/bootstrap.min.css'><link rel='stylesheet' href='/static/web/css/admin.css'></head><base target='_self'><body>";
  323. $htmlfoot = "</body></html>";
  324. $litime = ($limittime == 0 ? 1000 : $limittime);
  325. $func = '';
  326. if ($gourl == '-1') {
  327. if ($limittime == 0) $litime = 3000;
  328. $gourl = "javascript:history.go(-1);";
  329. }
  330. if ($gourl == '' || $onlymsg == 1) {
  331. $msg = "<script>alert(\"".str_replace("\"", "“", $msg)."\");</script>";
  332. } else {
  333. //当网址为:close::objname时,关闭父框架的id=objname元素
  334. if (preg_match('/close::/', $gourl)) {
  335. $tgobj = trim(preg_replace('/close::/', '', $gourl));
  336. $gourl = 'javascript:;';
  337. $func .= "<script>window.parent.document.getElementById('{$tgobj}').style.display='none';</script>";
  338. }
  339. $func .= "<script>var pgo=0;function JumpUrl(){if (pgo==0) {location='$gourl'; pgo=1;}}</script>";
  340. $rmsg = $func;
  341. $rmsg .= "<div class='tips'><div class='tips-box'><div class='tips-head'><p>系统提示</p></div>";
  342. $rmsg .= "<div class='tips-body'>";
  343. $rmsg .= "".str_replace("\"", "“", $msg)."";
  344. $rmsg .= "";
  345. if ($onlymsg == 0) {
  346. if ($gourl != 'javascript:;' && $gourl != '') {
  347. $rmsg .= "<div class='text-center mt-3'><a href='{$gourl}' class='btn btn-success btn-sm'>点击反应</a></div>";
  348. $rmsg .= "<script>setTimeout('JumpUrl()', $litime);</script>";
  349. } else {
  350. $rmsg .= "</div>";
  351. }
  352. } else {
  353. $rmsg .= "</div></div>";
  354. }
  355. $msg = $htmlhead.$rmsg.$htmlfoot;
  356. }
  357. echo $msg;
  358. }
  359. /**
  360. * 表中是否存在某个字段
  361. *
  362. * @param mixed $tablename 表名称
  363. * @param mixed $field 字段名
  364. * @return void
  365. */
  366. function TableHasField($tablename, $field)
  367. {
  368. global $dsql;
  369. $dsql->GetTableFields($tablename,"tfd");
  370. while ($r = $dsql->GetFieldObject("tfd")) {
  371. if ($r->name === $field) {
  372. return true;
  373. }
  374. }
  375. return false;
  376. }
  377. function GetSimpleServerSoftware()
  378. {
  379. if (preg_match("#^php#i",$_SERVER["SERVER_SOFTWARE"])) {
  380. return 'PHP Server';
  381. } else if (preg_match("#^apache#i",$_SERVER["SERVER_SOFTWARE"])){
  382. return 'Apache';
  383. } else if (preg_match("#^nginx#i",$_SERVER["SERVER_SOFTWARE"])){
  384. return 'Nginx';
  385. } else if (preg_match("#^microsoft-iis#i",$_SERVER["SERVER_SOFTWARE"])){
  386. return 'IIS';
  387. } else if (preg_match("#^caddy#i",$_SERVER["SERVER_SOFTWARE"])){
  388. return 'Caddy';
  389. } else {
  390. return 'Other';
  391. }
  392. }
  393. /**
  394. * 获取验证码的session值
  395. *
  396. * @return string
  397. */
  398. function GetCkVdValue()
  399. {
  400. @session_id($_COOKIE['PHPSESSID']);
  401. @session_start();
  402. return isset($_SESSION['securimage_code_value']) ? $_SESSION['securimage_code_value'] : '';
  403. }
  404. /**
  405. * PHP某些版本有Bug,不能在同一作用域中同时读session并改注销它,因此调用后需执行本函数
  406. *
  407. * @return void
  408. */
  409. function ResetVdValue()
  410. {
  411. @session_start();
  412. $_SESSION['securimage_code_value'] = '';
  413. }
  414. function IndexSub($idx, $num)
  415. {
  416. return intval($idx) - intval($num) == 0 ? '0 ' : intval($idx) - intval($num);
  417. }
  418. /**
  419. * HideEmail隐藏邮箱
  420. *
  421. * @param mixed $email
  422. * @return string
  423. */
  424. function HideEmail($email)
  425. {
  426. if (empty($email)) return "暂无";
  427. $em = explode("@",$email);
  428. $name = implode('@', array_slice($em, 0, count($em)-1));
  429. $len = floor(strlen($name)/2);
  430. return substr($name,0, $len).str_repeat('*', $len)."@".end($em);
  431. }
  432. //用来返回index的active
  433. function IndexActive($idx)
  434. {
  435. if ($idx == 1) {
  436. return ' active';
  437. } else {
  438. return '';
  439. }
  440. }
  441. //是否是HTTPS
  442. function IsSSL()
  443. {
  444. if (@$_SERVER['HTTPS'] && ('1' == $_SERVER['HTTPS'] || 'on' == strtolower($_SERVER['HTTPS']))) {
  445. return true;
  446. } elseif ('https' == @$_SERVER['REQUEST_SCHEME']) {
  447. return true;
  448. } elseif ('443' == $_SERVER['SERVER_PORT']) {
  449. return true;
  450. } elseif ('https' == @$_SERVER['HTTP_X_FORWARDED_PROTO']) {
  451. return true;
  452. }
  453. return false;
  454. }
  455. //获取对应版本号的更新SQL
  456. function GetUpdateSQL()
  457. {
  458. global $cfg_dbprefix, $cfg_dbtype, $cfg_db_language;
  459. $result = array();
  460. $query = '';
  461. $sql4tmp = "ENGINE=MyISAM DEFAULT CHARSET=".$cfg_db_language;
  462. $fp = fopen(DEDEROOT.'/install/update.txt','r');
  463. $sqls = array();
  464. $current_ver = '';
  465. while(!feof($fp))
  466. {
  467. $line = rtrim(fgets($fp,1024));
  468. if (preg_match("/\-\- ([\d\.]+)/",$line,$matches)) {
  469. if (count($sqls) > 0) {
  470. $result[$current_ver] = $sqls;
  471. }
  472. $sqls = array();
  473. $current_ver = $matches[1];
  474. }
  475. if (preg_match("#;$#", $line)) {
  476. $query .= $line."\n";
  477. $query = str_replace('#@__',$cfg_dbprefix,$query);
  478. if ($cfg_dbtype == 'sqlite') {
  479. $query = preg_replace('/character set (.*?) /i','',$query);
  480. $query = preg_replace('/unsigned/i','',$query);
  481. $query = str_replace('TYPE=MyISAM','',$query);
  482. $query = preg_replace ('/TINYINT\(([\d]+)\)/i','INTEGER',$query);
  483. $query = preg_replace ('/mediumint\(([\d]+)\)/i','INTEGER',$query);
  484. $query = preg_replace ('/smallint\(([\d]+)\)/i','INTEGER',$query);
  485. $query = preg_replace('/int\(([\d]+)\)/i','INTEGER',$query);
  486. $query = preg_replace('/auto_increment/i','PRIMARY KEY AUTOINCREMENT',$query);
  487. $query = preg_replace('/,([\t\s ]+)KEY(.*?)MyISAM;/','',$query);
  488. $query = preg_replace('/,([\t\s ]+)KEY(.*?);/',');',$query);
  489. $query = preg_replace('/,([\t\s ]+)UNIQUE KEY(.*?);/',');',$query);
  490. $query = preg_replace('/set\(([^\)]*?)\)/','varchar',$query);
  491. $query = preg_replace('/enum\(([^\)]*?)\)/','varchar',$query);
  492. if (preg_match("/PRIMARY KEY AUTOINCREMENT/",$query)) {
  493. $query = preg_replace('/,([\t\s ]+)PRIMARY KEY([\t\s ]+)\(`([0-9a-zA-Z]+)`\)/i','',$query);
  494. }
  495. $sqls[] = $query;
  496. } else {
  497. if (preg_match('#CREATE#i', $query)) {
  498. $sqls[] = preg_replace("#TYPE=MyISAM#i",$sql4tmp,$query);
  499. } else {
  500. $sqls[] = $query;
  501. }
  502. }
  503. $query='';
  504. } else if (!preg_match("#^(\/\/|--)#", $line)) {
  505. $query .= $line;
  506. }
  507. }
  508. if (count($sqls) > 0) {
  509. $result[$current_ver] = $sqls;
  510. }
  511. fclose($fp);
  512. return $result;
  513. }
  514. /**
  515. * GetMimeTypeOrExtension
  516. *
  517. * @param mixed $str 字符串
  518. * @param mixed $t 类型,0获取mime type,1获取扩展名
  519. * @return string
  520. */
  521. function GetMimeTypeOrExtension($str, $t = 0) {
  522. $mime_types = array(
  523. 'aac' => 'audio/aac',
  524. 'abw' => 'application/x-abiword',
  525. 'arc' => 'application/x-freearc',
  526. 'avi' => 'video/x-msvideo',
  527. 'azw' => 'application/vnd.amazon.ebook',
  528. 'bin' => 'application/octet-stream',
  529. 'bmp' => 'image/bmp',
  530. 'bz' => 'application/x-bzip',
  531. 'bz2' => 'application/x-bzip2',
  532. 'csh' => 'application/x-csh',
  533. 'css' => 'text/css',
  534. 'csv' => 'text/csv',
  535. 'doc' => 'application/msword',
  536. 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
  537. 'eot' => 'application/vnd.ms-fontobject',
  538. 'epub' => 'application/epub+zip',
  539. 'gif' => 'image/gif',
  540. 'htm' => 'text/html',
  541. 'html' => 'text/html',
  542. 'ico' => 'image/vnd.microsoft.icon',
  543. 'ics' => 'text/calendar',
  544. 'jar' => 'application/java-archive',
  545. 'jpeg' => 'image/jpeg',
  546. 'jpg' => 'image/jpeg',
  547. 'js' => 'text/javascript',
  548. 'json' => 'application/json',
  549. 'jsonld' => 'application/ld+json',
  550. 'mid' => 'audio/midi',
  551. 'midi' => 'audio/midi',
  552. 'mjs' => 'text/javascript',
  553. 'mp3' => 'audio/mpeg',
  554. 'mp4' => 'video/mp4',
  555. 'mpeg' => 'video/mpeg',
  556. 'mpkg' => 'application/vnd.apple.installer+xml',
  557. 'odp' => 'application/vnd.oasis.opendocument.presentation',
  558. 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
  559. 'odt' => 'application/vnd.oasis.opendocument.text',
  560. 'oga' => 'audio/ogg',
  561. 'ogv' => 'video/ogg',
  562. 'ogx' => 'application/ogg',
  563. 'otf' => 'font/otf',
  564. 'png' => 'image/png',
  565. 'pdf' => 'application/pdf',
  566. 'ppt' => 'application/vnd.ms-powerpoint',
  567. 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
  568. 'rar' => 'application/x-rar-compressed',
  569. 'rtf' => 'application/rtf',
  570. 'sh' => 'application/x-sh',
  571. 'svg' => 'image/svg+xml',
  572. 'swf' => 'application/x-shockwave-flash',
  573. 'tar' => 'application/x-tar',
  574. 'tif' => 'image/tiff',
  575. 'tiff' => 'image/tiff',
  576. 'ttf' => 'font/ttf',
  577. 'txt' => 'text/plain',
  578. 'vsd' => 'application/vnd.visio',
  579. 'wav' => 'audio/wav',
  580. 'weba' => 'audio/webm',
  581. 'webm' => 'video/webm',
  582. 'webp' => 'image/webp',
  583. 'woff' => 'font/woff',
  584. 'woff2' => 'font/woff2',
  585. 'xhtml' => 'application/xhtml+xml',
  586. 'xls' => 'application/vnd.ms-excel',
  587. 'xlsx' => 'application/vnd.ms-excel',
  588. 'xml' => 'application/xml',
  589. 'xul' => 'application/vnd.mozilla.xul+xml',
  590. 'zip' => 'application/zip',
  591. '3gp' => 'video/3gpp',
  592. '3g2' => 'video/3gpp2',
  593. '7z' => 'application/x-7z-compressed',
  594. 'wmv' => 'video/x-ms-asf',
  595. 'wma' => 'audio/x-ms-wma',
  596. 'mov' => 'video/quicktime',
  597. 'rm' => 'application/vnd.rn-realmedia',
  598. 'mpg' => 'video/mpeg',
  599. 'mpga' => 'audio/mpeg',
  600. );
  601. if ($t===0) {
  602. return isset($mime_types[$str])? $mime_types[$str] : 'application/octet-stream';
  603. } else {
  604. foreach ($mime_types as $key => $value) {
  605. if ($value == $str) return $key;
  606. }
  607. return "dedebiz";
  608. }
  609. }
  610. //自定义函数接口
  611. if (file_exists(DEDEINC.'/extend.func.php')) {
  612. require_once(DEDEINC.'/extend.func.php');
  613. }
  614. ?>