<?php require_once("../../classes/DBCon.php"); $DB = new DBCon();

$dq = '"'; $dqR = "in.";
$sq = "'"; $sqR = "in.";

$t	= trim($_POST['source_t']);

echo "<b style='color:#0cbd0c'>CLEANING STARTED</b><br />";
$res = $DB->execute("describe `{$t}`");
if($res[2]){
	while($row=$DB->nextRow($res[0])){
		$f = $row['Field']; if($f=="id" || $f=="vicyear") continue;
		echo "<br />".strtoupper($f);

		if($f=="vicmake"){
			if($DB->silentExecute("update `{$t}` set vicmake = concat('0',vicmake) where length(vicmake) = 1")){ echo "<br /><b style='color:#0cbd0c'>vicmake</b> appended where short<br />"; }
			continue;
		}

		if($f=="vicseries"){
			if($DB->silentExecute("update `{$t}` set vicseries = concat('0',vicseries) where length(vicseries) = 1")){ echo "<br /><b style='color:#0cbd0c'>vicseries</b> appended where short<br />"; }
			continue;
		}

		if($f=="vicbody"){
			if($DB->silentExecute("update `{$t}` set vicbody = concat('0',vicbody) where length(vicbody) = 1")){ echo "<br /><b style='color:#0cbd0c'>vicbody</b> appended where short<br />"; }
			continue;
		}

		if($DB->silentExecute("update `{$t}` set `{$f}` = trim({$f})")){
			echo "<br /><b style='color:#0cbd0c'>Trimmed {$f}</b>";
		}
		if($DB->silentExecute("update `{$t}` set `{$f}` = replace({$f}, '{$dq}', '{$dqR}')")){
			echo "<br /><b style='color:#0cbd0c'>{$dq}</b> cleaned";
		}
		if($DB->silentExecute("update `{$t}` set `{$f}` = replace({$f}, ''{$sq}', '{$sqR}')")){
			echo "<br /><b style='color:#0cbd0c'>{$sq}</b> cleaned<br />";
		}
	}

}
echo "<br />ENDED<hr />";
?>