* validate model config input, bug #36511.
This commit is contained in:
@@ -48,6 +48,16 @@ class ai extends control
|
||||
if(strtolower($this->server->request_method) == 'post')
|
||||
{
|
||||
$modelConfig = fixer::input('post')->get();
|
||||
|
||||
$errors = array();
|
||||
if(empty($modelConfig->type)) $errors[] = sprintf($this->lang->ai->validate->noEmpty, $this->lang->ai->models->type);
|
||||
if(empty($modelConfig->key)) $errors[] = sprintf($this->lang->ai->validate->noEmpty, $this->lang->ai->models->apiKey);
|
||||
if(!empty($modelConfig->proxyType) && empty($modelConfig->proxyAddr))
|
||||
{
|
||||
$errors[] = sprintf($this->lang->ai->validate->noEmpty, $this->lang->ai->models->proxyAddr);
|
||||
}
|
||||
if(!empty($errors)) return $this->send(array('result' => 'fail', 'message' => implode('<br>', $errors)));
|
||||
|
||||
$this->loadModel('setting')->setItems('system.ai', $modelConfig);
|
||||
|
||||
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
|
||||
|
||||
@@ -10,24 +10,26 @@
|
||||
*/
|
||||
?>
|
||||
<?php include '../../common/view/header.html.php';?>
|
||||
<style>
|
||||
.required:after {right: -12px;}
|
||||
</style>
|
||||
<div id='mainContent' class='main-content'>
|
||||
<form id='mainForm' class='load-indicator main-form form-ajax' method='post'>
|
||||
<table class='table table-form mw-800px'>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->type;?></th>
|
||||
<td><div class="required required-wrapper"></div><?php echo html::select('type', $lang->ai->models->typeList, $modelConfig->type, "class='form-control chosen'");?></td>
|
||||
<td><?php echo html::select('type', $lang->ai->models->typeList, $modelConfig->type, "class='form-control chosen' required");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->apiKey;?></th>
|
||||
<td><div class="required required-wrapper"></div><?php echo html::input('key', $modelConfig->key, "class='form-control'");?></td>
|
||||
<td><?php echo html::input('key', $modelConfig->key, "class='form-control' required");?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><?php echo $lang->ai->models->proxyType;?></th>
|
||||
<td>
|
||||
<div class='row'>
|
||||
<div class='col-md-4'>
|
||||
<div class="required required-wrapper"></div>
|
||||
<?php echo html::select('proxyType', $lang->ai->models->proxyTypes, $modelConfig->proxyType, "class='form-control chosen' data-disable_search='true'");?>
|
||||
<?php echo html::select('proxyType', $lang->ai->models->proxyTypes, $modelConfig->proxyType, "class='form-control chosen' data-disable_search='true' required");?>
|
||||
</div>
|
||||
<div class='col-md-8' id='proxyAddrContainer' <?php if(empty($modelConfig->proxyType)) echo 'style="display: none;"'; ?>>
|
||||
<div class='row'>
|
||||
|
||||
Reference in New Issue
Block a user