Beispiel #1
0
function XY_handleGetTableBody($action, $tableName, $fieldParamName, $defaultFileName, $adminUrl)
{
    $url = '';
    $content = '';
    $id = '';
    $sql = '';
    $addSql = '';
    $fieldName = '';
    $fieldParamValue = '';
    $fieldNameList = '';
    $nLen = '';
    $delHtmlYes = '';
    $trimYes = '';
    $defaultStr = '';
    $noisonhtml = '';
    $intoFieldStr = '';
    $valuesStr = '';
    $nonull = '';
    $fieldName = RParam($action, 'fieldname');
    //字段名称
    $noisonhtml = RParam($action, 'noisonhtml');
    //不生成html
    $nonull = RParam($action, 'noisonhtml');
    //内容不能为空20160716 home
    if ($noisonhtml == 'true') {
        $intoFieldStr = ',isonhtml';
        $valuesStr = ',0';
    }
    $fieldNameList = getHandleFieldList($GLOBALS['db_PREFIX'] . $tableName, '字段列表');
    //字段名称不为空,并且要在表字段里
    if ($fieldName == '' || inStr($fieldNameList, ',' . $fieldName . ',') == false) {
        $fieldName = $defaultFileName;
    }
    $fieldName = lCase($fieldName);
    //转为小写,因为在PHP里是全小写的
    $fieldParamValue = RParam($action, $fieldParamName);
    //截取字段内容
    $id = handleNumber(RParam($action, 'id'));
    //获得ID
    $addSql = ' where ' . $fieldParamName . '=\'' . $fieldParamValue . '\'';
    if ($id != '') {
        $addSql = ' where id=' . $id;
    }
    $content = getDefaultValue($action);
    $defaultStr = $content;
    //获得默认内容
    $sql = 'select * from ' . $GLOBALS['db_PREFIX'] . $tableName . $addSql;
    $rsObj = $GLOBALS['conn']->query($sql);
    if (@mysql_num_rows($rsObj) == 0) {
        $rs = mysql_fetch_array($rsObj);
        //自动添加 20160113
        if (RParam($action, 'autoadd') == 'true') {
            connexecute('insert into ' . $GLOBALS['db_PREFIX'] . $tableName . ' (' . $fieldParamName . ',' . $fieldName . $intoFieldStr . ') values(\'' . $fieldParamValue . '\',\'' . ADSql($content) . '\'' . $valuesStr . ')');
        }
    } else {
        $id = $rs['id'];
        $content = $rs[$fieldName];
        if (len($content) <= 0) {
            $content = $defaultStr;
            connexecute('update ' . $GLOBALS['db_PREFIX'] . $tableName . ' set ' . $fieldName . '=\'' . $content . '\' where id=' . $rs['id']);
        }
    }
    //删除Html
    $delHtmlYes = RParam($action, 'delHtml');
    //是否删除Html
    if ($delHtmlYes == 'true') {
        $content = replace(delHtml($content), '<', '&lt;');
    }
    //HTML处理
    //删除两边空格
    $trimYes = RParam($action, 'trim');
    //是否删除两边空格
    if ($trimYes == 'true') {
        $content = TrimVbCrlf($content);
    }
    //截取字符处理
    $nLen = RParam($action, 'len');
    //字符长度值
    $nLen = handleNumber($nLen);
    //If nLen<>"" Then ReplaceStr = CutStr(ReplaceStr,nLen,"null")' Left(ReplaceStr,nLen)
    if ($nLen != '') {
        $content = CutStr($content, $nLen, '...');
    }
    //Left(ReplaceStr,nLen)
    if ($id == '') {
        $id = XY_AP_GetFieldValue('', $sql, 'id');
    }
    $url = $adminUrl . '&id=' . $id . '&n=' . getRnd(11);
    if (@$_REQUEST['gl'] == 'edit') {
        $content = '<span>' . $content . '</span>';
    }
    //call echo(sql,url)
    $content = handleDisplayOnlineEditDialog($url, $content, '', 'span');
    $XY_handleGetTableBody = $content;
    return @$XY_handleGetTableBody;
}
Beispiel #2
0
function getPostSql($id, $tableName, $fieldNameList)
{
    $valueStr = '';
    $editValueStr = '';
    $sql = '';
    $splStr = '';
    $splxx = '';
    $s = '';
    $fieldList = '';
    $fieldName = '';
    $defaultFieldValue = '';
    //字段名称
    $fieldSetType = '';
    //字段设置类型
    $fieldValue = '';
    //字段值
    $systemFieldList = '';
    //表字段列表
    $systemFieldList = getHandleFieldList($GLOBALS['db_PREFIX'] . $tableName, '字段配置列表');
    $postFieldList = '';
    //post字段列表
    $splPost = '';
    $fieldContent = '';
    $fieldConfig = '';
    $postFieldList = getFormFieldList();
    //以后再把下面与上面这两种处理方法事成一种看看行不行
    $splPost = aspSplit($postFieldList, '|');
    foreach ($splPost as $key => $fieldName) {
        $fieldContent = @$_POST[$fieldName];
        if (inStr($systemFieldList, ',' . $fieldName . '|') > 0 && inStr(',' . $fieldList . ',', ',' . $fieldName . ',') == false) {
            //为自定义的
            if (inStr($fieldNameList, ',' . $fieldName . '|') > 0) {
                $fieldConfig = mid($fieldNameList, inStr($fieldNameList, ',' . $fieldName . '|') + 1, -1);
            } else {
                $fieldConfig = mid($systemFieldList, inStr($systemFieldList, ',' . $fieldName . '|') + 1, -1);
            }
            $fieldConfig = mid($fieldConfig, 1, inStr($fieldConfig, ',') - 1);
            //call echo("config",fieldConfig)
            //call echo(fieldName,fieldContent)
            //call echo("fieldConfig",fieldConfig)
            $splxx = aspSplit($fieldConfig . '|||', '|');
            $fieldName = $splxx[0];
            //字段名称
            $fieldSetType = $splxx[1];
            //字段设置类型
            $defaultFieldValue = $splxx[2];
            //默认字段值
            $fieldValue = ADSqlRf($fieldName);
            //代替上面,因为它处理了'符号
            //call echo("fieldValue",fieldValue)
            //排序密码不处理
            if ($fieldValue != '#NO******NO#') {
                //md5加密
                if ($fieldSetType == 'md5') {
                    $fieldValue = myMD5($fieldValue);
                }
                if ($fieldSetType == 'yesno') {
                    if ($fieldValue == '') {
                        $fieldValue = $defaultFieldValue;
                    }
                    //不为数字类型加单引号
                } else {
                    if ($fieldSetType == 'numb') {
                        if ($fieldValue == '') {
                            $fieldValue = $defaultFieldValue;
                        }
                    } else {
                        if ($fieldName == 'flags') {
                            //PHP里用法
                            if (EDITORTYPE == 'php') {
                                if ($fieldValue != '') {
                                    $fieldValue = '|' . arrayToString($fieldValue, '|');
                                }
                            } else {
                                $fieldValue = '|' . arrayToString(aspSplit($fieldValue, ', '), '|');
                            }
                            $fieldValue = '\'' . $fieldValue . '\'';
                            //为时间
                        } else {
                            if ($fieldSetType == 'time' || $fieldSetType == 'now') {
                                if ($fieldValue == '') {
                                    $fieldValue = now();
                                }
                                $fieldValue = '\'' . $fieldValue . '\'';
                                //为时期
                            } else {
                                if ($fieldSetType == 'date') {
                                    if ($fieldValue == '') {
                                        $fieldValue = aspDate();
                                    }
                                    $fieldValue = '\'' . $fieldValue . '\'';
                                } else {
                                    $fieldValue = '\'' . $fieldValue . '\'';
                                }
                            }
                        }
                    }
                }
                $fieldValue = unescape($fieldValue);
                //解码20160418
                if ($valueStr != '') {
                    $valueStr = $valueStr . ',';
                    $editValueStr = $editValueStr . ',';
                }
                $valueStr = $valueStr . $fieldValue;
                $editValueStr = $editValueStr . $fieldName . '=' . $fieldValue;
            }
            if ($fieldList != '') {
                $fieldList = $fieldList . ',';
            }
            $fieldList = $fieldList . $fieldName;
        }
    }
    //自定义字段是否需要写入默认值  有的
    $splStr = aspSplit($fieldNameList, ',');
    foreach ($splStr as $key => $s) {
        if (inStr($s, '|') > 0) {
            $splxx = aspSplit($s . '|||', '|');
            $fieldName = $splxx[0];
            //字段名称
            $fieldSetType = $splxx[1];
            //字段设置类型
            $fieldValue = $splxx[2];
            //默认字段值
            if (inStr($systemFieldList, ',' . $fieldName . '|') > 0 && inStr(',' . $fieldList . ',', ',' . $fieldName . ',') == false) {
                if ($fieldSetType == 'date' && $fieldValue == '') {
                    $fieldValue = aspDate();
                } else {
                    if (($fieldSetType == 'time' || $fieldSetType == 'now') && $fieldValue == '') {
                        $fieldValue = now();
                    }
                }
                if ($fieldSetType != 'yesno' && $fieldSetType != 'numb') {
                    $fieldValue = '\'' . $fieldValue . '\'';
                }
                if ($fieldList != '') {
                    $fieldList = $fieldList . ',';
                    $valueStr = $valueStr . ',';
                    $editValueStr = $editValueStr . ',';
                }
                $fieldList = $fieldList . $fieldName;
                $valueStr = $valueStr . $fieldValue;
                $editValueStr = $editValueStr . $fieldName . '=' . $fieldValue;
                //call echo(fieldName,fieldSetType)
            }
        }
    }
    if ($id == '') {
        $sql = 'insert into ' . $GLOBALS['db_PREFIX'] . '' . $tableName . ' (' . $fieldList . ',updatetime) values(' . $valueStr . ',\'' . now() . '\')';
    } else {
        $sql = 'update ' . $GLOBALS['db_PREFIX'] . '' . $tableName . ' set ' . $editValueStr . ',updatetime=\'' . now() . '\' where id=' . $id;
    }
    $getPostSql = $sql;
    return @$getPostSql;
}
Beispiel #3
0
function updateField()
{
    $tableName = '';
    $id = '';
    $fieldName = '';
    $fieldvalue = '';
    $fieldNameList = '';
    $url = '';
    $tableName = lCase(@$_REQUEST['actionType']);
    //表名称
    $id = @$_REQUEST['id'];
    //id
    $fieldName = lCase(@$_REQUEST['fieldname']);
    //字段名称
    $fieldvalue = @$_REQUEST['fieldvalue'];
    //字段值
    $fieldNameList = getHandleFieldList($GLOBALS['db_PREFIX'] . $tableName, '字段列表');
    //call echo(fieldname,fieldvalue)
    //call echo("fieldNameList",fieldNameList)
    if (inStr($fieldNameList, ',' . $fieldName . ',') == false) {
        Eerr('出错提示', '表(' . $tableName . ')不存在字段(' . $fieldName . ')');
    } else {
        connexecute('update ' . $GLOBALS['db_PREFIX'] . $tableName . ' set ' . $fieldName . '=' . $fieldvalue . ' where id=' . $id);
    }
    $url = getUrlAddToParam(getThisUrl(), '?act=dispalyManageHandle', 'replace');
    Rw(getMsg1('操作成功,正在返回列表...', $url));
}
Beispiel #4
0
function getDetailList($action, $content, $actionName, $lableTitle, $fieldNameList, $nPageSize, $nPage, $addSql)
{
    $GLOBALS['conn='] = OpenConn();
    $defaultStr = '';
    $i = '';
    $s = '';
    $c = '';
    $tableName = '';
    $j = '';
    $splxx = '';
    $sql = '';
    $x = '';
    $url = '';
    $nCount = '';
    $pageInfo = '';
    $modI = '';
    $startStr = '';
    $endStr = '';
    $fieldName = '';
    //字段名称
    $splFieldName = '';
    //分割字段
    $replaceStr = '';
    //替换字符
    $tableName = lCase($actionName);
    //表名称
    $listFileName = '';
    //列表文件名称
    $listFileName = RParam($action, 'listFileName');
    $abcolorStr = '';
    //A加粗和颜色
    $atargetStr = '';
    //A链接打开方式
    $atitleStr = '';
    //A链接的title20160407
    $anofollowStr = '';
    //A链接的nofollow
    $id = '';
    $idPage = '';
    $id = rq('id');
    checkIDSQL(@$_REQUEST['id']);
    if ($fieldNameList == '*') {
        $fieldNameList = getHandleFieldList($GLOBALS['db_PREFIX'] . $tableName, '字段列表');
    }
    $fieldNameList = specialStrReplace($fieldNameList);
    //特殊字符处理
    $splFieldName = aspSplit($fieldNameList, ',');
    //字段分割成数组
    $defaultStr = getStrCut($content, '<!--#body start#-->', '<!--#body end#-->', 2);
    $pageInfo = getStrCut($content, '[page]', '[/page]', 1);
    if ($pageInfo != '') {
        $content = replace($content, $pageInfo, '');
    }
    //call eerr("pageInfo",pageInfo)
    $sql = 'select * from ' . $GLOBALS['db_PREFIX'] . $tableName . ' ' . $addSql;
    //检测SQL
    if (checkSql($sql) == false) {
        errorLog('出错提示:<br>sql=' . $sql . '<br>');
        return '';
    }
    $rsObj = $GLOBALS['conn']->query($sql);
    $rs = mysql_fetch_array($rsObj);
    $nCount = @mysql_num_rows($rsObj);
    //为动态翻页网址
    if ($GLOBALS['isMakeHtml'] == true) {
        $url = '';
        if (len($listFileName) > 5) {
            $url = mid($listFileName, 1, len($listFileName) - 5) . '[id].html';
            $url = urlAddHttpUrl($GLOBALS['cfg_webSiteUrl'], $url);
        }
    } else {
        $url = getUrlAddToParam(getUrl(), '?page=[id]', 'replace');
    }
    $content = replace($content, '[$pageInfo$]', webPageControl($nCount, $nPageSize, $nPage, $url, $pageInfo));
    if (EDITORTYPE == 'asp') {
        $x = getRsPageNumber($rs, $nCount, $nPageSize, $nPage);
        //获得Rs页数                                                  '记录总数
    } else {
        if ($nPage != '') {
            $nPage = $nPage - 1;
        }
        $sql = 'select * from ' . $GLOBALS['db_PREFIX'] . '' . $tableName . ' ' . $addSql . ' limit ' . $nPageSize * $nPage . ',' . $nPageSize;
        $rsObj = $GLOBALS['conn']->query($sql);
        $rs = mysql_fetch_array($rsObj);
        $x = @mysql_num_rows($rsObj);
    }
    //call echo("sql",sql)
    for ($i = 1; $i <= $x; $i++) {
        $rs = mysql_fetch_array($rsObj);
        //给PHP用,因为在 asptophp转换不完善
        $startStr = '[list-' . $i . ']';
        $endStr = '[/list-' . $i . ']';
        //在最后时排序当前交点20160202
        if ($i == $x) {
            $startStr = '[list-end]';
            $endStr = '[/list-end]';
        }
        //例[list-mod2]  [/list-mod2]    20150112
        for ($modI = 6; $modI >= 2; $modI--) {
            if (inStr($defaultStr, $startStr) == false && $i % $modI == 0) {
                $startStr = '[list-mod' . $modI . ']';
                $endStr = '[/list-mod' . $modI . ']';
                if (inStr($defaultStr, $startStr) > 0) {
                    break;
                }
            }
        }
        //没有则用默认
        if (inStr($defaultStr, $startStr) == false || $startStr == '') {
            $startStr = '[list]';
            $endStr = '[/list]';
        }
        if (inStr($defaultStr, $startStr) > 0 && inStr($defaultStr, $endStr) > 0) {
            $s = StrCut($defaultStr, $startStr, $endStr, 2);
            //s = defaultStr
            $s = replace($s, '[$id$]', $rs['id']);
            for ($j = 0; $j <= uBound($splFieldName); $j++) {
                if ($splFieldName[$j] != '') {
                    $splxx = aspSplit($splFieldName[$j] . '|||', '|');
                    $fieldName = $splxx[0];
                    $replaceStr = $rs[$fieldName] . '';
                    $s = replaceValueParam($s, $fieldName, $replaceStr);
                }
                if ($GLOBALS['isMakeHtml'] == true) {
                    $url = getHandleRsUrl($rs['filename'], $rs['customaurl'], '/detail/detail' . $rs['id']);
                } else {
                    $url = handleWebUrl('?act=detail&id=' . $rs['id']);
                    if ($rs['customaurl'] != '') {
                        $url = $rs['customaurl'];
                    }
                }
                //A链接添加颜色
                $abcolorStr = '';
                if (inStr($fieldNameList, ',titlecolor,') > 0) {
                    //A链接颜色
                    if ($rs['titlecolor'] != '') {
                        $abcolorStr = 'color:' . $rs['titlecolor'] . ';';
                    }
                }
                if (inStr($fieldNameList, ',flags,') > 0) {
                    //A链接加粗
                    if (inStr($rs['flags'], '|b|') > 0) {
                        $abcolorStr = $abcolorStr . 'font-weight:bold;';
                    }
                }
                if ($abcolorStr != '') {
                    $abcolorStr = ' style="' . $abcolorStr . '"';
                }
                //打开方式2016
                if (inStr($fieldNameList, ',target,') > 0) {
                    $atargetStr = IIF($rs['target'] != '', ' target="' . $rs['target'] . '"', '');
                }
                //A的title
                if (inStr($fieldNameList, ',title,') > 0) {
                    $atitleStr = IIF($rs['title'] != '', ' title="' . $rs['title'] . '"', '');
                }
                //A的nofollow
                if (inStr($fieldNameList, ',nofollow,') > 0) {
                    $anofollowStr = IIF($rs['nofollow'] != 0, ' rel="nofollow"', '');
                }
                $s = replaceValueParam($s, 'url', $url);
                $s = replaceValueParam($s, 'abcolor', $abcolorStr);
                //A链接加颜色与加粗
                $s = replaceValueParam($s, 'atitle', $atitleStr);
                //A链接title
                $s = replaceValueParam($s, 'anofollow', $anofollowStr);
                //A链接nofollow
                $s = replaceValueParam($s, 'atarget', $atargetStr);
                //A链接打开方式
            }
        }
        //call echo("tableName",tableName)
        $idPage = getThisIdPage($GLOBALS['db_PREFIX'] . $tableName, $rs['id'], 10);
        //【留言】
        if ($tableName == 'guestbook') {
            $url = WEB_ADMINURL . '?act=addEditHandle&actionType=GuestBook&lableTitle=留言&nPageSize=10&parentid=&searchfield=bodycontent&keyword=&addsql=&page=' . $idPage . '&id=' . $rs['id'] . '&n=' . getRnd(11);
            //【默认显示文章】
        } else {
            $url = WEB_ADMINURL . '?act=addEditHandle&actionType=ArticleDetail&lableTitle=分类信息&nPageSize=10&page=' . $idPage . '&parentid=' . $rs['parentid'] . '&id=' . $rs['id'] . '&n=' . getRnd(11);
        }
        $s = handleDisplayOnlineEditDialog($url, $s, '', 'div|li|span');
        $c = $c . $s;
    }
    $content = replace($content, '<!--#body start#-->' . $defaultStr . '<!--#body end#-->', $c);
    if ($GLOBALS['isMakeHtml'] == true) {
        $url = '';
        if (len($listFileName) > 5) {
            $url = mid($listFileName, 1, len($listFileName) - 5) . '[id].html';
            $url = urlAddHttpUrl($GLOBALS['cfg_webSiteUrl'], $url);
        }
    } else {
        $url = getUrlAddToParam(getUrl(), '?page=[id]', 'replace');
    }
    $getDetailList = $content;
    return @$getDetailList;
}