💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
~~~ //todo 读取数据库字段 start if (empty($this->config['database'])) { $configFile = APP_PATH . "data/common.inc.php"; if (!file_exists($configFile)) { $dir_handle = opendir(APP_PATH); while (($file = readdir($dir_handle)) !== false) { if (substr($file, 0, 1) !== '.' and is_dir(APP_PATH . $file)) { $dir_handle2 = opendir(APP_PATH . $file); while (($file2 = readdir($dir_handle2)) !== false) { if ($file2 === 'common.inc.php') { $filePath = APP_PATH . $file . '/' . $file2; $content = file_get_contents($filePath); if (strpos($content, '//数据库连接信息') !== false) { $configFile = $filePath; break 2; } } } closedir($dir_handle2); } } closedir($dir_handle); } if (!file_exists($configFile)) { res(1002, "接口配置异常,无法正常读取配置信息"); } $cfg_dbhost = $cfg_dbuser = $cfg_dbpwd = $cfg_dbname = $cfg_db_language = $cfg_dbprefix = ''; require_once($configFile); $hostArr = explode(":", $cfg_dbhost); $this->config['database'] = array( 'host' => $hostArr[0], 'port' => $hostArr[1] ? $hostArr[1] : '3306', 'user' => $cfg_dbuser, 'password' => $cfg_dbpwd, 'database' => $cfg_dbname, 'charset' => $cfg_db_language, 'prefix' => $cfg_dbprefix ); } if (!$this->config['setting']['product_model_id']) { $this->config['setting']['product_model_id'] = 6; } //todo 读取数据库字段 end ~~~