ThinkPHP - F函数,更新配置文件

Html代码:

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<title>修改验证码配置文件</title>
<link rel="stylesheet" href="__PUBLIC__/Css/Public.css">
</head>
<body>
<form action="<{:U(GROUP_NAME . '/System/setVerify')}>" method="post">
<table class="table">
<tr>
<th colspan="2">验证码配置</th>
</tr>
<tr>
<td align="right">验证码字典:</td>
<td><input type="text" name="charset" value="<{$Think.config.charset}>" /></td>
</tr>
<tr>
<td align="right">验证码长度:</td>
<td><input type="text" name="codelen" value="<{$Think.config.codelen}>" /></td>
</tr>
<tr>
<td align="right">验证码宽度:</td>
<td><input type="text" name="width" value="<{$Think.config.width}>" /></td>
</tr>
<tr>
<td align="right">验证码高度:</td>
<td><input type="text" name="height" value="<{$Think.config.height}>" /></td>
</tr>
<tr>
<td align="right">验证码字体文件位置:</td>
<td><input type="text" name="font" value="<{$Think.config.font}>" /></td>
</tr>
<tr>
<td align="right">验证码字体大小:</td>
<td><input type="text" name="fontsize" value="<{$Think.config.fontsize}>" /></td>
</tr>
<tr>
<td align="right">Session名称</td>
<td><input type="text" name="verifyName" value="<{$Think.config.verifyName}>" /></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="保存更新" style="cursor:pointer;" />
</td>
</tr>
</table>
</form>
</body>
</htm

PHP代码:

    /**
* 验证码表单
*/
Public function setVerify() {
if ( !IS_POST ) $this->redirect(GROUP_NAME . '/Syatem/verify'); //使用F函数,重写配置文件
if ( F('verify', $_POST, CONF_PATH) ) {
$this->success('写入成功!', U( GROUP_NAME . '/System/verify'));
} else {
$this->error('写入失败, 请检查文件夹:' . CONF_PATH . '是否具有写入权限!');
}
}

生成文件:

<?php    return array ( 'charset' => 'abcdefghkmnprstuvwxyzABCDEFGHKMNPRSTUVWXYZ23456789', 'codelen' => '2', 'width' => '130', 'height' => '50', 'font' => './App/Data/QDB.otf', 'fontsize' => '30', 'verifyName' => 'verify', );?>
上一篇:Android插件化(三)载入插件apk中的Resource资源


下一篇:javascript语言理解