1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- use app\admin\service\AuthService;
- use think\admin\extend\NodeExtend;
- if (!function_exists('auth')) {
-
- function auth($node)
- {
- return AuthService::check($node);
- }
- }
- if (!function_exists('sysdata')) {
-
- function sysdata($name, array $value = null)
- {
- if (is_null($value)) {
- $data = json_decode(app()->db->name('SystemData')->where(['name' => $name])->value('value'), true);
- return empty($data) ? [] : $data;
- } else {
- return data_save('SystemData', ['name' => $name, 'value' => json_encode($value, JSON_UNESCAPED_UNICODE)], 'name');
- }
- }
- }
- if (!function_exists('sysoplog')) {
-
- function sysoplog($action, $content)
- {
- return app()->db->name('SystemOplog')->insert([
- 'node' => NodeExtend::getCurrent(),
- 'action' => $action, 'content' => $content,
- 'geoip' => PHP_SAPI === 'cli' ? '127.0.0.1' : app()->request->ip(),
- 'username' => PHP_SAPI === 'cli' ? 'cli' : app()->session->get('user.username'),
- ]);
- }
- }
|