123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <?php
- if (!function_exists('auth')) {
-
- function auth($node)
- {
- return \app\admin\service\Auth::checkAuthNode($node);
- }
- }
- if (!function_exists('sysdata')) {
-
- function sysdata($name, array $value = null)
- {
- if (is_null($value)) {
- $data = json_decode(\think\Db::name('SystemData')->where('name', $name)->value('value'), true);
- return empty($data) ? [] : $data;
- }
- return data_save('SystemData', ['name' => $name, 'value' => json_encode($value, 256)], 'name');
- }
- }
- if (!function_exists('_sysmsg')) {
-
- function _sysmsg($title, $desc, $url, $node)
- {
- return \app\admin\service\Message::add($title, $desc, $url, $node);
- }
- }
- if (!function_exists('_syslog')) {
-
- function _syslog($action, $content)
- {
- return \app\admin\service\Log::write($action, $content);
- }
- }
- if (!function_exists('local_image')) {
-
- function local_image($url)
- {
- $result = \library\File::down($url);
- if (isset($result['url'])) return $result['url'];
- return $url;
- }
- }
- if (!function_exists('base64_image')) {
-
- function base64_image($content, $predir = 'base64/')
- {
- try {
- if (preg_match('|^data:image/(.*?);base64,|i', $content)) {
- list($ext, $base) = explode('|||', preg_replace('|^data:image/(.*?);base64,|i', '$1|||', $content));
- $info = \library\File::save($predir . md5($base) . '.' . (empty($ext) ? 'tmp' : $ext), base64_decode($base));
- return $info['url'];
- }
- return $content;
- } catch (\Exception $e) {
- return $content;
- }
- }
- }
- \think\facade\Middleware::add('app\admin\service\Auth');
|