Example #1
0
function EditInfoSimple($add, $userid, $username)
{
    global $empire, $class_r, $class_zr, $bclassid, $public_r, $dbtbpre, $emod_r;
    $add[classid] = (int) $add[classid];
    $userid = (int) $userid;
    $add[id] = (int) $add[id];
    $closeurl = 'info/EditInfoSimple.php?isclose=1&reload=1' . hReturnEcmsHashStrHref2(0);
    if (!$add[id] || !$add[title] || !$add[classid]) {
        printerror("EmptyTitle", "history.go(-1)", 8);
    }
    $doselfinfo = CheckLevel($userid, $username, $add[classid], "news");
    //操作权限
    if (!$doselfinfo['doeditinfo']) {
        printerror("NotEditInfoLevel", "history.go(-1)", 8);
    }
    $ccr = $empire->fetch1("select classid,modid,listdt,haddlist,sametitle,addreinfo,wburl,repreinfo from {$dbtbpre}enewsclass where classid='{$add['classid']}' and islast=1 limit 1");
    if (!$ccr['classid'] || $ccr['wburl']) {
        printerror("ErrorUrl", "history.go(-1)", 8);
    }
    //索引表
    $index_checkr = $empire->fetch1("select id,classid,checked from {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . "_index where id='{$add['id']}' limit 1");
    if (!$index_checkr['id'] || $index_checkr['classid'] != $add['classid']) {
        printerror("ErrorUrl", "history.go(-1)", 8);
    }
    //主表
    $infotb = ReturnInfoMainTbname($class_r[$add[classid]][tbname], $index_checkr['checked']);
    $checkr = $empire->fetch1("select id,classid,userid,username,ismember,stb,newspath,filename,isqf,fstb,isgood,firsttitle,istop,groupid from " . $infotb . " where id='{$add['id']}' limit 1");
    if ($doselfinfo['doselfinfo'] && ($checkr['userid'] != $userid || $checkr['ismember'])) {
        printerror("NotDoSelfinfo", "history.go(-1)", 8);
    }
    //已审核信息不可修改
    if ($doselfinfo['docheckedit'] && $index_checkr['checked']) {
        printerror("NotEditCheckInfoLevel", "history.go(-1)");
    }
    //审核权限
    if (!$doselfinfo['docheckinfo']) {
        $add['checked'] = $index_checkr['checked'];
    }
    //必须审核
    if ($doselfinfo['domustcheck'] && !$index_checkr['checked']) {
        $add['checked'] = 0;
    }
    //推荐权限
    if (!$doselfinfo['dogoodinfo']) {
        $add['isgood'] = $checkr['isgood'];
        $add['firsttitle'] = $checkr['firsttitle'];
        $add['istop'] = $checkr['istop'];
    }
    if ($ccr['sametitle']) {
        if (ReturnCheckRetitle($add)) {
            printerror("ReInfoTitle", "history.go(-1)", 8);
        }
    }
    //公共表
    $pubid = ReturnInfoPubid($add['classid'], $add['id']);
    $pubcheckr = $empire->fetch1("select copyids from {$dbtbpre}enewsinfovote where pubid='{$pubid}' limit 1");
    $mid = $class_r[$add[classid]][modid];
    $pf = $emod_r[$mid]['pagef'];
    $add = DoPostInfoVar($add);
    //返回变量
    //签发
    $newchecked = $index_checkr['checked'];
    $a = "";
    if ($class_r[$add[classid]][wfid] && $checkr['isqf']) {
        $qfr = $empire->fetch1("select checktno from {$dbtbpre}enewswfinfo where id='{$add['id']}' and classid='{$add['classid']}' limit 1");
        if ($qfr['checktno'] == '100') {
            $aqf = ",checked='{$add['checked']}'";
            $newchecked = $add[checked];
        } else {
            if ($add[reworkflow]) {
                InfoUpdateToWorkflow($add[id], $add[classid], $class_r[$add[classid]][wfid], $userid, $username);
            }
            $aqf = '';
        }
    } else {
        $aqf = ",checked='{$add['checked']}'";
        $newchecked = $add[checked];
    }
    $lastdotime = time();
    //发布时间
    $newstime = empty($add['newstime']) ? time() : to_time($add['newstime']);
    //附加链接参数
    $addecmscheck = empty($newchecked) ? '&ecmscheck=1' : '';
    //信息地址
    $infourl = GotoGetTitleUrl($add['classid'], $add['id'], $checkr['newspath'], $checkr['filename'], $checkr['groupid'], $add['isurl'], $add['titleurl']);
    //返回表信息
    $infotbr = ReturnInfoTbname($class_r[$add[classid]][tbname], $index_checkr['checked'], $checkr['stb']);
    //索引表
    $indexsql = $empire->query("update {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . "_index set newstime='{$newstime}',lastdotime='{$lastdotime}'" . $aqf . " where id='{$add['id']}' limit 1");
    //主表
    $sql = $empire->query("update " . $infotbr['tbname'] . " set classid='{$add['classid']}',ttid='{$add['ttid']}',onclick='{$add['onclick']}',totaldown='{$add['totaldown']}',firsttitle='{$add['firsttitle']}',isgood='{$add['isgood']}',ispic='{$add['ispic']}',istop='{$add['istop']}',isurl='{$add['isurl']}',lastdotime='{$lastdotime}',titlefont='" . addslashes($add[my_titlefont]) . "',titleurl='" . addslashes($infourl) . "',title='" . addslashes($add[title]) . "',titlepic='" . addslashes($add[titlepic]) . "',newstime='{$newstime}' where id='{$add['id']}' limit 1");
    //副表
    $fsql = $empire->query("update " . $infotbr['datatbname'] . " set classid='{$add['classid']}',closepl='{$add['closepl']}'" . $ret_r[datavalues] . " where id='{$add['id']}' limit 1");
    //更新附件
    UpdateTheFileEdit($add['classid'], $add['id'], $checkr['fstb']);
    //是否改变审核状态
    if ($index_checkr['checked'] != $newchecked) {
        MoveCheckInfoData($class_r[$add[classid]][tbname], $index_checkr['checked'], $checkr['stb'], "id='{$add['id']}'");
        //更新栏目信息数
        if ($newchecked) {
            AddClassInfos($add['classid'], '', '+1');
        } else {
            AddClassInfos($add['classid'], '', '-1');
        }
    }
    //生成文件
    if ($ccr['addreinfo'] && $newchecked) {
        GetHtml($add['classid'], $add['id'], '', 0);
    }
    //生成上一篇
    if ($ccr['repreinfo'] && ($newchecked || $newchecked != $add[oldchecked])) {
        $prer = $empire->fetch1("select * from {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " where id<{$add['id']} and classid='{$add['classid']}' order by id desc limit 1");
        GetHtml($prer['classid'], $prer['id'], $prer, 1);
    }
    //生成栏目
    if ($ccr['haddlist'] && ($newchecked || $newchecked != $add[oldchecked])) {
        hAddListHtml($add[classid], $ccr['modid'], $ccr['haddlist'], $ccr['listdt']);
        //生成信息列表
    }
    //同时更新
    if ($checkr['copyids'] && $checkr['copyids'] != '1') {
        EditInfoToCopyInfo($add[classid], $add[id], $userid, $username, $doselfinfo);
    }
    if ($sql) {
        //返回地址
        if ($add['ecmsfrom'] && (stristr($add['ecmsfrom'], 'ListNews.php') || stristr($add['ecmsfrom'], 'ListAllInfo.php'))) {
            $ecmsfrom = $add['ecmsfrom'];
        } else {
            $ecmsfrom = "ListNews.php?bclassid={$add['bclassid']}&classid={$add['classid']}" . hReturnEcmsHashStrHref2(0);
        }
        $ecmsfrom = $ecmsfrom . $addecmscheck;
        insert_dolog("classid={$add['classid']}<br>id=" . $add[id] . "<br>title=" . $add[title], $pubid);
        //操作日志
        printerror("EditNewsSuccess", $closeurl, 8);
    } else {
        printerror("DbError", "history.go(-1)", 8);
    }
}
Example #2
0
function EditInfoSimple($add, $userid, $username)
{
    global $empire, $class_r, $class_zr, $bclassid, $public_r, $dbtbpre, $emod_r;
    $add[classid] = (int) $add[classid];
    $userid = (int) $userid;
    $ztid = $add[ztid];
    $add[id] = (int) $add[id];
    $closeurl = 'info/EditInfoSimple.php?isclose=1&reload=1';
    if (!$add[id] || !$add[title] || !$add[classid]) {
        printerror("EmptyTitle", "history.go(-1)", 8);
    }
    $doselfinfo = CheckLevel($userid, $username, $add[classid], "news");
    //操作权限
    if (!$doselfinfo['doeditinfo']) {
        printerror("NotEditInfoLevel", "history.go(-1)", 8);
    }
    $ccr = $empire->fetch1("select classid,modid,listdt,haddlist,sametitle,addreinfo,wburl,repreinfo from {$dbtbpre}enewsclass where classid='{$add['classid']}' and islast=1");
    if (!$ccr['classid'] || $ccr[wburl]) {
        printerror("ErrorUrl", "history.go(-1)", 8);
    }
    $checkr = $empire->fetch1("select id,userid,username,ismember,stb,copyids,newspath,filename,isqf,checked from {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " where id='{$add['id']}' and classid='{$add['classid']}'");
    if (!$checkr[id]) {
        printerror("ErrorUrl", "history.go(-1)", 8);
    }
    if ($doselfinfo['doselfinfo'] && ($checkr[userid] != $userid || $checkr[ismember])) {
        printerror("NotDoSelfinfo", "history.go(-1)", 8);
    }
    if ($ccr['sametitle']) {
        $num = $empire->gettotal("select count(*) as total from {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " where title='{$add['title']}' and id<>{$add['id']} limit 1");
        if ($num) {
            printerror("ReInfoTitle", "history.go(-1)", 8);
        }
    }
    $mid = $class_r[$add[classid]][modid];
    $pf = $emod_r[$mid]['pagef'];
    $add = DoPostInfoVar($add);
    //返回变量
    //签发
    $a = "";
    if ($class_r[$add[classid]][wfid] && $checkr['isqf']) {
        $qfr = $empire->fetch1("select checktno from {$dbtbpre}enewswfinfo where id='{$add['id']}' and classid='{$add['classid']}' limit 1");
        if ($qfr['checktno'] == '100') {
            $aqf = ",checked='{$add['checked']}'";
        } else {
            if ($add[reworkflow]) {
                InfoUpdateToWorkflow($add[id], $add[classid], $class_r[$add[classid]][wfid], $userid, $username);
            }
            $aqf = '';
        }
    } else {
        $aqf = ",checked='{$add['checked']}'";
    }
    $lastdotime = time();
    //发布时间
    $newstime = empty($add['newstime']) ? time() : to_time($add['newstime']);
    //主表
    $sql = $empire->query("update {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " set classid='{$add['classid']}',istop='{$add['istop']}',isgood='{$add['isgood']}',titlefont='" . addslashes($add[my_titlefont]) . "',titleurl='" . addslashes($add[titleurl]) . "',firsttitle='{$add['firsttitle']}',closepl='{$add['closepl']}',lastdotime='{$lastdotime}',ttid='{$add['ttid']}',onclick='{$add['onclick']}',totaldown='{$add['totaldown']}',ispic='{$add['ispic']}',title='" . addslashes($add[title]) . "',titlepic='" . addslashes($add[titlepic]) . "',newstime='{$newstime}'" . $aqf . " where id='{$add['id']}'");
    //更新附件
    UpdateTheFileEdit($add['classid'], $add['id']);
    //生成文件
    if ($ccr['addreinfo']) {
        $ar = $empire->fetch1("select * from {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " where id='{$add['id']}'");
        GetHtml($ar, '');
    }
    //生成上一篇
    if ($ccr['repreinfo'] && ($add[checked] || $add[checked] != $add[oldchecked])) {
        $prer = $empire->fetch1("select * from {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " where id<{$add['id']} and classid='{$add['classid']}' and checked=1 order by id desc limit 1");
        GetHtml($prer, '');
    }
    //生成栏目
    if ($ccr['haddlist'] && ($add[checked] || $add[checked] != $add[oldchecked])) {
        hAddListHtml($add[classid], $ccr['modid'], $ccr['haddlist'], $ccr['listdt']);
        //生成信息列表
    }
    //同时更新
    if ($checkr['copyids'] && $checkr['copyids'] != '1') {
        EditInfoToCopyInfo($add[classid], $add[id], $userid, $username);
    }
    if ($sql) {
        //返回地址
        if ($add['ecmsfrom'] && (stristr($add['ecmsfrom'], 'ListNews.php') || stristr($add['ecmsfrom'], 'ListAllInfo.php'))) {
            $ecmsfrom = $add['ecmsfrom'];
        } else {
            $ecmsfrom = "ListNews.php?bclassid={$add['bclassid']}&classid={$add['classid']}";
        }
        insert_dolog("classid={$add['classid']}<br>id=" . $add[id] . "<br>title=" . $add[title]);
        //操作日志
        printerror("EditNewsSuccess", $closeurl, 8);
    } else {
        printerror("DbError", "history.go(-1)", 8);
    }
}