system\framework\table.php 文件第 763-908行代码有误,相关错误代码如下:
{
$check = K::m( "verify/check" );
foreach ( $schemas as $k => $v )
{
if ( $pk )
{{
if ( empty( $v['edit'] ) )
{
unset( $data[$k] );
}
else if ( empty( $v['empty'] ) && isset( $data[$k] ) )
{
if ( $data[$k] === "" )
{
$this->err->add( $v['label']."不能为空", 451 );
return FALSE;
}
}
else if ( $v['empty'] && $v['label']."不能为空" )
{
if ( $pk )
{
break;
}
}
}
else if ( $v['type'] == "clientip" )
{
$data[$k] = __IP;
}
else
{
if ( $v['type'] == "dateline" )
{
$data[$k] = __CFG::TIME;
}
else if ( empty( $v['add'] ) )
{
unset( $data[$k] );
}
else
{
if ( empty( $v['empty'] ) )
{
if ( !isset( $data[$k] ) && $data[$k] === "" )
{
break;
}
else
{
$this->err->add( $v['label']."不能为空", 452 );
return FALSE;
}
}
else
{
do
{
} while ( 0 );
}
}
}
if ( $v['empty'] && isset( $data[$k], $data[$k] ) || !isset( $data[$k] ) )
{
switch ( strtolower( $v['type'] ) )
{
case "int" :
case "member" :
case "desginer" :
case "home" :
case "shop" :
case "company" :
$data[$k] = ( integer )$data[$k];
break;
case "number" :
$data[$k] = ( double )$data[$k];
break;
case "boolean" :
case "audit" :
case "closed" :
$data[$k] = $data[$k] ? 1 : 0;
break;
case "mail" :
if ( $check->mail( $data[$k] ) )
{
break;
}
$this->err->add( $v['label']."必须为Email格式", 453 );
return FALSE;
case "phone" :
if ( $check->phone( $data[$k] ) )
{
break;
}
$this->err->add( $v['label']."必须为电话", 454 );
return FALSE;
case "mobile" :
if ( !$check->phone( $data[$k] ) )
{
if ( $check->mobile( $data[$k] ) )
{
break;
}
$this->err->add( $v['label']."必须为电话/手机号格式", 454 );
return FALSE;
}
case "qq" :
if ( $check->qq( $data[$k] ) )
{
break;
}
$this->err->add( $v['label']."必须为QQ格式,多个用\",\"分隔", 455 );
return FALSE;
case "unixtime" :
$data[$k] = $data[$k] ? strtotime( $data[$k] ) : 0;
break;
case "date" :
$data[$k] = preg_match( "/^[\\d]{4}-[\\d]{1,2}-[\\d]{1,2}\$/", $data[$k] ) ? $data[$k] : "0";
case "checkbox" :
if ( !is_array( $data[$k] ) )
{
break;
}
else
{
if ( !( $ids = $check->ids( $data[$k] ) ) )
{
break;
}
$data[$k] = $ids;
}
break;
case "text" :
case "textarea" :
case "editor" :
} while ( 0 );
do
{
if ( $v['html'] )
{
break;
}
$data[$k] = K::m( "content/html" )->encode( $data[$k] );
}
}
}
}
解决方法为把上面这段代码替换为如下代码:
{
$check = K::M('verify/check');
foreach ($schemas as $k => $v) {
if ($pk) {
if (empty($v['edit'])) {
unset($data[$k]);
continue;
}
else {
if (empty($v['empty']) && isset($data[$k])) {
if ($data[$k] === '') {
$this->err->add($v['label'] . '不能为空', 451);
return false;
}
}
else {
if ($v['empty'] && isset($data[$k]) && empty($data[$k])) {
continue;
}
}
}
}
else if ($v['type'] == 'clientip') {
$data[$k] = __IP;
}
else if ($v['type'] == 'dateline') {
$data[$k] = __CFG::TIME;
}
else if (empty($v['add'])) {
unset($data[$k]);
continue;
}
else if (empty($v['empty'])) {
if (!isset($data[$k]) || ($data[$k] === '')) {
$this->err->add($v['label'] . '不能为空', 452);
return false;
}
}
else {
if ($v['empty'] && isset($data[$k]) && empty($data[$k])) {
continue;
}
}
if (isset($data[$k])) {
switch (strtolower($v['type'])) {
case 'int':
case 'member':
case 'company':
case 'shop':
case 'designer':
case 'mechanic':
case 'home':
case 'case':
$data[$k] = (int) $data[$k];
break;
case 'number':
$data[$k] = (double) $data[$k];
break;
case 'boolean':
case 'audit':
case 'closed':
$data[$k] = $data[$k] ? 1 : 0;
break;
case 'mail':
if (!$check->mail($data[$k])) {
$this->err->add($v['label'] . '必须为Email格式', 453);
return false;
}
break;
case 'phone':
if (!$check->phone($data[$k])) {
if (!$check->mobile($data[$k])) {
$this->err->add($v['label'] . '必须为电话/手机号格式', 454);
return false;
}
}
break;
case 'mobile':
if (!$check->mobile($data[$k])) {
$this->err->add($v['label'] . '必须为手机号格式', 454);
return false;
}
break;
case 'qq':
if (!$check->qq($data[$k])) {
$this->err->add($v['label'] . '必须为QQ格式,多个用","分隔', 455);
return false;
}
break;
case 'unixtime':
if (!is_numeric($data[$k])) {
$data[$k] = $data[$k] ? strtotime($data[$k]) : 0;
}
break;
case 'date':
if (!preg_match('/^[\\d]{4}-[\\d]{1,2}-[\\d]{1,2}$/', $data[$k])) {
if (!is_numeric($data[$k])) {
$data[$k] = 0;
}
}
break;
case 'checkbox':
if (is_array($data[$k])) {
if ($ids = $check->ids($data[$k])) {
$data[$k] = $ids;
}
break;
}
case 'html':
$data[$k] = K::M('content/html')->filter($data[$k]);
break;
case 'text':
case 'textarea':
case 'editor':
default:
if (!$v['html']) {
$data[$k] = K::M('content/html')->encode($data[$k]);
}
break;
}
}
}
}
|