common.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716
  1. <?php
  2. // 公共助手函数
  3. use think\exception\HttpResponseException;
  4. use think\Response;
  5. use app\common\Service\ShopConfigService;
  6. use app\common\exception\BusinessException;
  7. if (!function_exists('shop_config')) {
  8. /**
  9. * 获取SheepAdmin配置
  10. * @param string $code 配置名
  11. * @return string
  12. */
  13. function shop_config(string $code, $cache = true)
  14. {
  15. return ShopConfigService::getConfigs($code, $cache);
  16. }
  17. }
  18. /**
  19. * 获取前端用户
  20. */
  21. if (!function_exists('auth_user')) {
  22. function auth_user($throwException = false)
  23. {
  24. if (\app\common\library\Auth::instance()->isLogin()) {
  25. return \app\common\library\Auth::instance()->getUser();
  26. }
  27. if ($throwException) {
  28. throw new BusinessException('请登录后操作');
  29. }
  30. return null;
  31. }
  32. }
  33. /**
  34. * 获取管理员信息
  35. */
  36. if (!function_exists('auth_admin')) {
  37. function auth_admin()
  38. {
  39. if (\app\admin\library\Auth::instance()->isLogin()) {
  40. $admin = \app\admin\library\Auth::instance()->getUserInfo(); // 这里获取的是个数组,转为模型
  41. if ($admin) {
  42. return \app\admin\model\Admin::where('id', $admin['id'])->find();
  43. }
  44. }
  45. return null;
  46. }
  47. }
  48. if (!function_exists('string_hide')) {
  49. /**
  50. * 隐藏部分字符串
  51. *
  52. * @param string $string 原始字符串
  53. * @param int $start 开始位置
  54. * @return string
  55. */
  56. function string_hide($string, $start = 2)
  57. {
  58. if (mb_strlen($string) > $start) {
  59. $hide = mb_substr($string, 0, $start) . '***';
  60. } else {
  61. $hide = $string . '***';
  62. }
  63. return $hide;
  64. }
  65. }
  66. if (!function_exists('morph_to')) {
  67. /**
  68. * 多态关联
  69. *
  70. * @param array|object $items
  71. * @param array $morphs
  72. * @param array $fields
  73. * @return array|object
  74. */
  75. function morph_to($items, $morphs, $fields)
  76. {
  77. if ($items instanceof \think\Paginator) {
  78. $data = $items->items();
  79. } else if ($items instanceof \think\Collection) {
  80. $data = $items;
  81. } else {
  82. $data = collection($items);
  83. }
  84. $allIds = [];
  85. foreach ($data as $item) {
  86. $allIds[$item[$fields[0]]][] = $item[$fields[1]];
  87. }
  88. $morphsData = [];
  89. foreach ($allIds as $key => $ids) {
  90. $morphData = (new $morphs[$key])::where('id', 'in', $ids)->select();
  91. $morphsData[$key] = array_column($morphData, null, 'id');
  92. }
  93. $morph_key = strstr($fields[0], '_', true);
  94. foreach ($data as &$item) {
  95. $item->{$morph_key} = $morphsData[$item[$fields[0]]][$item[$fields[1]]] ?? null;
  96. }
  97. if ($items instanceof \think\Paginator) {
  98. $items->data = $items;
  99. } else {
  100. $items = $data;
  101. }
  102. return $items;
  103. }
  104. }
  105. if (!function_exists('account_hide')) {
  106. /**
  107. * 隐藏账号部分字符串
  108. *
  109. * @param string $string 原始字符串
  110. * @param int $start 开始位置
  111. * @param int $end 开始位置
  112. * @return string
  113. */
  114. function account_hide($string, $start = 2, $end = 2)
  115. {
  116. $hide = mb_substr($string, 0, $start) . '*****' . mb_substr($string, -$end);
  117. return $hide;
  118. }
  119. }
  120. if (!function_exists('get_sn')) {
  121. /**
  122. * 获取唯一编号
  123. *
  124. * @param mixed $id 唯一标识
  125. * @param string $type 类型
  126. * @return string
  127. */
  128. function get_sn($id, $type = '')
  129. {
  130. $id = (string)$id;
  131. $rand = $id < 9999 ? mt_rand(100000, 99999999) : mt_rand(100, 99999);
  132. $sn = date('Yhis') . $rand;
  133. $id = str_pad($id, (24 - strlen($sn)), '0', STR_PAD_BOTH);
  134. return $type . $sn . $id;
  135. }
  136. }
  137. /**
  138. * @notes 随机生成邀请码
  139. * @param $length
  140. * @return string
  141. * @author Tab
  142. * @date 2021/7/26 11:17
  143. */
  144. function generate_code($length = 6)
  145. {
  146. // 去除字母IO数字012
  147. $letters = 'ABCDEFGHJKLMNPQRSTUVWXYZ3456789';
  148. // 随机起始索引
  149. $start = mt_rand(0, strlen($letters) - $length);
  150. // 打乱字符串
  151. $shuffleStr = str_shuffle($letters);
  152. // 截取字符
  153. $randomStr = substr($shuffleStr, $start, $length);
  154. // 判断是否已被使用
  155. $user = \app\common\model\User::where('code', $randomStr)->findOrEmpty();
  156. if($user->isEmpty()) {
  157. return $randomStr;
  158. }
  159. generate_code($length);
  160. }
  161. if (!function_exists('format_log_error')) {
  162. /**
  163. * 格式化记录日志,重要地方使用
  164. *
  165. * @param object $error
  166. * @param string $name
  167. * @param string $message
  168. * @return void
  169. */
  170. function format_log_error($error, $name = 'QUEUE', $message = '')
  171. {
  172. $logInfo = [
  173. "========== $name LOG INFO BEGIN ==========",
  174. '[ Message ] ' . var_export('[' . $error->getCode() . ']' . $error->getMessage() . ' ' . $message, true),
  175. '[ File ] ' . var_export($error->getFile() . ':' . $error->getLine(), true),
  176. '[ Trace ] ' . var_export($error->getTraceAsString(), true),
  177. "============================================= $name LOG INFO ENDED ==========",
  178. ];
  179. $logInfo = implode(PHP_EOL, $logInfo) . PHP_EOL;
  180. \think\Log::error($logInfo);
  181. }
  182. }
  183. if (!function_exists('__')) {
  184. /**
  185. * 获取语言变量值
  186. * @param string $name 语言变量名
  187. * @param string | array $vars 动态变量值
  188. * @param string $lang 语言
  189. * @return mixed
  190. */
  191. function __($name, $vars = [], $lang = '')
  192. {
  193. if (is_numeric($name) || !$name) {
  194. return $name;
  195. }
  196. if (!is_array($vars)) {
  197. $vars = func_get_args();
  198. array_shift($vars);
  199. $lang = '';
  200. }
  201. return \think\Lang::get($name, $vars, $lang);
  202. }
  203. }
  204. if (!function_exists('format_bytes')) {
  205. /**
  206. * 将字节转换为可读文本
  207. * @param int $size 大小
  208. * @param string $delimiter 分隔符
  209. * @param int $precision 小数位数
  210. * @return string
  211. */
  212. function format_bytes($size, $delimiter = '', $precision = 2)
  213. {
  214. $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
  215. for ($i = 0; $size >= 1024 && $i < 5; $i++) {
  216. $size /= 1024;
  217. }
  218. return round($size, $precision) . $delimiter . $units[$i];
  219. }
  220. }
  221. if (!function_exists('datetime')) {
  222. /**
  223. * 将时间戳转换为日期时间
  224. * @param int $time 时间戳
  225. * @param string $format 日期时间格式
  226. * @return string
  227. */
  228. function datetime($time, $format = 'Y-m-d H:i:s')
  229. {
  230. $time = is_numeric($time) ? $time : strtotime($time);
  231. return date($format, $time);
  232. }
  233. }
  234. if (!function_exists('human_date')) {
  235. /**
  236. * 获取语义化时间
  237. * @param int $time 时间
  238. * @param int $local 本地时间
  239. * @return string
  240. */
  241. function human_date($time, $local = null)
  242. {
  243. return \fast\Date::human($time, $local);
  244. }
  245. }
  246. if (!function_exists('cdnurl')) {
  247. /**
  248. * 获取上传资源的CDN的地址
  249. * @param string $url 资源相对地址
  250. * @param boolean $domain 是否显示域名 或者直接传入域名
  251. * @return string
  252. */
  253. function cdnurl($url, $domain = false)
  254. {
  255. $regex = "/^((?:[a-z]+:)?\/\/|data:image\/)(.*)/i";
  256. $cdnurl = \think\Config::get('upload.cdnurl');
  257. if (is_bool($domain) || stripos($cdnurl, '/') === 0) {
  258. $url = preg_match($regex, $url) || ($cdnurl && stripos($url, $cdnurl) === 0) ? $url : $cdnurl . $url;
  259. }
  260. if ($domain && !preg_match($regex, $url)) {
  261. $domain = is_bool($domain) ? request()->domain() : $domain;
  262. $url = $domain . $url;
  263. }
  264. return $url;
  265. }
  266. }
  267. if (!function_exists('is_really_writable')) {
  268. /**
  269. * 判断文件或文件夹是否可写
  270. * @param string $file 文件或目录
  271. * @return bool
  272. */
  273. function is_really_writable($file)
  274. {
  275. if (DIRECTORY_SEPARATOR === '/') {
  276. return is_writable($file);
  277. }
  278. if (is_dir($file)) {
  279. $file = rtrim($file, '/') . '/' . md5(mt_rand());
  280. if (($fp = @fopen($file, 'ab')) === false) {
  281. return false;
  282. }
  283. fclose($fp);
  284. @chmod($file, 0777);
  285. @unlink($file);
  286. return true;
  287. } elseif (!is_file($file) or ($fp = @fopen($file, 'ab')) === false) {
  288. return false;
  289. }
  290. fclose($fp);
  291. return true;
  292. }
  293. }
  294. if (!function_exists('rmdirs')) {
  295. /**
  296. * 删除文件夹
  297. * @param string $dirname 目录
  298. * @param bool $withself 是否删除自身
  299. * @return boolean
  300. */
  301. function rmdirs($dirname, $withself = true)
  302. {
  303. if (!is_dir($dirname)) {
  304. return false;
  305. }
  306. $files = new RecursiveIteratorIterator(
  307. new RecursiveDirectoryIterator($dirname, RecursiveDirectoryIterator::SKIP_DOTS),
  308. RecursiveIteratorIterator::CHILD_FIRST
  309. );
  310. foreach ($files as $fileinfo) {
  311. $todo = ($fileinfo->isDir() ? 'rmdir' : 'unlink');
  312. $todo($fileinfo->getRealPath());
  313. }
  314. if ($withself) {
  315. @rmdir($dirname);
  316. }
  317. return true;
  318. }
  319. }
  320. if (!function_exists('copydirs')) {
  321. /**
  322. * 复制文件夹
  323. * @param string $source 源文件夹
  324. * @param string $dest 目标文件夹
  325. */
  326. function copydirs($source, $dest)
  327. {
  328. if (!is_dir($dest)) {
  329. mkdir($dest, 0755, true);
  330. }
  331. foreach (
  332. $iterator = new RecursiveIteratorIterator(
  333. new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
  334. RecursiveIteratorIterator::SELF_FIRST
  335. ) as $item
  336. ) {
  337. if ($item->isDir()) {
  338. $sontDir = $dest . DS . $iterator->getSubPathName();
  339. if (!is_dir($sontDir)) {
  340. mkdir($sontDir, 0755, true);
  341. }
  342. } else {
  343. copy($item, $dest . DS . $iterator->getSubPathName());
  344. }
  345. }
  346. }
  347. }
  348. if (!function_exists('mb_ucfirst')) {
  349. function mb_ucfirst($string)
  350. {
  351. return mb_strtoupper(mb_substr($string, 0, 1)) . mb_strtolower(mb_substr($string, 1));
  352. }
  353. }
  354. if (!function_exists('addtion')) {
  355. /**
  356. * 附加关联字段数据
  357. * @param array $items 数据列表
  358. * @param mixed $fields 渲染的来源字段
  359. * @return array
  360. */
  361. function addtion($items, $fields)
  362. {
  363. if (!$items || !$fields) {
  364. return $items;
  365. }
  366. $fieldsArr = [];
  367. if (!is_array($fields)) {
  368. $arr = explode(',', $fields);
  369. foreach ($arr as $k => $v) {
  370. $fieldsArr[$v] = ['field' => $v];
  371. }
  372. } else {
  373. foreach ($fields as $k => $v) {
  374. if (is_array($v)) {
  375. $v['field'] = $v['field'] ?? $k;
  376. } else {
  377. $v = ['field' => $v];
  378. }
  379. $fieldsArr[$v['field']] = $v;
  380. }
  381. }
  382. foreach ($fieldsArr as $k => &$v) {
  383. $v = is_array($v) ? $v : ['field' => $v];
  384. $v['display'] = $v['display'] ?? str_replace(['_ids', '_id'], ['_names', '_name'], $v['field']);
  385. $v['primary'] = $v['primary'] ?? '';
  386. $v['column'] = $v['column'] ?? 'name';
  387. $v['model'] = $v['model'] ?? '';
  388. $v['table'] = $v['table'] ?? '';
  389. $v['name'] = $v['name'] ?? str_replace(['_ids', '_id'], '', $v['field']);
  390. }
  391. unset($v);
  392. $ids = [];
  393. $fields = array_keys($fieldsArr);
  394. foreach ($items as $k => $v) {
  395. foreach ($fields as $m => $n) {
  396. if (isset($v[$n])) {
  397. $ids[$n] = array_merge(isset($ids[$n]) && is_array($ids[$n]) ? $ids[$n] : [], explode(',', $v[$n]));
  398. }
  399. }
  400. }
  401. $result = [];
  402. foreach ($fieldsArr as $k => $v) {
  403. if ($v['model']) {
  404. $model = new $v['model'];
  405. } else {
  406. // 优先判断使用table的配置
  407. $model = $v['table'] ? \think\Db::table($v['table']) : \think\Db::name($v['name']);
  408. }
  409. $primary = $v['primary'] ?: $model->getPk();
  410. $result[$v['field']] = isset($ids[$v['field']]) ? $model->where($primary, 'in', $ids[$v['field']])->column($v['column'], $primary) : [];
  411. }
  412. foreach ($items as $k => &$v) {
  413. foreach ($fields as $m => $n) {
  414. if (isset($v[$n])) {
  415. $curr = array_flip(explode(',', $v[$n]));
  416. $linedata = array_intersect_key($result[$n], $curr);
  417. $v[$fieldsArr[$n]['display']] = $fieldsArr[$n]['column'] == '*' ? $linedata : implode(',', $linedata);
  418. }
  419. }
  420. }
  421. return $items;
  422. }
  423. }
  424. if (!function_exists('var_export_short')) {
  425. /**
  426. * 使用短标签打印或返回数组结构
  427. * @param mixed $data
  428. * @param boolean $return 是否返回数据
  429. * @return string
  430. */
  431. function var_export_short($data, $return = true)
  432. {
  433. return var_export($data, $return);
  434. }
  435. }
  436. if (!function_exists('letter_avatar')) {
  437. /**
  438. * 首字母头像
  439. * @param $text
  440. * @return string
  441. */
  442. function letter_avatar($text)
  443. {
  444. $total = unpack('L', hash('adler32', $text, true))[1];
  445. $hue = $total % 360;
  446. list($r, $g, $b) = hsv2rgb($hue / 360, 0.3, 0.9);
  447. $bg = "rgb({$r},{$g},{$b})";
  448. $color = "#ffffff";
  449. $first = mb_strtoupper(mb_substr($text, 0, 1));
  450. $src = base64_encode('<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="100" width="100"><rect fill="' . $bg . '" x="0" y="0" width="100" height="100"></rect><text x="50" y="50" font-size="50" text-copy="fast" fill="' . $color . '" text-anchor="middle" text-rights="admin" dominant-baseline="central">' . $first . '</text></svg>');
  451. $value = 'data:image/svg+xml;base64,' . $src;
  452. return $value;
  453. }
  454. }
  455. if (!function_exists('hsv2rgb')) {
  456. function hsv2rgb($h, $s, $v)
  457. {
  458. $r = $g = $b = 0;
  459. $i = floor($h * 6);
  460. $f = $h * 6 - $i;
  461. $p = $v * (1 - $s);
  462. $q = $v * (1 - $f * $s);
  463. $t = $v * (1 - (1 - $f) * $s);
  464. switch ($i % 6) {
  465. case 0:
  466. $r = $v;
  467. $g = $t;
  468. $b = $p;
  469. break;
  470. case 1:
  471. $r = $q;
  472. $g = $v;
  473. $b = $p;
  474. break;
  475. case 2:
  476. $r = $p;
  477. $g = $v;
  478. $b = $t;
  479. break;
  480. case 3:
  481. $r = $p;
  482. $g = $q;
  483. $b = $v;
  484. break;
  485. case 4:
  486. $r = $t;
  487. $g = $p;
  488. $b = $v;
  489. break;
  490. case 5:
  491. $r = $v;
  492. $g = $p;
  493. $b = $q;
  494. break;
  495. }
  496. return [
  497. floor($r * 255),
  498. floor($g * 255),
  499. floor($b * 255)
  500. ];
  501. }
  502. }
  503. if (!function_exists('check_nav_active')) {
  504. /**
  505. * 检测会员中心导航是否高亮
  506. */
  507. function check_nav_active($url, $classname = 'active')
  508. {
  509. $auth = \app\common\library\Auth::instance();
  510. $requestUrl = $auth->getRequestUri();
  511. $url = ltrim($url, '/');
  512. return $requestUrl === str_replace(".", "/", $url) ? $classname : '';
  513. }
  514. }
  515. if (!function_exists('check_cors_request')) {
  516. /**
  517. * 跨域检测
  518. */
  519. function check_cors_request()
  520. {
  521. if (isset($_SERVER['HTTP_ORIGIN']) && $_SERVER['HTTP_ORIGIN'] && config('fastadmin.cors_request_domain')) {
  522. $info = parse_url($_SERVER['HTTP_ORIGIN']);
  523. $domainArr = explode(',', config('fastadmin.cors_request_domain'));
  524. $domainArr[] = request()->host(true);
  525. if (in_array("*", $domainArr) || in_array($_SERVER['HTTP_ORIGIN'], $domainArr) || (isset($info['host']) && in_array($info['host'], $domainArr))) {
  526. header("Access-Control-Allow-Origin: " . $_SERVER['HTTP_ORIGIN']);
  527. } else {
  528. $response = Response::create('跨域检测无效', 'html', 403);
  529. throw new HttpResponseException($response);
  530. }
  531. header('Access-Control-Allow-Credentials: true');
  532. header('Access-Control-Max-Age: 86400');
  533. if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
  534. if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) {
  535. header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
  536. }
  537. if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
  538. header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
  539. }
  540. $response = Response::create('', 'html');
  541. throw new HttpResponseException($response);
  542. }
  543. }
  544. }
  545. }
  546. if (!function_exists('xss_clean')) {
  547. /**
  548. * 清理XSS
  549. */
  550. function xss_clean($content, $is_image = false)
  551. {
  552. return \app\common\library\Security::instance()->xss_clean($content, $is_image);
  553. }
  554. }
  555. if (!function_exists('url_clean')) {
  556. /**
  557. * 清理URL
  558. */
  559. function url_clean($url)
  560. {
  561. if (!check_url_allowed($url)) {
  562. return '';
  563. }
  564. return xss_clean($url);
  565. }
  566. }
  567. if (!function_exists('check_ip_allowed')) {
  568. /**
  569. * 检测IP是否允许
  570. * @param string $ip IP地址
  571. */
  572. function check_ip_allowed($ip = null)
  573. {
  574. $ip = is_null($ip) ? request()->ip() : $ip;
  575. $forbiddenipArr = config('site.forbiddenip');
  576. $forbiddenipArr = !$forbiddenipArr ? [] : $forbiddenipArr;
  577. $forbiddenipArr = is_array($forbiddenipArr) ? $forbiddenipArr : array_filter(explode("\n", str_replace("\r\n", "\n", $forbiddenipArr)));
  578. if ($forbiddenipArr && \Symfony\Component\HttpFoundation\IpUtils::checkIp($ip, $forbiddenipArr)) {
  579. $response = Response::create('请求无权访问', 'html', 403);
  580. throw new HttpResponseException($response);
  581. }
  582. }
  583. }
  584. if (!function_exists('check_url_allowed')) {
  585. /**
  586. * 检测URL是否允许
  587. * @param string $url URL
  588. * @return bool
  589. */
  590. function check_url_allowed($url = '')
  591. {
  592. //允许的主机列表
  593. $allowedHostArr = [
  594. strtolower(request()->host())
  595. ];
  596. if (empty($url)) {
  597. return true;
  598. }
  599. //如果是站内相对链接则允许
  600. if (preg_match("/^[\/a-z][a-z0-9][a-z0-9\.\/]+((\?|#).*)?\$/i", $url) && substr($url, 0, 2) !== '//') {
  601. return true;
  602. }
  603. //如果是站外链接则需要判断HOST是否允许
  604. if (preg_match("/((http[s]?:\/\/)+((?>[a-z\-0-9]{2,}\.)+[a-z]{2,8}|((?>([0-9]{1,3}\.)){3}[0-9]{1,3}))(:[0-9]{1,5})?)(?:\s|\/)/i", $url)) {
  605. $chkHost = parse_url(strtolower($url), PHP_URL_HOST);
  606. if ($chkHost && in_array($chkHost, $allowedHostArr)) {
  607. return true;
  608. }
  609. }
  610. return false;
  611. }
  612. }
  613. if (!function_exists('build_suffix_image')) {
  614. /**
  615. * 生成文件后缀图片
  616. * @param string $suffix 后缀
  617. * @param null $background
  618. * @return string
  619. */
  620. function build_suffix_image($suffix, $background = null)
  621. {
  622. $suffix = mb_substr(strtoupper($suffix), 0, 4);
  623. $total = unpack('L', hash('adler32', $suffix, true))[1];
  624. $hue = $total % 360;
  625. list($r, $g, $b) = hsv2rgb($hue / 360, 0.3, 0.9);
  626. $background = $background ? $background : "rgb({$r},{$g},{$b})";
  627. $icon = <<<EOT
  628. <svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 512 512" style="enable-background:new 0 0 512 512;" xml:space="preserve">
  629. <path style="fill:#E2E5E7;" d="M128,0c-17.6,0-32,14.4-32,32v448c0,17.6,14.4,32,32,32h320c17.6,0,32-14.4,32-32V128L352,0H128z"/>
  630. <path style="fill:#B0B7BD;" d="M384,128h96L352,0v96C352,113.6,366.4,128,384,128z"/>
  631. <polygon style="fill:#CAD1D8;" points="480,224 384,128 480,128 "/>
  632. <path style="fill:{$background};" d="M416,416c0,8.8-7.2,16-16,16H48c-8.8,0-16-7.2-16-16V256c0-8.8,7.2-16,16-16h352c8.8,0,16,7.2,16,16 V416z"/>
  633. <path style="fill:#CAD1D8;" d="M400,432H96v16h304c8.8,0,16-7.2,16-16v-16C416,424.8,408.8,432,400,432z"/>
  634. <g><text><tspan x="220" y="380" font-size="124" font-family="Verdana, Helvetica, Arial, sans-serif" fill="white" text-anchor="middle">{$suffix}</tspan></text></g>
  635. </svg>
  636. EOT;
  637. return $icon;
  638. }
  639. }