sysconf('wechat_token'), 'appid' => sysconf('wechat_appid'), 'appsecret' => sysconf('wechat_appsecret'), 'encodingaeskey' => sysconf('wechat_encodingaeskey'), 'mch_id' => sysconf('wechat_mch_id'), 'partnerkey' => sysconf('wechat_partnerkey'), 'ssl_cer' => sysconf('wechat_cert_cert'), 'ssl_key' => sysconf('wechat_cert_key'), 'cachepath' => CACHE_PATH . 'wxpay' . DS, ]; $wechat[$index] = Loader::get($type, $config); } return $wechat[$index]; } /** * UTF8字符串加密 * @param string $string * @return string */ function encode($string) { $chars = ''; $len = strlen($string = iconv('utf-8', 'gbk', $string)); for ($i = 0; $i < $len; $i++) { $chars .= str_pad(base_convert(ord($string[$i]), 10, 36), 2, 0, 0); } return strtoupper($chars); } /** * UTF8字符串解密 * @param string $string * @return string */ function decode($string) { $chars = ''; foreach (str_split($string, 2) as $char) { $chars .= chr(intval(base_convert($char, 36, 10))); } return iconv('gbk', 'utf-8', $chars); } /** * RBAC节点权限验证 * @param string $node * @return bool */ function auth($node) { return NodeService::checkAuthNode($node); } /** * 设备或配置系统参数 * @param string $name 参数名称 * @param bool $value 默认是false为获取值,否则为更新 * @return string|bool */ function sysconf($name, $value = false) { static $config = []; if ($value !== false) { $config = []; $data = ['name' => $name, 'value' => $value]; return DataService::save('SystemConfig', $data, 'name'); } if (empty($config)) { foreach (Db::name('SystemConfig')->select() as $vo) { $config[$vo['name']] = $vo['value']; } } return isset($config[$name]) ? $config[$name] : ''; } /** * array_column 函数兼容 */ if (!function_exists("array_column")) { function array_column(array &$rows, $column_key, $index_key = null) { $data = []; foreach ($rows as $row) { if (empty($index_key)) { $data[] = $row[$column_key]; } else { $data[$row[$index_key]] = $row[$column_key]; } } return $data; } }