예제 #1
0
function getHandleFieldList($tableName, $sType)
{
    $s = '';
    if ($GLOBALS['WEB_CACHEContent'] == '') {
        $GLOBALS['WEB_CACHEContent'] = getFText($GLOBALS['WEB_CACHEFile']);
    }
    $s = getConfigContentBlock($GLOBALS['WEB_CACHEContent'], '#' . $tableName . $sType . '#');
    if ($s == '') {
        if ($sType == '字段配置列表') {
            $s = lCase(getFieldConfigList($tableName));
        } else {
            $s = lCase(getFieldList($tableName));
        }
        $GLOBALS['WEB_CACHEContent'] = setConfigFileBlock($GLOBALS['WEB_CACHEFile'], $s, '#' . $tableName . $sType . '#');
        if ($GLOBALS['isCacheTip'] == true) {
            aspEcho('缓冲', $tableName . $sType);
        }
    }
    $getHandleFieldList = $s;
    return @$getHandleFieldList;
}
예제 #2
0
function importTXTData($content, $tableName, $sType)
{
    $fieldConfigList = '';
    $splList = '';
    $listStr = '';
    $splStr = '';
    $splxx = '';
    $s = '';
    $sql = '';
    $nOK = '';
    $fieldName = '';
    $fieldType = '';
    $fieldValue = '';
    $addFieldList = '';
    $addValueList = '';
    $updateValueList = '';
    $fieldStr = '';
    $tableName = aspTrim(lCase($tableName));
    //表
    //这样做是为了从GitHub下载时它把vbcrlf转成 chr(10)  20160409
    if (inStr($content, vbCrlf()) == false) {
        $content = replace($content, chr(10), vbCrlf());
    }
    $fieldConfigList = lCase(getFieldConfigList($GLOBALS['db_PREFIX'] . $tableName));
    $splStr = aspSplit($fieldConfigList, ',');
    $splList = aspSplit($content, vbCrlf() . '-------------------------------');
    $nOK = 0;
    foreach ($splList as $key => $listStr) {
        $addFieldList = '';
        //添加字段列表清空
        $addValueList = '';
        //添加字段列表值
        $updateValueList = '';
        //修改字段列表
        $s = lCase(newGetStrCut($listStr, '#stop#'));
        if ($s != '1' && $s != 'true') {
            foreach ($splStr as $key => $fieldStr) {
                if ($fieldStr != '') {
                    $splxx = aspSplit($fieldStr, '|');
                    $fieldName = $splxx[0];
                    $fieldType = $splxx[1];
                    if (inStr($listStr, '【' . $fieldName . '】') > 0) {
                        $listStr = $listStr . vbCrlf();
                        //加个换行是为了让最后一个参数能添加进去 20160629
                        if ($addFieldList != '') {
                            $addFieldList = $addFieldList . ',';
                            $addValueList = $addValueList . ',';
                            $updateValueList = $updateValueList . ',';
                        }
                        $addFieldList = $addFieldList . $fieldName;
                        $fieldValue = newGetStrCut($listStr, $fieldName);
                        if ($fieldType == 'textarea') {
                            $fieldValue = contentTranscoding($fieldValue);
                        }
                        //call echo(tableName,fieldName)
                        //文章大类
                        if (($tableName == 'articledetail' || $tableName == 'webcolumn') && $fieldName == 'parentid') {
                            //call echo(tableName,fieldName)
                            //call echo("fieldValue",fieldValue)
                            $fieldValue = getColumnId($fieldValue);
                            //call echo("fieldValue",fieldValue)
                            //后台菜单
                        } else {
                            if ($tableName == 'listmenu' && $fieldName == 'parentid') {
                                $fieldValue = getListMenuId($fieldValue);
                            }
                        }
                        if ($fieldType == 'date' && $fieldValue == '') {
                            $fieldValue = aspDate();
                        } else {
                            if (($fieldType == 'time' || $fieldType == 'now') && $fieldValue == '') {
                                $fieldValue = now();
                            }
                        }
                        if ($fieldType != 'yesno' && $fieldType != 'numb') {
                            $fieldValue = '\'' . $fieldValue . '\'';
                            //默认数值类型为0
                        } else {
                            if ($fieldValue == '') {
                                $fieldValue = 0;
                            }
                        }
                        $addValueList = $addValueList . $fieldValue;
                        //添加值
                        $updateValueList = $updateValueList . $fieldName . '=' . $fieldValue;
                        //修改值
                    }
                }
            }
            //字段列表不为空
            if ($addFieldList != '') {
                if ($sType == '修改') {
                    $sql = 'update ' . $GLOBALS['db_PREFIX'] . '' . $tableName . ' set ' . $updateValueList;
                } else {
                    $sql = 'insert into ' . $GLOBALS['db_PREFIX'] . '' . $tableName . ' (' . $addFieldList . ') values(' . $addValueList . ')';
                }
                //检测SQL
                if (checkSql($sql) == false) {
                    eerr('出错提示', '<hr>sql=' . $sql . '<br>');
                }
                $nOK = $nOK + 1;
            } else {
                $nOK = batchImportColumnList($splStr, $listStr, $nOK, $tableName);
            }
        }
    }
    $importTXTData = $nOK;
    //call echo("sql",sql)
    //call echo("addFieldList",addFieldList)
    //call echo("updateValueList",updateValueList)
    return @$importTXTData;
}