if ($emod_r[$modid]['tbdataf'] && $emod_r[$modid]['tbdataf'] != ',') { $selectdataf = substr($emod_r[$modid]['tbdataf'], 1, -1); $finfor = $empire->fetch1("select " . $selectdataf . " from {$dbtbpre}ecms_" . $class_r[$classid][tbname] . "_data_" . $r[stb] . " where id='{$id}'"); $r = array_merge($r, $finfor); } //时间 $newstime = $r['newstime']; $r['newstime'] = date("Y-m-d H:i:s", $r['newstime']); //会员组 $group = str_replace(" value=" . $r[groupid] . ">", " value=" . $r[groupid] . " selected>", $ygroup); //内容存文本 $savetxtf = $emod_r[$modid]['savetxtf']; $newstext_url = ''; if ($savetxtf) { $newstext_url = $r[$savetxtf]; $r[$savetxtf] = GetTxtFieldText($r[$savetxtf]); } //标题属性 if (strstr($r[titlefont], ',')) { $tfontr = explode(',', $r[titlefont]); $r[titlecolor] = $tfontr[0]; $r[titlefont] = $tfontr[1]; } if (strstr($r[titlefont], "b|")) { $titlefontb = " checked"; } if (strstr($r[titlefont], "i|")) { $titlefonti = " checked"; } if (strstr($r[titlefont], "s|")) { $titlefonts = " checked";
//权限 if ($r['groupid'] || $class_r[$classid]['cgtoinfo']) { define('empirecms', 'wm_chief'); define('PageCheckLevel', 'wm_chief'); $check_tbname = $tbname; $check_infoid = $id; $check_classid = $classid; $check_path = "../../"; $checkinfor = $r; @(include "../class/CheckLevel.php"); } //存文本 if ($emod_r[$mid]['savetxtf']) { $stf = $emod_r[$mid]['savetxtf']; if ($r[$stf]) { $r[$stf] = GetTxtFieldText($r[$stf]); } } //初始值 $search = "&classid={$classid}&id={$id}"; $line = 1; $start = 0; $page_line = 6; //每页显示链接数 $offset = $page * $line; //总偏移量 $GLOBALS['navclassid'] = $r[classid]; $GLOBALS['navinfor'] = $r; //取得内容模板 $r[newstempid] = $r[newstempid] ? $r[newstempid] : $class_r[$r[classid]][newstempid]; $newstemp_r = $empire->fetch1("select tempid,temptext,showdate from " . GetTemptb("enewsnewstemp") . " where tempid='{$r['newstempid']}'");
function LoadSearchAll($lid, $start, $userid, $username) { global $empire, $dbtbpre, $class_r, $fun_r, $public_r, $emod_r; $lid = (int) $lid; if (empty($lid)) { printerror('ErrorUrl', ''); } $lr = $empire->fetch1("select tbname,titlefield,infotextfield,loadnum,lastid from {$dbtbpre}enewssearchall_load where lid='{$lid}'"); if (empty($lr['tbname'])) { printerror('ErrorUrl', ''); } //不导入栏目 $pr = $empire->fetch1("select schallnotcid from {$dbtbpre}enewspublic limit 1"); $line = $lr['loadnum']; if (empty($line)) { $line = 300; } $start = (int) $start; if ($start < $lr['lastid']) { $start = $lr['lastid']; } //字段 $selectdtf = ''; $selectf = ''; $savetxtf = ''; $fsql = $empire->query("select tid,f,savetxt,tbdataf from {$dbtbpre}enewsf where (f='{$lr['titlefield']}' or f='{$lr['infotextfield']}') and tbname='{$lr['tbname']}' limit 2"); while ($fr = $empire->fetch($fsql)) { if ($fr['tbdataf']) { $selectdtf .= ',' . $fr[f]; } else { $selectf .= ',' . $fr[f]; } if ($fr['savetxt']) { $savetxtf = $fr[f]; } } $b = 0; $sql = $empire->query("select id,stb,classid,isurl,newstime" . $selectf . " from {$dbtbpre}ecms_" . $lr['tbname'] . " where id>{$start} order by id limit " . $line); while ($r = $empire->fetch($sql)) { $b = 1; $newstart = $r['id']; if ($r['isurl']) { continue; } if (empty($class_r[$r[classid]]['tbname'])) { continue; } if (strstr($pr['schallnotcid'], ',' . $r[classid] . ',')) { continue; } //重复 $havenum = $empire->gettotal("select count(*) as total from {$dbtbpre}enewssearchall where id='{$r['id']}' and classid='{$r['classid']}' limit 1"); if ($havenum) { continue; } //副表 if ($selectdtf) { $finfor = $empire->fetch1("select id" . $selectdtf . " from {$dbtbpre}ecms_" . $lr['tbname'] . "_data_" . $r[stb] . " where id='{$r['id']}'"); $r = array_merge($r, $finfor); } //存文本 if ($savetxtf) { $r[$savetxtf] = GetTxtFieldText($r[$savetxtf]); } $infotext = $r[$lr[infotextfield]]; $title = $r[$lr[titlefield]]; $infotime = $r[newstime]; $title = SearchReturnSaveStr(ClearSearchAllHtml(stripSlashes($title))); $infotext = SearchReturnSaveStr(ClearSearchAllHtml(stripSlashes($infotext))); $empire->query("insert into {$dbtbpre}enewssearchall(sid,id,classid,title,infotime,infotext) values(NULL,'{$r['id']}','{$r['classid']}','" . addslashes($title) . "','{$infotime}','" . addslashes($infotext) . "');"); } if (empty($b)) { $lasttime = time(); if (empty($newstart)) { $newstart = $start; } $empire->query("update {$dbtbpre}enewssearchall_load set lasttime='{$lasttime}',lastid='{$newstart}' where lid='{$lid}'"); echo "<link rel=\"stylesheet\" href=\"../../data/images/css.css\" type=\"text/css\"><center><b>" . $lr['tbname'] . $fun_r[LoadSearchAllIsOK] . "</b></center>"; db_close(); $empire = null; exit; } echo "<link rel=\"stylesheet\" href=\"../../data/images/css.css\" type=\"text/css\"><meta http-equiv=\"refresh\" content=\"0;url=LoadSearchAll.php?enews=LoadSearchAll&lid={$lid}&start={$newstart}" . hReturnEcmsHashStrHref(0) . "\">" . $fun_r[OneLoadSearchAllSuccess] . "(ID:<font color=red><b>" . $newstart . "</b></font>)"; exit; }
function GetHtml($add, $fields, $doall = 0) { global $public_r, $class_r, $class_zr, $fun_r, $empire, $dbtbpre, $emod_r, $class_tr, $level_r, $etable_r; if (empty($doall)) { if ($add['titleurl'] || $add['checked'] == 0 || $class_r[$add[classid]][showdt] == 2 || strstr($public_r['nreinfo'], ',' . $add['classid'] . ',')) { return ''; } } $mid = $class_r[$add[classid]]['modid']; $tbname = $class_r[$add[classid]][tbname]; //副表 if ($emod_r[$mid]['tbdataf'] && $emod_r[$mid]['tbdataf'] != ',') { $selectdataf = substr($emod_r[$mid]['tbdataf'], 1, -1); $addr = $empire->fetch1("select " . $selectdataf . " from {$dbtbpre}ecms_" . $tbname . "_data_" . $add[stb] . " where id='{$add['id']}'"); $add = array_merge($add, $addr); } $iclasspath = ReturnSaveInfoPath($add[classid], $add[id]); $doclasspath = ECMS_PATH . $iclasspath; $createinfopath = $doclasspath; //建立日期目录 $newspath = ''; if ($add[newspath]) { $createpath = $doclasspath . $add[newspath]; if (!file_exists($createpath)) { $r[newspath] = FormatPath($add[classid], $add[newspath], 1); } $createinfopath .= $add[newspath] . '/'; $newspath = $add[newspath] . '/'; } //新建存放目录 if ($class_r[$add[classid]][filename] == 3) { $createinfopath .= ReturnInfoSPath($add['filename']); DoMkdir($createinfopath); $fn3 = 1; } //存文本 if ($emod_r[$mid]['savetxtf']) { $stf = $emod_r[$mid]['savetxtf']; if ($add[$stf]) { $add[$stf] = GetTxtFieldText($add[$stf]); } } $GLOBALS['navclassid'] = $add[classid]; $GLOBALS['navinfor'] = $add; //取得内容模板 $add[newstempid] = $add[newstempid] ? $add[newstempid] : $class_r[$add[classid]][newstempid]; $newstemp_r = GetNewsTemp($add[newstempid]); $newstemptext = $newstemp_r[temptext]; $formatdate = $newstemp_r[showdate]; //页面 $pagetitle = htmlspecialchars($add[title]); $url = ReturnClassLink($add[classid]); //导航 $newstemptext = Info_ReplaceSvars($newstemptext, $url, $add[classid], $pagetitle, $add[keyboard], $pagetitle); //文件类型/权限 if ($add[groupid] || $class_r[$add[classid]]['cgtoinfo']) { if (empty($add[newspath])) { $include = ''; } else { $pr = explode('/', $add[newspath]); for ($i = 0; $i < count($pr); $i++) { $include .= '../'; } } if ($fn3 == 1) { $include .= '../'; } $pr = explode('/', $iclasspath); $pcount = count($pr); for ($i = 0; $i < $pcount - 1; $i++) { $include .= '../'; } $include1 = $include; $include .= 'e/class/CheckLevel.php'; $filetype = '.php'; $addlevel = "<?php\r\n\t\tdefine('empirecms','wm_chief');\r\n\t\t\$check_tbname='" . $class_r[$add[classid]][tbname] . "';\r\n\t\t\$check_infoid=" . $add[id] . ";\r\n\t\t\$check_classid=" . $add[classid] . ";\r\n\t\t\$check_path=\"" . $include1 . "\";\r\n\t\trequire(\"" . $include . "\");\r\n\t\t?>"; } else { $filetype = $class_r[$add[classid]][filetype]; $addlevel = ''; } //取得本目录链接 if ($class_r[$add[classid]][classurl] && $class_r[$add[classid]][ipath] == '') { $dolink = $class_r[$add[classid]][classurl] . '/' . $newspath; } else { $dolink = $public_r[newsurl] . $iclasspath . $newspath; } //相关信息 if (strstr($newstemptext, '[!--other.link--]')) { $keyboardtext = GetKeyboard($add[keyboard], $add[keyid], $add[classid], $add[id], $class_r[$add[classid]][link_num]); } $onclick = "<script src='" . $public_r[newsurl] . "e/public/onclick?enews=donews&classid={$add['classid']}&id=" . $add[id] . "'></script>"; //返回替换验证字符 $docheckrep = ReturnCheckDoRepStr(); if ($add[newstext]) { if (empty($public_r['dorepword']) && $docheckrep[3]) { $add[newstext] = ReplaceWord($add[newstext]); //过滤字符 } if (empty($public_r['dorepkey']) && $docheckrep[4] && !empty($add[dokey])) { $add[newstext] = ReplaceKey($add[newstext]); } if ($public_r['opencopytext']) { $add[newstext] = AddNotCopyRndStr($add[newstext]); //随机复制字符 } } //分页字段 $expage = '[!--empirenews.page--]'; //分页符 $pf = $emod_r[$mid]['pagef']; //变量 $tempf = $emod_r[$mid]['tempf']; if ($pf && strstr($add[$pf], $expage)) { $tempf = str_replace(',' . $pf . ',', ',', $tempf); } $fr = explode(',', $tempf); $fcount = count($fr) - 1; //变量替换 $newstempstr = $newstemptext; //模板 for ($i = 1; $i < $fcount; $i++) { $f = $fr[$i]; $value = $add[$f]; if ($f == 'downpath') { if (strstr($newstemptext, '[!--downpath--]')) { $value = ReturnDownSoftHtml($add); } } elseif ($f == 'onlinepath') { if (strstr($newstemptext, '[!--onlinepath--]')) { $value = ReturnOnlinepathHtml($add); } } elseif ($f == 'morepic') { if (strstr($newstemptext, '[!--morepic--]')) { $value = ReturnMorepicpathHtml($add); } } elseif ($f == 'newstime') { if (strstr($newstemptext, '[!--newstime--]')) { $value = date($formatdate, $value); } } elseif ($f == 'befrom') { if ($docheckrep[1] && strstr($newstemptext, '[!--befrom--]')) { $value = ReplaceBefrom($value); } } elseif ($f == 'writer') { if ($docheckrep[2] && strstr($newstemptext, '[!--writer--]')) { $value = ReplaceWriter($value); } } elseif ($f == 'titlepic') { if (empty($value)) { $value = $public_r[newsurl] . 'e/data/images/notimg.gif'; } } elseif ($f == 'title') { } else { if (!strstr($emod_r[$mid]['editorf'], ',' . $f . ',')) { if (strstr($emod_r[$mid]['tobrf'], ',' . $f . ',')) { $value = nl2br($value); } if (!strstr($emod_r[$mid]['dohtmlf'], ',' . $f . ',')) { $value = RepFieldtextNbsp(htmlspecialchars($value)); } } } $newstempstr = str_replace('[!--' . $f . '--]', $value, $newstempstr); } //固定变量 $newstempstr = str_replace('[!--id--]', $add[id], $newstempstr); $newstempstr = str_replace('[!--classid--]', $add[classid], $newstempstr); $newstempstr = str_replace('[!--class.name--]', $class_r[$add[classid]][classname], $newstempstr); $newstempstr = str_replace('[!--ttid--]', $add[ttid], $newstempstr); $newstempstr = str_replace('[!--tt.name--]', $class_tr[$add[ttid]][tname], $newstempstr); $newstempstr = str_replace('[!--onclick--]', $add[onclick], $newstempstr); $newstempstr = str_replace('[!--userfen--]', $add[userfen], $newstempstr); $newstempstr = str_replace('[!--username--]', $add[username], $newstempstr); //带链接的用户名 if ($add[ismember] == 1 && $add[userid]) { $newstempstr = str_replace('[!--linkusername--]', "<a href='" . $public_r[newsurl] . "e/space/?userid=" . $add[userid] . "' target=_blank>" . $add[username] . "</a>", $newstempstr); } else { $newstempstr = str_replace('[!--linkusername--]', $add[username], $newstempstr); } $newstempstr = str_replace('[!--userid--]', $add[userid], $newstempstr); $newstempstr = str_replace('[!--other.link--]', $keyboardtext, $newstempstr); $newstempstr = str_replace('[!--news.url--]', $public_r[newsurl], $newstempstr); $newstempstr = str_replace('[!--plnum--]', $add[plnum], $newstempstr); $newstempstr = str_replace('[!--totaldown--]', $add[totaldown], $newstempstr); $newstempstr = str_replace('[!--keyboard--]', $add[keyboard], $newstempstr); //链接 $titleurl = sys_ReturnBqTitleLink($add); $newstempstr = str_replace('[!--titleurl--]', $titleurl, $newstempstr); $newstempstr = str_replace('[!--page.stats--]', $onclick, $newstempstr); $classurl = sys_ReturnBqClassname($add, 9); $newstempstr = str_replace('[!--class.url--]', $classurl, $newstempstr); //下一篇 if (strstr($newstemptext, '[!--info.next--]')) { $next_r = $empire->fetch1("select titleurl,groupid,classid,newspath,filename,id,title from {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " where id>{$add['id']} and classid='{$add['classid']}' and checked=1 order by id limit 1"); if (empty($next_r[id])) { $infonext = "<a href='" . $classurl . "'>" . $fun_r['HaveNoNextLink'] . "</a>"; } else { //链接 $nexttitleurl = sys_ReturnBqTitleLink($next_r); $infonext = "<a href='" . $nexttitleurl . "'>" . $next_r[title] . "</a>"; } $newstempstr = str_replace('[!--info.next--]', $infonext, $newstempstr); } //上一篇 if (strstr($newstemptext, '[!--info.pre--]')) { $next_r = $empire->fetch1("select titleurl,groupid,classid,newspath,filename,id,title 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"); if (empty($next_r[id])) { $infonext = "<a href='" . $classurl . "'>" . $fun_r['HaveNoNextLink'] . "</a>"; } else { //链接 $nexttitleurl = sys_ReturnBqTitleLink($next_r); $infonext = "<a href='" . $nexttitleurl . "'>" . $next_r[title] . "</a>"; } $newstempstr = str_replace('[!--info.pre--]', $infonext, $newstempstr); } //投票 if (strstr($newstemptext, '[!--info.vote--]')) { $myvotetext = sys_GetInfoVote($add[classid], $add[id]); $newstempstr = str_replace('[!--info.vote--]', $myvotetext, $newstempstr); } //评分 if (strstr($newstemptext, '[!--pinfopfen--]')) { $pinfopfen = $add[infopfennum] ? round($add[infopfen] / $add[infopfennum]) : 0; $newstempstr = str_replace('[!--pinfopfen--]', $pinfopfen, $newstempstr); $newstempstr = str_replace('[!--infopfennum--]', $add[infopfennum], $newstempstr); } if ($pf && strstr($add[$pf], $expage)) { $n_r = explode($expage, $add[$pf]); $thispagenum = count($n_r); //取得分页 $thefun = $public_r['textpagefun'] ? $public_r['textpagefun'] : 'sys_ShowTextPage'; //下拉式分页 if (strstr($newstemptext, '[!--title.select--]')) { $dotitleselect = sys_ShowTextPageSelect($thispagenum, $dolink, $add, $filetype, $n_r); } for ($j = 1; $j <= $thispagenum; $j++) { $string = $newstempstr; //模板 $truepage = ''; $titleselect = ''; //下一页链接 if ($thispagenum == $j) { $thisnextlink = $dolink . $add[filename] . $filetype; } else { $thisj = $j + 1; $thisnextlink = $dolink . $add[filename] . '_' . $thisj . $filetype; } $k = $j - 1; if ($j == 1) { $file = $doclasspath . $newspath . $add[filename] . $filetype; $ptitle = $add[title]; } else { $file = $doclasspath . $newspath . $add[filename] . '_' . $j . $filetype; $ti_r = explode('[/!--empirenews.page--]', $n_r[$k]); if (count($ti_r) >= 2) { $ptitle = $ti_r[0]; $n_r[$k] = $ti_r[1]; } else { $ptitle = $add[title] . '(' . $j . ')'; } } //取得当前页 if ($thispagenum != 1) { $truepage = $thefun($thispagenum, $j, $dolink, $add, $filetype, ''); $titleselect = str_replace("?" . $j . "\">", "?" . $j . "\" selected>", $dotitleselect); } //替换变量 $newstext = $n_r[$k]; if (!strstr($emod_r[$mid]['editorf'], ',' . $pf . ',')) { if (strstr($emod_r[$mid]['tobrf'], ',' . $pf . ',')) { $newstext = nl2br($newstext); } if (!strstr($emod_r[$mid]['dohtmlf'], ',' . $pf . ',')) { $newstext = htmlspecialchars($newstext); $newstext = RepFieldtextNbsp($newstext); } } $string = str_replace('[!--' . $pf . '--]', $newstext, $string); $string = str_replace('[!--p.title--]', $ptitle, $string); $string = str_replace('[!--next.page--]', $thisnextlink, $string); $string = str_replace('[!--page.url--]', $truepage, $string); $string = str_replace('[!--title.select--]', $titleselect, $string); //写文件 WriteFiletext($file, $addlevel . $string); } } else { $file = $doclasspath . $newspath . $add[filename] . $filetype; $string = $newstempstr; //模板 //替换变量 $string = str_replace('[!--p.title--]', $add[title], $string); $string = str_replace('[!--next.page--]', '', $string); $string = str_replace('[!--page.url--]', '', $string); $string = str_replace('[!--title.select--]', '', $string); //写文件 WriteFiletext($file, $addlevel . $string); } //设为已生成 if (empty($add['havehtml'])) { $empire->query("update {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " set havehtml=1 where id='{$add['id']}' limit 1"); } }
function DelClassTranFile($classid) { global $empire, $class_r, $dbtbpre, $emod_r; //删除存文本 $mid = $class_r[$classid][modid]; $savetxtf = $emod_r[$mid]['savetxtf']; if ($savetxtf) { $txtsql = $empire->query("select " . $savetxtf . " from {$dbtbpre}ecms_" . $class_r[$classid][tbname] . " where classid='{$classid}'"); while ($txtr = $empire->fetch($txtsql)) { $newstextfile = $txtr[$savetxtf]; $txtr[$savetxtf] = GetTxtFieldText($txtr[$savetxtf]); DelTxtFieldText($newstextfile); //删除文件 } } //删除附件 $filesql = $empire->query("select id from {$dbtbpre}ecms_" . $class_r[$classid][tbname] . " where classid='{$classid}'"); while ($filer = $empire->fetch($filesql)) { DelNewsTheFile($filer[id], $classid); //删除附件 } }
function DoAutoUpAndDownInfo() { global $empire, $dbtbpre, $class_r, $emod_r, $public_r; $todaytime = time(); $sql = $empire->query("select id,classid,infouptime,infodowntime from {$dbtbpre}enewsinfovote where infouptime>0 or infodowntime>0"); while ($r = $empire->fetch($sql)) { if (!$class_r[$r[classid]]['tbname']) { continue; } //上线 if ($r['infouptime'] && $r['infouptime'] <= $todaytime) { $infor = $empire->fetch1("select * from {$dbtbpre}ecms_" . $class_r[$r[classid]][tbname] . " where id='{$r['id']}'"); if (!$infor['id']) { continue; } //签发 if ($infor['isqf']) { $qfr = $empire->fetch1("select checktno from {$dbtbpre}enewswfinfo where id='{$r['id']}' and classid='{$r['classid']}' limit 1"); if ($qfr['checktno'] != '100') { continue; } } $empire->query("update {$dbtbpre}ecms_" . $class_r[$r[classid]][tbname] . " set checked=1 where id='{$r['id']}'"); $empire->query("update {$dbtbpre}enewsinfovote set infouptime=0 where id='{$r['id']}' and classid='{$r['classid']}' limit 1"); $infor['checked'] = 1; //刷新信息 GetHtml($infor, ''); //刷新列表 ReListHtml($r[classid], 1); } //下线 if ($r['infodowntime'] && $r['infodowntime'] <= $todaytime) { $mid = $class_r[$r[classid]][modid]; $tbname = $class_r[$r[classid]][tbname]; $pf = $emod_r[$mid]['pagef']; $stf = $emod_r[$mid]['savetxtf']; //主表 $infor = $empire->fetch1("select * from {$dbtbpre}ecms_" . $class_r[$r[classid]][tbname] . " where id='" . $r[id] . "'"); if (!$infor['id']) { continue; } //签发 if ($infor['isqf']) { $qfr = $empire->fetch1("select checktno from {$dbtbpre}enewswfinfo where id='{$r['id']}' and classid='{$r['classid']}' limit 1"); if ($qfr['checktno'] != '100') { continue; } } //分页字段 if ($pf) { if (strstr($emod_r[$mid]['tbdataf'], ',' . $pf . ',')) { $finfor = $empire->fetch1("select " . $pf . " from {$dbtbpre}ecms_" . $tbname . "_data_" . $infor[stb] . " where id='{$r['id']}'"); $infor[$pf] = $finfor[$pf]; } if ($stf && $stf == $pf) { $infor[$pf] = GetTxtFieldText($infor[$pf]); } } DelNewsFile($infor[filename], $infor[newspath], $infor[classid], $infor[$pf], $infor[groupid]); $empire->query("update {$dbtbpre}ecms_" . $class_r[$r[classid]][tbname] . " set checked=0,havehtml=0 where id='{$r['id']}'"); $empire->query("update {$dbtbpre}enewsinfovote set infodowntime=0 where id='{$r['id']}' and classid='{$r['classid']}' limit 1"); //刷新列表 ReListHtml($r[classid], 1); } } }
function DoRepNewstext($start,$oldword,$newword,$field,$classid,$tid,$tbname,$over,$dozz,$dotxt,$userid,$username){ global $empire,$public_r,$class_r,$fun_r,$dbtbpre,$emod_r; $tbname=RepPostVar($tbname); $field=RepPostVar($field); $tid=(int)$tid; $dotype=(int)$_POST['dotype']; $classid=(int)$classid; if(!$field||empty($tbname)||!$tid) { printerror("FailCX","history.go(-1)"); } if($dotype==0&&strlen($oldword)==0) { printerror("FailCX","history.go(-1)"); } CheckLevel($userid,$username,$classid,"repnewstext");//验证权限 //变量替换 $postoldword=ClearAddsData($oldword); $postnewword=ClearAddsData($newword); //替换条件 if($classid)//按栏目替换 { if(empty($class_r[$classid][islast]))//中级栏目 { $where=ReturnClass($class_r[$classid][sonclass]); } else//终极栏目 { $where="classid='$classid'"; } $add1=" and (".$where.")"; $add2=" where (".$where.")"; } $fr=$empire->fetch1("select tid,savetxt,tbdataf from {$dbtbpre}enewsf where tbname='$tbname' and f='$field' limit 1"); //系统字段 $specialdatafield=',keyid,dokey,newstempid,closepl,haveaddfen,infotags,'; if(!$fr['tid']&&stristr($specialdatafield,','.$field.',')) { $fr['tbdataf']=1; } //覆盖方式 if($dotype==1) { $repoldword=addslashes($oldword); $repnewword=addslashes($newword); if($over==1)//完全替换 { if(empty($add2)) { $and=" where "; } else { $and=" and "; } $add2.=$and.$field."='".$repoldword."'"; } if($fr['tbdataf'])//副表 { //已审核 $tbr=$empire->fetch1("select datatbs from {$dbtbpre}enewstable where tbname='$tbname' limit 1"); if($tbr['datatbs']) { $dtbr=explode(',',$tbr['datatbs']); $count=count($dtbr); for($i=1;$i<$count-1;$i++) { $empire->query("update {$dbtbpre}ecms_".$tbname."_data_".$dtbr[$i]." set ".$field."='$repnewword'".$add2); } } //未审核 $empire->query("update {$dbtbpre}ecms_".$tbname."_check_data set ".$field."='$repnewword'".$add2); } else//主表 { $empire->query("update {$dbtbpre}ecms_".$tbname." set ".$field."='$repnewword'".$add2); //未审核 $empire->query("update {$dbtbpre}ecms_".$tbname."_check set ".$field."='$repnewword'".$add2); } //替换完毕 insert_dolog("tbname=".$tbname."&field=".$field."&dotype=1<br>oldword=".$oldword."<br>newword=".$newword);//操作日志 printerror("DoRepNewstextSuccess","db/RepNewstext.php?tid=$tid".hReturnEcmsHashStrHref2(0)); } //存文本替换 elseif($fr['savetxt']) { $repoldword=addslashes($postoldword); $repnewword=addslashes($postnewword); //字段 $selectf=$fr['tbdataf']?',stb':','.$field; $fieldform="<input type='hidden' name='field' value='".$field."'>"; if(empty($public_r[dorepnum])) { $public_r[dorepnum]=600; } $start=(int)$start; $b=0; $sql=$empire->query("select id,checked from {$dbtbpre}ecms_".$tbname."_index where id>$start".$add1." order by id limit ".$public_r[dorepnum]); while($r=$empire->fetch($sql)) { $b=1; $newstart=$r[id]; //返回表 $infotb=ReturnInfoMainTbname($tbname,$r['checked']); //主表 $infor=$empire->fetch1("select isurl".$selectf." from ".$infotb." where id='$r[id]' limit 1"); if($infor['isurl']) { continue; } //副表 if($fr['tbdataf']) { //返回表信息 $infodatatb=ReturnInfoDataTbname($tbname,$r['checked'],$infor['stb']); $finfor=$empire->fetch1("select ".$field." from ".$infodatatb." where id='$r[id]' limit 1"); $infor[$field]=$finfor[$field]; } $value=GetTxtFieldText($infor[$field]); if(empty($value)) { continue; } if($dozz==1)//正则 { $newvalue=DoRepNewstextZz($repoldword,$repnewword,$value);//正则替换 } else//普通 { if(!stristr($value,$repoldword)) { continue; } $newvalue=str_replace($repoldword,$repnewword,$value); } EditTxtFieldText($infor[$field],$newvalue); } //替换完毕 if(empty($b)) { insert_dolog("tbname=".$tbname."&field=".$field."<br>oldword=".$oldword."<br>newword=".$newword);//操作日志 printerror("DoRepNewstextSuccess","db/RepNewstext.php?tid=$tid".hReturnEcmsHashStrHref2(0)); } EchoRepFieldForm($tid,$tbname,$over,$dozz,$dotxt,$newstart,$fieldform,$classid,$postoldword,$postnewword); } //正则替换 elseif($dozz==1) { //字段 $selectf=$fr['tbdataf']?',stb':','.$field; $fieldform="<input type='hidden' name='field' value='".$field."'>"; if(empty($public_r[dorepnum])) { $public_r[dorepnum]=600; } $start=(int)$start; $b=0; $sql=$empire->query("select id,checked from {$dbtbpre}ecms_".$tbname."_index where id>$start".$add1." order by id limit ".$public_r[dorepnum]); while($r=$empire->fetch($sql)) { $b=1; $newstart=$r[id]; //返回表 $infotb=ReturnInfoMainTbname($tbname,$r['checked']); //主表 $infor=$empire->fetch1("select isurl".$selectf." from ".$infotb." where id='$r[id]' limit 1"); if($infor['isurl']) { continue; } if($fr['tbdataf'])//副表 { //返回表信息 $infodatatb=ReturnInfoDataTbname($tbname,$r['checked'],$infor['stb']); $finfor=$empire->fetch1("select ".$field." from ".$infodatatb." where id='$r[id]' limit 1"); $newvalue=DoRepNewstextZz($oldword,$newword,stripSlashes($finfor[$field]));//正则替换 $empire->query("update ".$infodatatb." set ".$field."='".addslashes($newvalue)."' where id='$r[id]'"); } else//主表 { $newvalue=DoRepNewstextZz($oldword,$newword,stripSlashes($infor[$field]));//正则替换 $empire->query("update ".$infotb." set ".$field."='".addslashes($newvalue)."' where id='$r[id]'"); } } //替换完毕 if(empty($b)) { insert_dolog("tbname=".$tbname."&field=".$field."<br>oldword=".$oldword."<br>newword=".$newword);//操作日志 printerror("DoRepNewstextSuccess","db/RepNewstext.php?tid=$tid".hReturnEcmsHashStrHref2(0)); } EchoRepFieldForm($tid,$tbname,$over,$dozz,$dotxt,$newstart,$fieldform,$classid,$postoldword,$postnewword); } //普通替换 else { $repoldword=eaddslashes2($oldword); $repnewword=eaddslashes2($newword); if($over==1)//完全替换 { if(empty($add2)) { $and=" where "; } else { $and=" and "; } $add2.=$and.$field."='".$repoldword."'"; } if($fr['tbdataf'])//副表 { //已审核 $tbr=$empire->fetch1("select datatbs from {$dbtbpre}enewstable where tbname='$tbname' limit 1"); if($tbr['datatbs']) { $dtbr=explode(',',$tbr['datatbs']); $count=count($dtbr); for($i=1;$i<$count-1;$i++) { $empire->query("update {$dbtbpre}ecms_".$tbname."_data_".$dtbr[$i]." set ".$field."=REPLACE(".$field.",'$repoldword','$repnewword')".$add2); } } //未审核 $empire->query("update {$dbtbpre}ecms_".$tbname."_check_data set ".$field."=REPLACE(".$field.",'$repoldword','$repnewword')".$add2); } else//主表 { $empire->query("update {$dbtbpre}ecms_".$tbname." set ".$field."=REPLACE(".$field.",'$repoldword','$repnewword')".$add2); //未审核 $empire->query("update {$dbtbpre}ecms_".$tbname."_check set ".$field."=REPLACE(".$field.",'$repoldword','$repnewword')".$add2); } //替换完毕 insert_dolog("tbname=".$tbname."&field=".$field."<br>oldword=".$oldword."<br>newword=".$newword);//操作日志 printerror("DoRepNewstextSuccess","db/RepNewstext.php?tid=$tid".hReturnEcmsHashStrHref2(0)); } }
function DelInfoData($start, $classid, $from, $retype, $startday, $endday, $startid, $endid, $tbname, $add, $userid, $username) { global $empire, $public_r, $class_r, $fun_r, $dbtbpre, $emod_r; //验证权限 CheckLevel($userid, $username, $classid, "delinfodata"); $search = ''; $start = (int) $start; $tbname = RepPostVar($tbname); if (empty($tbname)) { printerror("ErrorUrl", "history.go(-1)"); } $search .= "&tbname={$tbname}"; //查询表 $infotb = "{$dbtbpre}ecms_" . $tbname; //按栏目 $classid = (int) $classid; if ($classid) { if (empty($class_r[$classid][islast])) { $where = ReturnClass($class_r[$classid][sonclass]); } else { $where = "classid='{$classid}'"; } $add1 = " and (" . $where . ")"; $search .= "&classid={$classid}"; } //按ID刷新 $search .= "&retype={$retype}"; if ($retype) { $startid = (int) $startid; $endid = (int) $endid; if ($endid) { $add1 .= " and id>={$startid} and id<={$endid}"; } $search .= "&startid={$startid}&endid={$endid}"; } else { $startday = RepPostVar($startday); $endday = RepPostVar($endday); if ($startday && $endday) { $add1 .= " and truetime>=" . to_time($startday . " 00:00:00") . " and truetime<=" . to_time($endday . " 23:59:59"); } $search .= "&startday={$startday}&endday={$endday}"; } //信息类型 $delckinfo = 0; $infost = (int) $add['infost']; if ($infost) { if ($infost == 1) { $delckinfo = 1; } else { $infotb = "{$dbtbpre}ecms_" . $tbname . "_check"; $delckinfo = 2; } $search .= "&infost={$infost}"; } else { $dodelcheck = (int) $add['dodelcheck']; if ($dodelcheck) { $infotb = "{$dbtbpre}ecms_" . $tbname . "_check"; $delckinfo = 2; $search .= "&dodelcheck=1"; } } //用户发布 $ismember = (int) $add['ismember']; if ($ismember) { if ($ismember == 1) { $add1 .= " and userid=0"; } elseif ($ismember == 2) { $add1 .= " and userid>0"; } elseif ($ismember == 3) { $add1 .= " and userid>0 and ismember=1"; } elseif ($ismember == 4) { $add1 .= " and userid>0 and ismember=0"; } $search .= "&ismember={$ismember}"; } //是否外部链接 $isurl = (int) $add['isurl']; if ($isurl) { if ($isurl == 1) { $add1 .= " and isurl=1"; } else { $add1 .= " and isurl=0"; } $search .= "&isurl={$isurl}"; } //评论数 $plnum = (int) $add['plnum']; if ($plnum) { $add1 .= " and plnum<" . $plnum; $search .= "&plnum={$plnum}"; } //点击数 $onclick = (int) $add['onclick']; if ($onclick) { $add1 .= " and onclick<" . $onclick; $search .= "&onclick={$onclick}"; } //下载数 $totaldown = (int) $add['totaldown']; if ($totaldown) { $add1 .= " and totaldown<" . $totaldown; $search .= "&totaldown={$totaldown}"; } //用户ID $userids = RepPostVar($add['userids']); $usertype = (int) $add['usertype']; if ($userids) { $uidsr = explode(',', $userids); $uidscount = count($uidsr); $uids = ''; $udh = ''; for ($ui = 0; $ui < $uidscount; $ui++) { $uids .= $udh . intval($uidsr[$ui]); $udh = ','; } if ($usertype == 1) { $add1 .= " and userid in (" . $uids . ") and ismember=0"; } else { $add1 .= " and userid in (" . $uids . ") and ismember=1"; } $search .= "&userids={$userids}&usertype={$usertype}"; } //标题 $title = RepPostStr($add['title']); if ($title) { $titler = explode('|', $title); $titlecount = count($titler); $titlewhere = ''; $titleor = ''; for ($ti = 0; $ti < $titlecount; $ti++) { $titlewhere .= $titleor . "title like '%" . $titler[$ti] . "%'"; $titleor = ' or '; } $add1 .= " and (" . $titlewhere . ")"; $search .= "&title={$title}"; } $b = 0; $sql = $empire->query("select * from " . $infotb . " where id>{$start}" . $add1 . " order by id limit " . $public_r[delnewsnum]); while ($r = $empire->fetch($sql)) { $b = 1; $new_start = $r[id]; $mid = $emod_r[$r[classid]]['modid']; $pf = $emod_r[$mid]['pagef']; $stf = $emod_r[$mid]['savetxtf']; //未审核表 if ($delckinfo == 2) { $infodatatb = "{$dbtbpre}ecms_" . $tbname . "_check_data"; } else { $infodatatb = "{$dbtbpre}ecms_" . $tbname . "_data_" . $r['stb']; } //分页字段 if ($pf) { if (strstr($emod_r[$mid]['tbdataf'], ',' . $pf . ',')) { $finfor = $empire->fetch1("select " . $pf . " from " . $infodatatb . " where id='{$r['id']}' limit 1"); $r[$pf] = $finfor[$pf]; } } //存文本 if ($stf) { $newstextfile = $r[$stf]; $r[$stf] = GetTxtFieldText($r[$stf]); DelTxtFieldText($newstextfile); //删除文件 } //删除信息文件 if ($add['delhtml'] != 1 && $delckinfo != 2) { DelNewsFile($r[filename], $r[newspath], $r[classid], $r[$pf], $r[groupid]); } //删除表信息 $empire->query("delete from {$dbtbpre}ecms_" . $tbname . "_index where id='{$r['id']}'"); $empire->query("delete from " . $infotb . " where id='{$r['id']}'"); $empire->query("delete from " . $infodatatb . " where id='{$r['id']}'"); //更新栏目信息数 AddClassInfos($r['classid'], '-1', '-1', $delckinfo == 2 ? 0 : 1); //删除其它表记录和附件 DelSingleInfoOtherData($r['classid'], $r['id'], $r, 0, 0); } if (empty($b)) { if ($delckinfo == 0 && !$dodelcheck) { echo $fun_r[DelDataSuccess] . "<script>self.location.href='ecmsinfo.php?enews=DelInfoData&start=0&from=" . urlencode($from) . "&delhtml={$add['delhtml']}&dodelcheck=1" . $search . hReturnEcmsHashStrHref(0) . "';</script>"; exit; } //操作日志 insert_dolog(""); printerror("DelNewsAllSuccess", "db/DelData.php" . hReturnEcmsHashStrHref2(1)); } echo $fun_r[OneDelDataSuccess] . "(ID:<font color=red><b>" . $new_start . "</b></font>)<script>self.location.href='ecmsinfo.php?enews=DelInfoData&start={$new_start}&from=" . urlencode($from) . "&delhtml={$add['delhtml']}" . $search . hReturnEcmsHashStrHref(0) . "';</script>"; exit; }
function DelDataTable($add, $userid, $username) { global $empire, $dbtbpre, $emod_r, $class_r; //操作权限 CheckLevel($userid, $username, $classid, "table"); $tid = (int) $add['tid']; $tbname = RepPostVar($add['tbname']); $datatb = (int) $add['datatb']; if (!$tid || !$tbname || !$datatb) { printerror("NotChangeDataTable", "history.go(-1)"); } $tr = $empire->fetch1("select tid,tbname,datatbs,deftb from {$dbtbpre}enewstable where tid='{$tid}'"); if (!$tr['tid']) { printerror("NotChangeDataTable", "history.go(-1)"); } if (!strstr($tr['datatbs'], ',' . $datatb . ',')) { printerror("NotChangeDataTable", "history.go(-1)"); } if ($tr['deftb'] == $datatb || $datatb == 1) { printerror("NotDelDefDataTable", "history.go(-1)"); } $newdatatbs = str_replace(',' . $datatb . ',', ',', $tr['datatbs']); $sql = $empire->query("update {$dbtbpre}enewstable set datatbs='{$newdatatbs}' where tid='{$tid}'"); //删除信息 $infosql = $empire->query("select * from {$dbtbpre}ecms_" . $tr[tbname] . " where stb='{$datatb}'"); while ($infor = $empire->fetch($infosql)) { $mid = $class_r[$infor[classid]]['modid']; $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_" . $tr[tbname] . "_data_" . $datatb . " where id='{$infor['id']}'"); $infor[$pf] = $finfor[$pf]; } } //存文本 if ($stf) { $newstextfile = $infor[$stf]; $infor[$stf] = GetTxtFieldText($infor[$stf]); DelTxtFieldText($newstextfile); //删除文件 } //删除信息文件 DelNewsFile($infor[filename], $infor[newspath], $infor[classid], $infor[$pf], $infor[groupid]); //删除其它表记录 $empire->query("delete from {$dbtbpre}enewswfinfo where id='{$infor['id']}' and classid='{$infor['classid']}'"); $empire->query("delete from {$dbtbpre}enewswfinfolog where id='{$infor['id']}' and classid='{$infor['classid']}'"); $empire->query("delete from {$dbtbpre}enewsinfovote where id='{$infor['id']}' and classid='{$infor['classid']}'"); $empire->query("delete from {$dbtbpre}enewsdiggips where id='{$infor['id']}' and classid='{$infor['classid']}'"); //删除附件 DelNewsTheFile($infor['id'], $infor['classid']); } $deltb = $empire->query("delete from {$dbtbpre}ecms_" . $tr[tbname] . " where stb='{$datatb}'"); //删除表 $deltb = $empire->query("DROP TABLE IF EXISTS {$dbtbpre}ecms_" . $tr[tbname] . "_data_" . $datatb . ";"); GetConfig(1); //更新缓存 if ($sql) { //操作日志 insert_dolog("tid=" . $tid . "<br>tbname=" . $tr[tbname] . "&datatb={$datatb}"); printerror("DelDataTableSuccess", "db/ListDataTable.php?tid={$tid}&tbname={$tr['tbname']}"); } else { printerror("DbError", "history.go(-1)"); } }
function DodoInfo($add, $ecms = 0) { global $empire, $public_r, $emod_r, $level_r, $class_r, $dbtbpre, $fun_r; //验证来源 if ($ecms == 0 || $ecms == 1) { CheckCanPostUrl(); } //开启投稿 if ($public_r['addnews_ok']) { printerror("CloseQAdd", "", 1); } //验证本时间允许操作 eCheckTimeCloseDo('info'); $classid = (int) $add['classid']; $mid = (int) $class_r[$classid]['modid']; if (!$mid || !$classid) { printerror("EmptyQinfoCid", "", 1); } $tbname = $emod_r[$mid]['tbname']; $qenter = $emod_r[$mid]['qenter']; if (!$tbname || !$qenter || $qenter == ',') { printerror("ErrorUrl", "history.go(-1)", 1); } $muserid = (int) getcvar('mluserid'); $musername = RepPostVar(getcvar('mlusername')); $mrnd = RepPostVar(getcvar('mlrnd')); //取得栏目信息 $isadd = 0; if ($ecms == 0) { $isadd = 1; } $setuserday = ''; $cr = DoQCheckAddLevel($classid, $muserid, $musername, $mrnd, $ecms, $isadd); $setuserday = $cr['checkaddnumquery']; $filepass = (int) $add['filepass']; $id = (int) $add['id']; $infor = array(); //组合标题属性 $titlecolor = RepPostStr(RepPhpAspJspcodeText($add[titlecolor])); $titlefont = TitleFont($add[titlefont], $titlecolor); $titlecolor = ""; $titlefont = ""; $ttid = (int) $add['ttid']; $keyboard = addslashes(RepPostStr(trim(DoReplaceQjDh($add[keyboard])))); $keyid = ''; //返回关键字组合 if ($keyboard && strstr($qenter, ',special.field,')) { $keyboard = str_replace('[!--f--!]', 'ecms', $keyboard); $keyid = GetKeyid($keyboard, $classid, $id, $class_r[$classid][link_num]); } //验证码 $keyvname = 'checkinfokey'; //moreport if (Moreport_ReturnMustDt()) { define('ECMS_SELFPATH', eReturnEcmsMainPortPath()); Moreport_ResetMainTempGid(); } //-----------------增加 if ($ecms == 0) { //时间 $lasttime = getcvar('lastaddinfotime'); if ($lasttime) { if (time() - $lasttime < $public_r['readdinfotime']) { printerror("QAddInfoOutTime", "", 1); } } //验证码 if ($cr['qaddshowkey']) { ecmsCheckShowKey($keyvname, $add['key'], 1); } //IP发布数限制 $check_ip = egetip(); $check_checked = $cr['wfid'] ? 0 : $cr['checkqadd']; eCheckIpAddInfoNum($check_ip, $tbname, $mid, $check_checked); //返回字段 $ret_r = ReturnQAddinfoF($mid, $add, $infor, $classid, $filepass, $muserid, $musername, 0); $checked = $cr['checkqadd']; $havehtml = 0; $newspath = date($cr['newspath']); $truetime = time(); $newstime = $truetime; $newstempid = $cr['newstempid']; $haveaddfen = 0; //强制签发 $isqf = 0; if ($cr['wfid']) { $checked = 0; $isqf = 1; } //增扣点 if ($checked && $muserid) { AddInfoFen($cr['addinfofen'], $muserid); $haveaddfen = 1; } if (empty($muserid)) { $musername = $fun_r['guest']; } //会员投稿数更新 if ($setuserday) { $empire->query($setuserday); } //发布时间 if (!strstr($qenter, ',newstime,')) { $ret_r[0] = ",newstime" . $ret_r[0]; $ret_r[1] = ",'{$newstime}'" . $ret_r[1]; } else { if ($add['newstime']) { $newstime = to_time($add['newstime']); $newstime = intval($newstime); } } //附加链接参数 $addecmscheck = empty($checked) ? '&ecmscheck=1' : ''; //索引表 $indexsql = $empire->query("insert into {$dbtbpre}ecms_" . $tbname . "_index(classid,checked,newstime,truetime,lastdotime,havehtml) values('{$classid}','{$checked}','{$newstime}','{$truetime}','{$truetime}','{$havehtml}');"); $id = $empire->lastid(); //返回表信息 $infotbr = ReturnInfoTbname($tbname, $checked, $ret_r[4]); //主表 $sql = $empire->query("insert into " . $infotbr['tbname'] . "(id,classid,ttid,onclick,plnum,totaldown,newspath,filename,userid,username,firsttitle,isgood,istop,isqf,ismember,isurl,truetime,lastdotime,havehtml,groupid,userfen,titlefont,titleurl,stb,fstb,restb,keyboard" . $ret_r[0] . ") values('{$id}','{$classid}','{$ttid}',0,0,0,'{$newspath}','','" . $muserid . "','" . addslashes($musername) . "',0,0,0,'{$isqf}',1,0,'{$truetime}','{$truetime}','{$havehtml}',0,0,'{$titlefont}','','{$ret_r['4']}','{$public_r['filedeftb']}','{$public_r['pldeftb']}','{$keyboard}'" . $ret_r[1] . ");"); //副表 $fsql = $empire->query("insert into " . $infotbr['datatbname'] . "(id,classid,keyid,dokey,newstempid,closepl,haveaddfen,infotags" . $ret_r[2] . ") values('{$id}','{$classid}','{$keyid}',1,'{$newstempid}',0,'{$haveaddfen}',''" . $ret_r[3] . ");"); //扣点记录 if ($haveaddfen) { if ($cr['addinfofen'] < 0) { BakDown($classid, $id, 0, $muserid, $musername, RepPostStr($add[title]), abs($cr['addinfofen']), 3); } } //签发 if ($isqf == 1) { InfoInsertToWorkflow($id, $classid, $cr['wfid'], $muserid, addslashes($musername)); } //文件命名 $filename = ReturnInfoFilename($classid, $id, ''); //信息地址 $infourl = GotoGetTitleUrl($classid, $id, $newspath, $filename, 0, 0, ''); $usql = $empire->query("update " . $infotbr['tbname'] . " set filename='{$filename}',titleurl='{$infourl}' where id='{$id}'"); //修改ispic UpdateTheIspic($classid, $id, $checked); //修改附件 if ($filepass) { UpdateTheFile($id, $filepass, $classid, $public_r['filedeftb']); } //更新栏目信息数 AddClassInfos($classid, '+1', '+1', $checked); //更新新信息数 DoUpdateAddDataNum('info', $class_r[$classid]['tid'], 1); //清除验证码 ecmsEmptyShowKey($keyvname); esetcookie("qeditinfo", "", 0); //生成页面 if ($checked && !$cr['showdt']) { $titleurl = qAddGetHtml($classid, $id); } //生成列表 if ($checked) { qAddListHtml($classid, $mid, $cr['qaddlist'], $cr['listdt']); //生成上一篇 if ($cr['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); } } if ($sql) { $reurl = DoingReturnUrl("AddInfo.php?classid={$classid}&mid={$mid}" . $addecmscheck, $add['ecmsfrom']); if ($add['gotoinfourl'] && $checked) { if ($cr['showdt'] == 1) { $reurl = $public_r[newsurl] . "e/action/ShowInfo/?classid={$classid}&id={$id}"; } elseif ($cr['showdt'] == 2) { $rewriter = eReturnRewriteInfoUrl($classid, $id, 1); $reurl = $rewriter['pageurl']; } else { $reurl = $titleurl; } } esetcookie("lastaddinfotime", time(), time() + 3600 * 24); //设置最后发表时间 printerror("AddQinfoSuccess", $reurl, 1); } else { printerror("DbError", "history.go(-1)", 1); } } elseif ($ecms == 1) { if (!$id) { printerror("ErrorUrl", "history.go(-1)", 1); } //检测权限 $infor = CheckQdoinfo($classid, $id, $muserid, $tbname, $cr['adminqinfo'], 1); //检测时间 if ($public_r['qeditinfotime']) { if (time() - $infor['truetime'] > $public_r['qeditinfotime'] * 60) { printerror("QEditInfoOutTime", "history.go(-1)", 1); } } $iaddfield = ''; $addfield = ''; $faddfield = ''; //返回字段 $ret_r = ReturnQAddinfoF($mid, $add, $infor, $classid, $filepass, $muserid, $musername, 1); if ($keyboard) { $addfield = ",keyboard='{$keyboard}'"; $faddfield = ",keyid='{$keyid}'"; } //时间 if (strstr($qenter, ',newstime,')) { if ($add['newstime']) { $newstime = to_time($add['newstime']); $newstime = intval($newstime); $iaddfield .= ",newstime='{$newstime}'"; } } //修改是否需要审核 $ychecked = $infor['checked']; if ($cr['qeditchecked']) { $infor['checked'] = 0; $iaddfield .= ",checked=0"; $relist = 1; //删除原页面 DelNewsFile($infor[filename], $infor[newspath], $infor[classid], $infor[newstext], $infor[groupid]); } //会员投稿数更新 if ($setuserday) { //$empire->query($setuserday); } $lastdotime = time(); //附加链接参数 $addecmscheck = empty($infor['checked']) ? '&ecmscheck=1' : ''; //索引表 $indexsql = $empire->query("update {$dbtbpre}ecms_" . $tbname . "_index set lastdotime={$lastdotime},havehtml=0" . $iaddfield . " where id='{$id}'"); //返回表信息 $infotbr = ReturnInfoTbname($tbname, $ychecked, $infor['stb']); //主表 $sql = $empire->query("update " . $infotbr['tbname'] . " set lastdotime={$lastdotime},havehtml=0,ttid='{$ttid}'" . $addfield . $ret_r[0] . " where id={$id} and classid={$classid} and userid='{$muserid}' and ismember=1"); //副表 $fsql = $empire->query("update " . $infotbr['datatbname'] . " set classid='{$classid}'" . $faddfield . $ret_r[3] . " where id='{$id}'"); //修改ispic UpdateTheIspic($classid, $id, $ychecked); //更新附件 UpdateTheFileEdit($classid, $id, $infor['fstb']); //未审核信息互转 if ($ychecked != $infor['checked']) { MoveCheckInfoData($tbname, $ychecked, $infor['stb'], "id='{$id}'"); //更新栏目信息数 if ($infor['checked']) { AddClassInfos($classid, '', '+1'); } else { AddClassInfos($classid, '', '-1'); } } esetcookie("qeditinfo", "", 0); //生成页面 if ($infor['checked'] && !$cr['showdt']) { $titleurl = qAddGetHtml($classid, $id); } //生成列表 if ($infor['checked'] || $relist == 1) { qAddListHtml($classid, $mid, $cr['qaddlist'], $cr['listdt']); } //生成上一篇 if ($cr['repreinfo'] && $infor['checked']) { $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); } if ($sql) { $reurl = DoingReturnUrl("ListInfo.php?mid={$mid}" . $addecmscheck, $add['ecmsfrom']); if ($add['editgotoinfourl'] && $infor['checked']) { if ($cr['showdt'] == 1) { $reurl = $public_r[newsurl] . "e/action/ShowInfo/?classid={$classid}&id={$id}"; } elseif ($cr['showdt'] == 2) { $rewriter = eReturnRewriteInfoUrl($classid, $id, 1); $reurl = $rewriter['pageurl']; } else { $reurl = $titleurl; } } printerror("EditQinfoSuccess", $reurl, 1); } else { printerror("DbError", "history.go(-1)", 1); } } elseif ($ecms == 2) { if (!$id) { printerror("ErrorUrl", "history.go(-1)", 1); } //检测权限 $r = CheckQdoinfo($classid, $id, $muserid, $tbname, $cr['adminqinfo'], 2); //附加链接参数 $addecmscheck = empty($r['checked']) ? '&ecmscheck=1' : ''; //返回表信息 $infotbr = ReturnInfoTbname($tbname, $r['checked'], $r['stb']); $stf = $emod_r[$mid]['savetxtf']; $pf = $emod_r[$mid]['pagef']; //分页字段 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]); $indexsql = $empire->query("delete from {$dbtbpre}ecms_" . $tbname . "_index where id='{$id}'"); $sql = $empire->query("delete from " . $infotbr['tbname'] . " where id={$id} and classid={$classid} and userid='{$muserid}' and ismember=1"); $fsql = $empire->query("delete from " . $infotbr['datatbname'] . " where id={$id}"); esetcookie("qdelinfo", "", 0); //更新栏目信息数 AddClassInfos($classid, '-1', '-1', $r['checked']); //删除其它表记录和附件 DelSingleInfoOtherData($classid, $id, $r, 0, 0); //生成列表 if ($r['checked']) { qAddListHtml($classid, $mid, $cr['qaddlist'], $cr['listdt']); //生成上一篇 if ($cr['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); } } } if ($sql) { $reurl = DoingReturnUrl("ListInfo.php?mid={$mid}", $add['ecmsfrom']); printerror("DelQinfoSuccess", $reurl, 1); } else { printerror("DbError", "history.go(-1)", 1); } } else { printerror("ErrorUrl", "", 1); } }
function GetHtml($classid, $id, $add, $ecms = 0, $doall = 0) { global $public_r, $class_r, $class_zr, $fun_r, $empire, $dbtbpre, $emod_r, $class_tr, $level_r, $etable_r; $mid = $class_r[$classid]['modid']; $tbname = $class_r[$classid][tbname]; if (InfoIsInTable($tbname)) { return ''; } if ($ecms == 0) { $add = $empire->fetch1("select " . ReturnSqlTextF($mid, 1) . " from {$dbtbpre}ecms_" . $tbname . " where id='{$id}' limit 1"); } $add['id'] = $id; $add['classid'] = $classid; if ($add['isurl']) { return ''; } if (empty($doall)) { if (!$add['stb'] || $class_r[$add[classid]][showdt] == 2 || strstr($public_r['nreinfo'], ',' . $add['classid'] . ',')) { return ''; } } //副表 $addr = $empire->fetch1("select " . ReturnSqlFtextF($mid) . " from {$dbtbpre}ecms_" . $tbname . "_data_" . $add[stb] . " where id='{$add['id']}' limit 1"); $add = array_merge($add, $addr); //路径 $iclasspath = ReturnSaveInfoPath($add[classid], $add[id]); $doclasspath = eReturnTrueEcmsPath() . $iclasspath; //moreport $createinfopath = $doclasspath; //建立日期目录 $newspath = ''; if ($add[newspath]) { $createpath = $doclasspath . $add[newspath]; if (!file_exists($createpath)) { $r[newspath] = FormatPath($add[classid], $add[newspath], 1); } $createinfopath .= $add[newspath] . '/'; $newspath = $add[newspath] . '/'; } //新建存放目录 if ($class_r[$add[classid]][filename] == 3) { $createinfopath .= ReturnInfoSPath($add['filename']); DoMkdir($createinfopath); $fn3 = 1; } //存文本 if ($emod_r[$mid]['savetxtf']) { $stf = $emod_r[$mid]['savetxtf']; if ($add[$stf]) { $add[$stf] = GetTxtFieldText($add[$stf]); } } $GLOBALS['navclassid'] = $add[classid]; $GLOBALS['navinfor'] = $add; //取得内容模板 $add[newstempid] = $add[newstempid] ? $add[newstempid] : $class_r[$add[classid]][newstempid]; $newstemp_r = $empire->fetch1("select temptext,showdate from " . GetTemptb("enewsnewstemp") . " where tempid='{$add['newstempid']}' limit 1"); $newstemp_r['tempid'] = $add['newstempid']; if ($public_r['opennotcj']) { $newstemp_r['temptext'] = ReturnNotcj($newstemp_r['temptext']); } $newstemptext = $newstemp_r[temptext]; $formatdate = $newstemp_r[showdate]; //文件类型/权限 if ($add[groupid] || $class_r[$add[classid]]['cgtoinfo']) { if (empty($add[newspath])) { $include = ''; } else { $pr = explode('/', $add[newspath]); for ($i = 0; $i < count($pr); $i++) { $include .= '../'; } } if ($fn3 == 1) { $include .= '../'; } $pr = explode('/', $iclasspath); $pcount = count($pr); for ($i = 0; $i < $pcount - 1; $i++) { $include .= '../'; } $include1 = $include; $include .= 'e/class/CheckLevel.php'; $filetype = '.php'; $addlevel = "<?php\n\t\tdefine('empirecms','wm_chief');\n\t\t\$check_tbname='" . $class_r[$add[classid]][tbname] . "';\n\t\t\$check_infoid=" . $add[id] . ";\n\t\t\$check_classid=" . $add[classid] . ";\n\t\t\$check_path=\"" . $include1 . "\";\n\t\trequire(\"" . $include . "\");\n\t\t?>"; } else { $filetype = $class_r[$add[classid]][filetype]; $addlevel = ''; } //取得本目录链接 if ($class_r[$add[classid]][classurl] && $class_r[$add[classid]][ipath] == '') { $dolink = $class_r[$add[classid]][classurl] . '/' . $newspath; } else { $dolink = $public_r[newsurl] . $iclasspath . $newspath; } //返回替换验证字符 $docheckrep = ReturnCheckDoRepStr(); if ($add[newstext]) { if (empty($public_r['dorepword']) && $docheckrep[3]) { $add[newstext] = ReplaceWord($add[newstext]); //过滤字符 } if (empty($public_r['dorepkey']) && $docheckrep[4] && !empty($add[dokey])) { $add[newstext] = ReplaceKey($add['newstext'], $add['classid']); } if ($public_r['opencopytext']) { $add[newstext] = AddNotCopyRndStr($add[newstext]); //随机复制字符 } } //返回编译 $newstemptext = GetInfoNewsBq($classid, $newstemp_r, $add, $docheckrep); //分页字段 $expage = '[!--empirenews.page--]'; //分页符 $pf = $emod_r[$mid]['pagef']; //变量替换 $newstempstr = $newstemptext; //模板 //分页 if ($pf && strstr($add[$pf], $expage)) { $n_r = explode($expage, $add[$pf]); $thispagenum = count($n_r); //取得分页 $thefun = $public_r['textpagefun'] ? $public_r['textpagefun'] : 'sys_ShowTextPage'; //下拉式分页 if (strstr($newstemptext, '[!--title.select--]')) { $dotitleselect = sys_ShowTextPageSelect($thispagenum, $dolink, $add, $filetype, $n_r); } for ($j = 1; $j <= $thispagenum; $j++) { $string = $newstempstr; //模板 $truepage = ''; $titleselect = ''; //下一页链接 if ($thispagenum == $j) { $thisnextlink = $dolink . $add[filename] . $filetype; } else { $thisj = $j + 1; $thisnextlink = $dolink . $add[filename] . '_' . $thisj . $filetype; } $k = $j - 1; if ($j == 1) { $file = $doclasspath . $newspath . $add[filename] . $filetype; $ptitle = $add[title]; } else { $file = $doclasspath . $newspath . $add[filename] . '_' . $j . $filetype; $ti_r = explode('[/!--empirenews.page--]', $n_r[$k]); if (count($ti_r) >= 2) { $ptitle = $ti_r[0]; $n_r[$k] = $ti_r[1]; } else { $ptitle = $add[title] . '(' . $j . ')'; } } //取得当前页 if ($thispagenum != 1) { $truepage = $thefun($thispagenum, $j, $dolink, $add, $filetype, ''); $titleselect = str_replace("?" . $j . "\">", "?" . $j . "\" selected>", $dotitleselect); } //替换变量 $newstext = $n_r[$k]; if (!strstr($emod_r[$mid]['editorf'], ',' . $pf . ',')) { if (strstr($emod_r[$mid]['tobrf'], ',' . $pf . ',')) { $newstext = nl2br($newstext); } if (!strstr($emod_r[$mid]['dohtmlf'], ',' . $pf . ',')) { $newstext = ehtmlspecialchars($newstext); $newstext = RepFieldtextNbsp($newstext); } } $string = str_replace('[!--' . $pf . '--]', $newstext, $string); $string = str_replace('[!--p.title--]', strip_tags($ptitle), $string); $string = str_replace('[!--next.page--]', $thisnextlink, $string); $string = str_replace('[!--page.url--]', $truepage, $string); $string = str_replace('[!--title.select--]', $titleselect, $string); //写文件 WriteFiletext($file, $addlevel . $string); } } else { $file = $doclasspath . $newspath . $add[filename] . $filetype; $string = $newstempstr; //模板 //替换变量 $string = str_replace('[!--p.title--]', $add[title], $string); $string = str_replace('[!--next.page--]', '', $string); $string = str_replace('[!--page.url--]', '', $string); $string = str_replace('[!--title.select--]', '', $string); //写文件 WriteFiletext($file, $addlevel . $string); } //设为已生成 if (empty($doall) && empty($add['havehtml'])) { $empire->query("update {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . "_index set havehtml=1 where id='{$add['id']}' limit 1"); $empire->query("update {$dbtbpre}ecms_" . $class_r[$add[classid]][tbname] . " set havehtml=1 where id='{$add['id']}' limit 1"); } }
function DoRepNewstext($start, $oldword, $newword, $field, $classid, $tid, $tbname, $over, $dozz, $dotxt, $userid, $username) { global $empire, $public_r, $class_r, $fun_r, $dbtbpre, $emod_r; $tbname = RepPostVar($tbname); $field = RepPostVar($field); $tid = (int) $tid; $dotype = (int) $_POST['dotype']; if (!$field || empty($tbname) || !$tid) { printerror("FailCX", "history.go(-1)"); } if ($dotype == 0 && strlen($oldword) == 0) { printerror("FailCX", "history.go(-1)"); } CheckLevel($userid, $username, $classid, "repnewstext"); //验证权限 //变量替换 $postoldword = ClearAddsData($oldword); $postnewword = ClearAddsData($newword); //替换条件 if ($classid) { if (empty($class_r[$classid][islast])) { $where = ReturnClass($class_r[$classid][sonclass]); } else { $where = "classid='{$classid}'"; } $add1 = " and (" . $where . ")"; $add2 = " where (" . $where . ")"; } $fr = $empire->fetch1("select tid,savetxt,tbdataf from {$dbtbpre}enewsf where tbname='{$tbname}' and f='{$field}' limit 1"); //覆盖方式 if ($dotype == 1) { $repoldword = addslashes($oldword); $repnewword = addslashes($newword); if ($over == 1) { if (empty($add2)) { $and = " where "; } else { $and = " and "; } $add2 .= $and . $field . "='" . $repoldword . "'"; } if ($fr['tbdataf']) { $tbr = $empire->fetch1("select datatbs from {$dbtbpre}enewstable where tbname='{$tbname}' limit 1"); if ($tbr['datatbs']) { $dtbr = explode(',', $tbr['datatbs']); $count = count($dtbr); for ($i = 1; $i < $count - 1; $i++) { $empire->query("update {$dbtbpre}ecms_" . $tbname . "_data_" . $dtbr[$i] . " set " . $field . "='{$repnewword}'" . $add2); } } } else { $empire->query("update {$dbtbpre}ecms_" . $tbname . " set " . $field . "='{$repnewword}'" . $add2); } //替换完毕 insert_dolog("tbname=" . $tbname . "&field=" . $field . "&dotype=1<br>oldword=" . $oldword . "<br>newword=" . $newword); //操作日志 printerror("DoRepNewstextSuccess", "db/RepNewstext.php?tid={$tid}"); } elseif ($fr['savetxt']) { $repoldword = addslashes($postoldword); $repnewword = addslashes($postnewword); //字段 $selectf = $fr['tbdataf'] ? ',stb' : ',' . $field; $fieldform = "<input type='hidden' name='field' value='" . $field . "'>"; if (empty($public_r[dorepnum])) { $public_r[dorepnum] = 600; } $start = (int) $start; $b = 0; $sql = $empire->query("select id" . $selectf . " from {$dbtbpre}ecms_" . $tbname . " where id>{$start}" . $add1 . " and titleurl='' order by id limit " . $public_r[dorepnum]); while ($r = $empire->fetch($sql)) { $b = 1; $newstart = $r[id]; //副表 if ($fr['tbdataf']) { $finfor = $empire->fetch1("select " . $field . " from {$dbtbpre}ecms_" . $tbname . "_data_" . $r[stb] . " where id='{$r['id']}'"); $r[$field] = $finfor[$field]; } $value = GetTxtFieldText($r[$field]); if (empty($value)) { continue; } if ($dozz == 1) { $newvalue = DoRepNewstextZz($repoldword, $repnewword, $value); //正则替换 } else { if (!stristr($value, $repoldword)) { continue; } $newvalue = str_replace($repoldword, $repnewword, $value); } EditTxtFieldText($r[$field], $newvalue); } //替换完毕 if (empty($b)) { insert_dolog("tbname=" . $tbname . "&field=" . $field . "<br>oldword=" . $oldword . "<br>newword=" . $newword); //操作日志 printerror("DoRepNewstextSuccess", "db/RepNewstext.php?tid={$tid}"); } EchoRepFieldForm($tid, $tbname, $over, $dozz, $dotxt, $newstart, $fieldform, $classid, $postoldword, $postnewword); } elseif ($dozz == 1) { //字段 $selectf = $fr['tbdataf'] ? ',stb' : ',' . $field; $fieldform = "<input type='hidden' name='field' value='" . $field . "'>"; if (empty($public_r[dorepnum])) { $public_r[dorepnum] = 600; } $start = (int) $start; $b = 0; $sql = $empire->query("select id" . $selectf . " from {$dbtbpre}ecms_" . $tbname . " where id>{$start}" . $add1 . " and titleurl='' order by id limit " . $public_r[dorepnum]); while ($r = $empire->fetch($sql)) { $b = 1; $newstart = $r[id]; if ($fr['tbdataf']) { $finfor = $empire->fetch1("select " . $field . " from {$dbtbpre}ecms_" . $tbname . "_data_" . $r[stb] . " where id='{$r['id']}'"); $newvalue = DoRepNewstextZz($oldword, $newword, stripSlashes($finfor[$field])); //正则替换 $empire->query("update {$dbtbpre}ecms_" . $tbname . "_data_" . $r[stb] . " set " . $field . "='" . addslashes($newvalue) . "' where id='{$r['id']}'"); } else { $newvalue = DoRepNewstextZz($oldword, $newword, stripSlashes($r[$field])); //正则替换 $empire->query("update {$dbtbpre}ecms_" . $tbname . " set " . $field . "='" . addslashes($newvalue) . "' where id='{$r['id']}'"); } } //替换完毕 if (empty($b)) { insert_dolog("tbname=" . $tbname . "&field=" . $field . "<br>oldword=" . $oldword . "<br>newword=" . $newword); //操作日志 printerror("DoRepNewstextSuccess", "db/RepNewstext.php?tid={$tid}"); } EchoRepFieldForm($tid, $tbname, $over, $dozz, $dotxt, $newstart, $fieldform, $classid, $postoldword, $postnewword); } else { $repoldword = addslashes($oldword); $repnewword = addslashes($newword); if ($over == 1) { if (empty($add2)) { $and = " where "; } else { $and = " and "; } $add2 .= $and . $field . "='" . $repoldword . "'"; } if ($fr['tbdataf']) { $tbr = $empire->fetch1("select datatbs from {$dbtbpre}enewstable where tbname='{$tbname}' limit 1"); if ($tbr['datatbs']) { $dtbr = explode(',', $tbr['datatbs']); $count = count($dtbr); for ($i = 1; $i < $count - 1; $i++) { $empire->query("update {$dbtbpre}ecms_" . $tbname . "_data_" . $dtbr[$i] . " set " . $field . "=REPLACE(" . $field . ",'{$repoldword}','{$repnewword}')" . $add2); } } } else { $empire->query("update {$dbtbpre}ecms_" . $tbname . " set " . $field . "=REPLACE(" . $field . ",'{$repoldword}','{$repnewword}')" . $add2); } //替换完毕 insert_dolog("tbname=" . $tbname . "&field=" . $field . "<br>oldword=" . $oldword . "<br>newword=" . $newword); //操作日志 printerror("DoRepNewstextSuccess", "db/RepNewstext.php?tid={$tid}"); } }