Beispiel #1
0
function DelNews($id, $classid, $userid, $username)
{
    global $empire, $class_r, $class_zr, $bclassid, $public_r, $dbtbpre, $emod_r, $adddatar;
    $id = (int) $id;
    $classid = (int) $classid;
    if (!$id || !$classid) {
        printerror("NotDelNewsid", "history.go(-1)");
    }
    $doselfinfo = CheckLevel($userid, $username, $classid, "news");
    //操作权限
    if (!$doselfinfo['dodelinfo']) {
        printerror("NotDelInfoLevel", "history.go(-1)");
    }
    $ccr = $empire->fetch1("select classid,modid,listdt,haddlist,repreinfo from {$dbtbpre}enewsclass where classid='{$classid}' limit 1");
    if (!$ccr['classid']) {
        printerror("ErrorUrl", "history.go(-1)");
    }
    //索引表
    $index_r = $empire->fetch1("select classid,checked from {$dbtbpre}ecms_" . $class_r[$classid][tbname] . "_index  where id='{$id}' limit 1");
    if (!$index_r[classid] || $index_r[classid] != $classid) {
        printerror("ErrorUrl", "history.go(-1)");
    }
    //返回表
    $infotb = ReturnInfoMainTbname($class_r[$classid][tbname], $index_r['checked']);
    $r = $empire->fetch1("select * from " . $infotb . " where id='{$id}' limit 1");
    if ($doselfinfo['doselfinfo'] && ($r[userid] != $userid || $r[ismember])) {
        printerror("NotDoSelfinfo", "history.go(-1)");
    }
    $pubid = ReturnInfoPubid($classid, $id);
    //附加链接参数
    $addecmscheck = empty($index_r['checked']) ? '&ecmscheck=1' : '';
    $mid = $class_r[$classid][modid];
    $tbname = $class_r[$classid][tbname];
    $pf = $emod_r[$mid]['pagef'];
    $stf = $emod_r[$mid]['savetxtf'];
    //返回表信息
    $infotbr = ReturnInfoTbname($class_r[$classid][tbname], $index_r['checked'], $r['stb']);
    //分页字段
    if ($pf) {
        if (strstr($emod_r[$mid]['tbdataf'], ',' . $pf . ',')) {
            $finfor = $empire->fetch1("select " . $pf . " from " . $infotbr['datatbname'] . " where id='{$id}' limit 1");
            $r[$pf] = $finfor[$pf];
        }
    }
    //存文本
    if ($stf) {
        $newstextfile = $r[$stf];
        $r[$stf] = GetTxtFieldText($r[$stf]);
        DelTxtFieldText($newstextfile);
        //删除文件
    }
    DelNewsFile($r[filename], $r[newspath], $classid, $r[$pf], $r[groupid]);
    //删除信息文件
    $sql = $empire->query("delete from {$dbtbpre}ecms_" . $class_r[$classid][tbname] . "_index where id='{$id}'");
    $sql = $empire->query("delete from " . $infotbr['tbname'] . " where id='{$id}'");
    $fsql = $empire->query("delete from " . $infotbr['datatbname'] . " where id='{$id}'");
    //更新栏目信息数
    AddClassInfos($classid, '-1', '-1', $index_r['checked']);
    //删除其它表记录和附件
    DelSingleInfoOtherData($r['classid'], $id, $r, 0, 0);
    if ($index_r['checked']) {
        //生成上一篇
        if ($ccr['repreinfo']) {
            $prer = $empire->fetch1("select * from {$dbtbpre}ecms_" . $tbname . " where id<{$id} and classid='{$classid}' order by id desc limit 1");
            GetHtml($prer['classid'], $prer['id'], $prer, 1);
            //下一篇
            $nextr = $empire->fetch1("select * from {$dbtbpre}ecms_" . $tbname . " where id>{$id} and classid='{$classid}' order by id limit 1");
            if ($nextr['id']) {
                GetHtml($nextr['classid'], $nextr['id'], $nextr, 1);
            }
        }
        hAddListHtml($classid, $ccr['modid'], $ccr['haddlist'], $ccr['listdt']);
        //生成信息列表
        if ($r['ttid']) {
            ListHtml($r['ttid'], '', 5);
        }
    }
    //同步删除
    if ($r['copyids'] && $r['copyids'] != '1') {
        DelInfoToCopyInfo($classid, $id, $r, $userid, $username, $doselfinfo);
    }
    if ($sql) {
        $returl = $_SERVER['HTTP_REFERER'];
        //发送通知
        if ($adddatar['causetext']) {
            DoInfoSendNotice($userid, $username, $r['userid'], $r['username'], $adddatar['causetext'], $r, 1);
            if ($adddatar['ecmsfrom'] && (stristr($adddatar['ecmsfrom'], 'ListNews.php') || stristr($adddatar['ecmsfrom'], 'ListAllInfo.php'))) {
                $returl = $adddatar['ecmsfrom'];
            } else {
                $returl = "ListNews.php?bclassid={$adddatar['bclassid']}&classid={$adddatar['classid']}" . $addecmscheck . hReturnEcmsHashStrHref2(0);
            }
        } else {
            if ($_POST['enews'] == 'DoInfoAndSendNotice') {
                $returl = "ListNews.php?bclassid={$adddatar['bclassid']}&classid={$adddatar['classid']}" . $addecmscheck . hReturnEcmsHashStrHref2(0);
            }
        }
        insert_dolog("classid={$classid}<br>id=" . $id . "<br>title=" . $r[title], $pubid);
        //操作日志
        printerror("DelNewsSuccess", $returl);
    } else {
        printerror("ErrorUrl", "history.go(-1)");
    }
}
function DelNews($id, $classid, $userid, $username)
{
    global $empire, $class_r, $class_zr, $bclassid, $public_r, $dbtbpre, $emod_r;
    $id = (int) $id;
    $classid = (int) $classid;
    if (!$id || !$classid) {
        printerror("NotDelNewsid", "history.go(-1)");
    }
    $doselfinfo = CheckLevel($userid, $username, $classid, "news");
    //操作权限
    if (!$doselfinfo['dodelinfo']) {
        printerror("NotDelInfoLevel", "history.go(-1)");
    }
    $ccr = $empire->fetch1("select classid,modid,listdt,haddlist,repreinfo from {$dbtbpre}enewsclass where classid='{$classid}'");
    if (!$ccr['classid']) {
        printerror("ErrorUrl", "history.go(-1)");
    }
    $r = $empire->fetch1("select * from {$dbtbpre}ecms_" . $class_r[$classid][tbname] . " where id='{$id}' and classid='{$classid}'");
    if (!$r[classid]) {
        printerror("ErrorUrl", "history.go(-1)");
    }
    if ($doselfinfo['doselfinfo'] && ($r[userid] != $userid || $r[ismember])) {
        printerror("NotDoSelfinfo", "history.go(-1)");
    }
    $mid = $class_r[$classid][modid];
    $tbname = $class_r[$classid][tbname];
    $pf = $emod_r[$mid]['pagef'];
    $stf = $emod_r[$mid]['savetxtf'];
    //分页字段
    if ($pf) {
        if (strstr($emod_r[$mid]['tbdataf'], ',' . $pf . ',')) {
            $finfor = $empire->fetch1("select " . $pf . " from {$dbtbpre}ecms_" . $tbname . "_data_" . $r[stb] . " where id='{$id}'");
            $r[$pf] = $finfor[$pf];
        }
    }
    //存文本
    if ($stf) {
        $newstextfile = $r[$stf];
        $r[$stf] = GetTxtFieldText($r[$stf]);
        DelTxtFieldText($newstextfile);
        //删除文件
    }
    DelNewsFile($r[filename], $r[newspath], $classid, $r[$pf], $r[groupid]);
    //删除信息文件
    $sql = $empire->query("delete from {$dbtbpre}ecms_" . $tbname . " where id='{$id}'");
    $fsql = $empire->query("delete from {$dbtbpre}ecms_" . $tbname . "_data_" . $r[stb] . " where id='{$id}'");
    //删除其它表记录
    $delsql = $empire->query("delete from {$dbtbpre}enewswfinfo where id='{$id}' and classid='{$r['classid']}'");
    $delsql = $empire->query("delete from {$dbtbpre}enewswfinfolog where id='{$id}' and classid='{$r['classid']}'");
    $delsql = $empire->query("delete from {$dbtbpre}enewsinfovote where id='{$id}' and classid='{$r['classid']}'");
    $delsql = $empire->query("delete from {$dbtbpre}enewsdiggips where id='{$id}' and classid='{$r['classid']}'");
    DelNewsTheFile($id, $classid);
    //删除附件
    if ($r['checked']) {
        //生成上一篇
        if ($ccr['repreinfo']) {
            $prer = $empire->fetch1("select * from {$dbtbpre}ecms_" . $tbname . " where id<{$id} and classid='{$classid}' and checked=1 order by id desc limit 1");
            GetHtml($prer, '');
            //下一篇
            $nextr = $empire->fetch1("select * from {$dbtbpre}ecms_" . $tbname . " where id>{$id} and classid='{$classid}' and checked=1 order by id limit 1");
            if ($nextr['id']) {
                GetHtml($nextr, '');
            }
        }
        hAddListHtml($classid, $ccr['modid'], $ccr['haddlist'], $ccr['listdt']);
        //生成信息列表
        if ($r[ztid]) {
            $z_r = explode("|" . $r[ztid] . "|", $r[ztid]);
            for ($z = 1; $z < count($z_r) - 1; $z++) {
                ListHtml(intval($z_r[$z]), '', 1);
            }
        }
    }
    //同步删除
    if ($r['copyids'] && $r['copyids'] != '1') {
        DelInfoToCopyInfo($classid, $id, $r, $userid, $username);
    }
    if ($sql) {
        insert_dolog("classid={$classid}<br>id=" . $id . "<br>title=" . $r[title]);
        //操作日志
        printerror("DelNewsSuccess", $_SERVER['HTTP_REFERER']);
    } else {
        printerror("ErrorUrl", "history.go(-1)");
    }
}