function MakeArticleHtm($aid = '', $p = '1') { global $DreamCMS; //if(!$DreamCMS->config['ishtm']||empty($aid)) return false; //zhaoyanmin 静态判断 start //查询此文章和栏目 $datas = $DreamCMS->db->get_row("SELECT c.`arturlset` FROM `#DC@__article` AS a,`#DC@__catalog` AS c where a.`id` ='{$aid}' AND a.`cid`=c.`id` LIMIT 1 ", ARRAY_A); /*$DreamCMS->ishtml_z = $datas['arturlset'] ==1 ? true : false ; if(!$DreamCMS->ishtml_z || empty($aid)) return false;*/ $DreamCMS->config['ishtm'] = $datas['arturlset'] == 1 ? true : false; if (!$DreamCMS->config['ishtm'] || empty($aid)) { return false; } //zhaoyanmin 静态判断 end $DreamCMS->mode = 'CreateHtml'; //$htmldate=$DreamCMS->Show($aid,$p); //原 $htmldate = $DreamCMS->Show($aid, $p, 1); //zhaoyanmin 更新静态页和添加静态页时有跳转地址防止跳转 //$body=explode('<div style="page-break-after: always"><span style="display: none"> </span></div>',$DreamCMS->result->body); $body = explode('<div style="page-break-after: always;"><span style="DISPLAY:none"> </span></div>', $DreamCMS->result->body); //zhaoyanmin 内容分页 $total = count($body); $RootDir = DCPATH . $DreamCMS->config['htmdir'] . $DreamCMS->dirule(array('id' => $DreamCMS->result->id, 'dir' => $DreamCMS->result->catalogdir, 'pubdate' => $DreamCMS->result->pubdate)); $filename = $DreamCMS->filerule(array('id' => $DreamCMS->result->id, 'link' => $DreamCMS->result->customlink, 'pubdate' => $DreamCMS->result->pubdate)); $total > 1 && $p != 1 && ($filename .= '_' . $p); $FilePath = $RootDir . "/{$filename}" . $DreamCMS->config['htmlext']; createdir($RootDir); //writefile($FilePath,$htmldate); /*zhaoyanmin start filename赋值*/ switch ($DreamCMS->config['htmnamerule']) { case "0": $filename = $DreamCMS->result->id; break; case "pinyin": $filename = $DreamCMS->result->customlink; break; case "pubdate": $filename = $DreamCMS->result->pubdate; break; default: $filename = $DreamCMS->result->id; } $NewFileName = $_Dir . '/' . $filename; $total > 1 && $p != 1 && ($filename .= '_' . $p); $FilePath = $RootDir . "/{$filename}" . $DreamCMS->config['htmlext']; if ($NewFileName == $DreamCMS->result->filename) { writefile($FilePath, $htmldate); } else { delfile(DCPATH . $DreamCMS->config['htmdir'] . $DreamCMS->result->filename . $DreamCMS->config['htmlext']); if ($total > 1) { for ($i = 1; $i <= $total; $i++) { delfile(DCPATH . $DreamCMS->config['htmdir'] . $DreamCMS->result->filename . '_' . $i . $DreamCMS->config['htmlext']); } } writefile($FilePath, $htmldate); } /*zhaoyanmin start filename赋值*/ $total > 1 && $p < $total && MakeArticleHtm($aid, $p + 1); // $DreamCMS->db->query("UPDATE `#DC@__article` SET `filename` = '{$NewFileName}' WHERE `id` ='$aid'"); $DreamCMS->db->query("UPDATE `#DC@__article` SET `filename` = '{$NewFileName}' WHERE `id` ='{$aid}'"); //zhaoyanmin return true; }
flush(); } _header('admincp.php?do=html&operation=create&action=article&startid=' . $startid . '&endid=' . $endid . '&g&loop=' . ($loop + 1) . '&i=' . $j . $QUERY_STRING); } else { redirect("文章更新完毕!", 'admincp.php?do=html&operation=article'); } } elseif ($starttime) { $s = strtotime($starttime); $e = empty($endtime) ? time() + 86400 : strtotime($endtime); $rs = $DreamCMS->db->get_results("SELECT id FROM #DC@__article WHERE `pubdate`>='{$s}' and `pubdate`<='{$e}' and `visible`='1'"); empty($totle) && ($totle = count($rs)); $tloop = ceil($totle / $speed); if ($loop <= $tloop) { $max = $i + $speed > $totle ? $totle : $i + $speed; for ($j = $i; $j < $max; $j++) { MakeArticleHtm($rs[$j]['id']); echo "文章ID:" . $rs[$j]['id'] . "生成…<span style='color:green;'>√</span><br />"; flush(); } _header('admincp.php?do=html&operation=create&action=article&starttime=' . $starttime . '&endtime=' . $endtime . '&totle=' . $totle . '&loop=' . ($loop + 1) . '&i=' . $j . $QUERY_STRING); } else { redirect("文章更新完毕!", 'admincp.php?do=html&operation=article'); } } else { alert("请选择方式"); } } break; } function _redirect($T1, $T2, $U1, $U2) {
$art = $iCMS->db->getRow("SELECT `cid`,`tags` FROM `#iCMS@__article` where `id` ='{$aid}'"); TagsDiff($tags, $art->tags); tags_cache(); $iCMS->db->update('article', compact('cid', 'title', 'stitle', 'customlink', 'url', 'source', 'author', 'editor', 'userid', 'postype', 'keywords', 'tags', 'description', 'related', 'pic', 'pubdate', 'type', 'vlink', 'top', 'visible'), array('id' => $aid)); if ($iCMS->db->getValue("SELECT `id` FROM `#iCMS@__articledata` where `aid` ='{$aid}'")) { $iCMS->db->update('articledata', compact('tpl', 'subtitle', 'body'), compact('aid')); } else { $iCMS->db->insert('articledata', compact('aid', 'subtitle', 'tpl', 'body')); } // insert_db_remote($body,$aid); if ($isexamine) { alert("此栏目文章需要管理员审核,请稍候..", 'url:' . __SELF__ . "?do=article&operation=manage"); } else { if ($iCMS->config['ishtm'] && $visible) { include_once iPATH . "include/function/template.php"; MakeArticleHtm($aid); } if ($art->cid != $cid) { $iCMS->db->query("UPDATE `#iCMS@__catalog` SET `count` = count-1 WHERE `id` ='{$art->cid}' LIMIT 1 "); $iCMS->db->query("UPDATE `#iCMS@__catalog` SET `count` = count+1 WHERE `id` ='{$cid}' LIMIT 1 "); } alert("文章编辑完成!", 'url:' . __SELF__ . "?do=article&operation=manage"); } } break; case 'del': empty($_POST['id']) && alert("请选择要删除的文章"); if (is_array($_POST['id'])) { foreach ($_POST['id'] as $id) { delArticle($id, $member->uId, 0); }
break; case 'cancel': empty($_POST['id']) && alert("请选择要隐藏的内容"); if (is_array($_POST['id'])) { $ids = implode(',', $_POST['id']); $iCMS->db->query("UPDATE `#iCMS@__{$__TABLE__}` SET `visible` = '0' WHERE `id` IN ({$ids})"); } _Header(); break; case 'updateHTML': empty($_POST['id']) && alert("请选择要更新的内容"); include_once iPATH . "include/function/template.php"; $i = 0; if (is_array($_POST['id'])) { foreach ($_POST['id'] as $aid) { MakeArticleHtm($aid) && $i++; } } alert($i . '个文件更新完成!', "url:1"); break; case 'contentype': empty($_POST['id']) && alert("请选择要更改的内容"); $type = empty($_POST['type']) ? "0" : implode(',', $_POST['type']); $ids = implode(',', $_POST['id']); $iCMS->db->query("UPDATE `#iCMS@__{$__TABLE__}` SET `type` = '{$type}' WHERE `id` IN ({$ids})"); alert('内容属性更改完成!', "url:1"); break; case 'keyword': empty($_POST['id']) && alert("请选择内容"); $ids = implode(',', $_POST['id']); if ($_POST['pattern'] == 'replace') {
function MakeArticleHtm($aid = '', $p = '1') { global $DreamCMS; if (!$DreamCMS->config['ishtm'] || empty($aid)) { return false; } $DreamCMS->mode = 'CreateHtml'; //$htmldate=$DreamCMS->Show($aid,$p); //原 $htmldate = $DreamCMS->Show($aid, $p, 1); //zhaoyanmin 更新静态页和添加静态页时有跳转地址防止跳转 //$body=explode('<div style="page-break-after: always"><span style="display: none"> </span></div>',$DreamCMS->result->body); $body = explode('<div style="page-break-after: always;"><span style="DISPLAY:none"> </span></div>', $DreamCMS->result->body); //zhaoyanmin 内容分页 $total = count($body); if ($DreamCMS->config['htmdircreaterule'] == '0') { $FDir = $DreamCMS->result->catalogdir; } elseif ($DreamCMS->config['htmdircreaterule'] == '1') { $FDir = _getdate('Y-m-d'); } elseif ($DreamCMS->config['htmdircreaterule'] == '2') { $FDir = str_replace(array('Y', 'y', 'm', 'n', 'd', 'j', 'C'), array(_getdate('Y'), _getdate('y'), _getdate('m'), _getdate('n'), _getdate('d'), _getdate('j'), $DreamCMS->result->catalogdir), $DreamCMS->config['customhtmdircreaterule']); } else { $FDir = _getdate('Ymd'); } $ODir = substr($DreamCMS->result->filename, 0, strrpos($DreamCMS->result->filename, '/')); $_Dir = $ODir == $FDir ? $ODir : $FDir; $RootDir = DCPATH . $DreamCMS->config['htmdir'] . $_Dir; createdir($RootDir); switch ($DreamCMS->config['htmnamerule']) { case "0": $filename = $DreamCMS->result->id; break; case "pinyin": $filename = $DreamCMS->result->customlink; break; case "pubdate": $filename = $DreamCMS->result->pubdate; break; default: $filename = $DreamCMS->result->id; } $NewFileName = $_Dir . '/' . $filename; $total > 1 && $p != 1 && ($filename .= '_' . $p); $FilePath = $RootDir . "/{$filename}" . $DreamCMS->config['htmlext']; if ($NewFileName == $DreamCMS->result->filename) { writefile($FilePath, $htmldate); } else { delfile(DCPATH . $DreamCMS->config['htmdir'] . $DreamCMS->result->filename . $DreamCMS->config['htmlext']); if ($total > 1) { for ($i = 1; $i <= $total; $i++) { delfile(DCPATH . $DreamCMS->config['htmdir'] . $DreamCMS->result->filename . '_' . $i . $DreamCMS->config['htmlext']); } } writefile($FilePath, $htmldate); } $total > 1 && $p < $total && MakeArticleHtm($aid, $p + 1); $DreamCMS->db->query("UPDATE `#DC@__article` SET `filename` = '{$NewFileName}' WHERE `id` ='{$aid}'"); return true; }
function MakeArticleHtm($aid = '', $p = '1') { global $iCMS; if (!$iCMS->config['ishtm'] || empty($aid)) { return false; } $iCMS->mode = 'CreateHtml'; $htmldate = $iCMS->Show($aid, $p); $total = $iCMS->result->pagetotal; $RootDir = path(iPATH . $iCMS->config['htmdir'] . $iCMS->dirule(array('id' => $iCMS->result->id, 'dir' => $iCMS->result->catalogdir, 'pubdate' => $iCMS->result->pubdate))); $filename = $iCMS->filerule(array('id' => $iCMS->result->id, 'link' => $iCMS->result->customlink, 'pubdate' => $iCMS->result->pubdate)); $total > 1 && $p != 1 && ($filename .= '_' . $p); $FilePath = $RootDir . '/' . $filename . $iCMS->config['htmlext']; createdir($RootDir); writefile($FilePath, $htmldate, false); $total > 1 && $p < $total && MakeArticleHtm($aid, $p + 1); return true; }