diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index ad75aa87..d34fe0e0 100755 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -21,6 +21,16 @@ class Crud extends Command protected $internalKeywords = [ 'abstract', 'and', 'array', 'as', 'break', 'callable', 'case', 'catch', 'class', 'clone', 'const', 'continue', 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exit', 'extends', 'final', 'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'isset', 'list', 'namespace', 'new', 'or', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'switch', 'throw', 'trait', 'try', 'unset', 'use', 'var', 'while', 'xor' ]; + + /** + * 受保护的系统表, crud不会生效 + */ + protected $systemTables = [ + 'admin', 'admin_log', 'auth_group', 'auth_group_access', 'auth_rule', + 'attachment', 'config', 'category', 'ems', 'sms', + 'user', 'user_group', 'user_rule', 'user_score_log', 'user_token', + ]; + /** * Selectpage搜索字段关联 */ @@ -204,9 +214,12 @@ class Crud extends Command $force = $input->getOption('force'); //是否为本地model,为0时表示为全局model将会把model放在app/common/model中 $local = $input->getOption('local'); + if (!$table) { throw new Exception('table name can\'t empty'); } + + //是否生成菜单 $menu = $input->getOption("menu"); //关联表 @@ -298,6 +311,11 @@ class Crud extends Command $dbname = Config::get($db . '.database'); $prefix = Config::get($db . '.prefix'); + //系统表无法生成,防止后台错乱 + if(in_array(str_replace($prefix,"",$table),$this->systemTables)){ + throw new Exception('system table can\'t be crud'); + } + //模块 $moduleName = 'admin'; $modelModuleName = $local ? $moduleName : 'common'; @@ -886,7 +904,7 @@ class Crud extends Command 'recyclebinJs' => '', 'headingHtml' => $headingHtml, 'recyclebinHtml' => $recyclebinHtml, - 'visibleFieldList' => $fields ? "\$row->visible(['" . implode("','", array_filter(explode(',', $fields))) . "']);" : '', + 'visibleFieldList' => $fields ? "\$row->visible(['" . implode("','", array_filter(in_array($priKey,explode(',', $fields))?explode(',', $fields):explode(',',$priKey.','.$fields))) . "']);" : '', 'appendAttrList' => implode(",\n", $appendAttrList), 'getEnumList' => implode("\n\n", $getEnumArr), 'getAttrList' => implode("\n\n", $getAttrArr), diff --git a/application/admin/library/Auth.php b/application/admin/library/Auth.php index 5e265f5c..64bf1eec 100644 --- a/application/admin/library/Auth.php +++ b/application/admin/library/Auth.php @@ -473,7 +473,7 @@ class Auth extends \fast\Auth foreach ($topList as $index => $item) { $childList = Tree::instance()->getTreeMenu( $item['id'], - '
  • @title @caret @badge @childlist
  • ', + '
  • @title @caret @badge @childlist
  • ', $select_id, '', 'ul', @@ -495,7 +495,7 @@ class Auth extends \fast\Auth Tree::instance()->init($ruleList); $menu = Tree::instance()->getTreeMenu( 0, - '
  • @title @caret @badge @childlist
  • ', + '
  • @title @caret @badge @childlist
  • ', $select_id, '', 'ul', diff --git a/application/common/library/Email.php b/application/common/library/Email.php index 7636d761..4ddb0b65 100644 --- a/application/common/library/Email.php +++ b/application/common/library/Email.php @@ -219,6 +219,7 @@ class Email preg_match_all("/Expected: (\d+)\, Got: (\d+)( \| (.*))?\$/i", $e->getMessage(), $matches); $code = isset($matches[2][3]) ? $matches[2][3] : 0; $message = isset($matches[2][0]) ? $matches[4][0] : $e->getMessage(); + $message = mb_convert_encoding($message, 'UTF-8', 'GBK,GB2312,BIG5'); $this->setError($message); } catch (\Exception $e) { $this->setError($e->getMessage());