<?php
	function gettablename($table)
	{
		$mtable = ltrim($table,C('DB_PREFIX'));
		switch($mtable)
		{
			case 'info':
			echo '网址主表';
			break;
			case 'label':
			echo '标签表';
			break;
			case 'tpl':
			echo '模板表';
			break;
			case 'visit':
			echo '统计表';
			break;
			case 'feedback':
			echo '反馈表';
			break;
			case 'friendlink_group':
			echo '友情链接组表';
			break;
			case 'articlelink':
			echo '关键词替换表';
			break;
			case 'member_msg':
			echo '会员短信息表';
			break;
			case 'member_rank':
			echo '会员等级表';
			break;
			case 'plugin':
			echo '插件表';
			break;
			case 'special':
			echo '专题表';
			break;
			case 'tags':
			echo '关键词表';
			break;
			case 'vote':
			echo '投票主表';
			break;
			case 'member':
			echo '会员表';
			break;
			case 'admin':
			echo '管理员表';
			break;
			case 'config':
			echo '系统配置表';
			break;
			case 'ad':
			echo '广告主表';
			break;
			case 'ad_group':
			echo '广告分组表';
			break;
			case 'arctype':
			echo '栏目主表';
			break;
			case 'config_group':
			echo '栏目主表';
			break;
			case 'arctype':
			echo '栏目主表';
			break;
			default:
			echo $table;
		}
	}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="__PUBLIC__/Admin/images/Admin_css.css" type="text/css" rel="stylesheet">
<link rel="shortcut icon" href="__PUBLIC__/Admin/images/myfav.ico" type="image/x-icon" />
<style> 
.classlist {float:left;margin:0;padding:0;}
.classlist ul {float:left;margin:0;padding:0;}
.classlist li {margin:0;padding:0;padding:3px 0;border-bottom:1px solid #ffffff;}
.classlist li span {float:right;margin-top:-3px;}
.classlist .bigclass {font-weight:bold;clear:both;list-style:none;margin:5px 0;}
.classlist .yaoclass {font-weight:normal;list-style:none;padding-left:10px;}
</style>
<import file="Admin.js.Jquery"/> 
<script charset="utf-8" src="__PUBLIC__/Common/artDialog/jquery.artDialog.js?skin=green"></script>
<script charset="utf-8" src="__PUBLIC__/Common/artDialog/extend.js"></script>
<script>
function jconfirm(str,url)
{
   $.dialog.confirm(str,function (){window.location.href=url;});
}
function showfields(){
	var exptable = $('#exptable').val();
	$.ajax({
		url: '{:U('Backup/ajaxfields?id=')}'+exptable+'',
		success: function(res){
			$('#fields').html(res);
		}
	});
} 
function rpfield(v){
	$('#rpfield').val(v); 
}
</script>
<title>数据批量替换</title>
</head>
<body>
<script>
	function CheckForm()
	{ 
		if(EmptyCheckForm('sql','sql语句不能为空!','')) return false;
	}
	function EmptyCheckForm(id,value,set)
	{
		if($('#'+id).val()==set)
		{
			$.dialog({icon:'warning',content:value,ok:function(){ $('#' + id).focus();}});return true;
		}
		return false;
	}
</script>
<table border="0" align="center" cellpadding="3" cellspacing="2" bgcolor="#FFFFFF" class="admintable">
  <tr>
    <td colspan="2" class="admintitle">数据批量替换</td>
  </tr>
  <form action="{:U('Backup/dorepsql')}" method="post" onsubmit="return CheckForm()">
  <tr>
  <td colspan="2">
 <h4> 声明：程序用于批量替换数据库中某字段的内容，此操作极为危险，请小心使用。</h4>
  </td>
  </tr>
  <tr>
    <td align="left" width="20%" height="25" bgcolor="f7f7f7">&nbsp;选择数据表与字段：</td>
    <td align="left" height="25" bgcolor="f7f7f7"><select name="exptable" id="exptable" size="10" style="height:150px;width:500px;" onChange="showfields()">
  <volist name="list_table" id="vo"><option value="{$vo}">{$vo} ({$vo|gettablename})</option></volist></select><div id="fields" style="float:left"></div></td>
  </tr>
  <tr>
    <td align="left" height="25" bgcolor="f7f7f7">&nbsp;要替换的字段：</td>
    <td align="left" height="25" bgcolor="f7f7f7"><input name="rpfield" type="text" id="rpfield" style="width:500px;"/> *</td>
  </tr>
  <tr>
    <td align="left" height="25" bgcolor="f7f7f7">&nbsp;被替换的内容：</td>
    <td align="left" height="25" bgcolor="f7f7f7"><textarea name="rpstring" id="rpstring" style="width:500px;height:80px"></textarea> *</td>
  </tr>
   <tr>
    <td align="left" height="25" bgcolor="f7f7f7">&nbsp;替换为的内容：</td>
    <td align="left" height="25" bgcolor="f7f7f7"><textarea name="tostring" id="tostring" class="alltxt" style="width:500px;height:80px"></textarea> *</td>
  </tr>
  <tr>
    <td align="left" height="25" bgcolor="f7f7f7">&nbsp;选择替换条件：</td>
    <td align="left" height="25" bgcolor="f7f7f7"><input name="condition" type="text" id="condition" style="width:500px; color:#696969;" title="留空则全部替换,请遵循SQL的条件语句规则 如id=888 id&gt;888"/></td>
  </tr>
  <tr>
    <td height="25" colspan="2" align="center" class="tabletd2"><input type="submit" name="Submit" class="bnt" value="执行SQL">&nbsp;&nbsp;<input name="Submit22" type="button" class="bnt" onClick="history.go(-1)"  value="返 回"></td>
  </tr>
  </form>
</table>
<div style="text-align:center;margin:10px;">
<hr>
<include file="Index:copy" /> 
</div>
</body>
</html>