function doCreateArticle() { $mtime = microtime(); $mtime = explode(' ', $mtime); $time_start = $mtime[1] + $mtime[0]; $speed = $this->PG('speed', 25); //生成速度 $fids = $this->PG('fid'); $startid = (int) $this->PG('startid'); $endid = (int) $this->PG('endid'); $starttime = $this->PG('starttime'); $endtime = $this->PG('endtime'); $atime = isset($_GET['atime']) ? $_GET['atime'] : 0; $attime = isset($_GET['attime']) ? $_GET['attime'] : 0; $totle = isset($_GET['totle']) ? $_GET['totle'] : 0; $loop = isset($_GET['loop']) ? $_GET['loop'] : 1; $i = isset($_GET['i']) ? $_GET['i'] : 0; if ($fids) { empty($fids) && javascript::alert("请选择版块"); is_array($fids) && ($fids = implode(",", $fids)); $isA = $this->isAll(); if (strstr($fids, 'all')) { $forum = new forum(); $fids = substr($forum->fid(), 0, -1); _header(__SELF__ . '?mo=html&do=CreateArticle&fid=' . $fids . $isA); } else { $cArray = explode(',', $fids); $cCount = count($cArray); $k = isset($_GET['k']) ? $_GET['k'] : 0; $fidsql = strstr($fids, ',') ? " fid in ({$fids})" : " fid='{$fids}'"; empty($totle) && ($totle = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__article` WHERE {$fidsql} and `status`='1'")); $offset = ($loop - 1) * $speed; $totlepg = ceil($totle / $speed); $loop = min($totlepg, $loop); $offset < 0 && ($offset = 0); $rs = iCMS_DB::getArray("SELECT id FROM #iCMS@__article WHERE {$fidsql} and `status`='1' order by id DESC LIMIT {$offset} , {$speed}"); $max = count($rs); if ($loop <= $totlepg && $max > 0) { $msg = "共有文章{$totle}篇,已生成{$offset}篇,完成" . round($offset / $totle, 3) * 100 . "%<br />预计用时" . $this->Hms(ceil($totlepg * $atime / 60) * 60) . ",生成{$speed}篇用时" . $this->Hms($atime) . ",已用时" . $this->Hms($attime) . "<br />"; for ($j = 0; $j < $max; $j++) { $Art = iHtml::Article($rs[$j]['id']); $msg .= "文章ID:" . $rs[$j]['id'] . "生成…<span style='color:green;'>" . ($Art == false ? '×' : '√') . "</span> "; if ($j % 2) { $msg .= '<br />'; } } $mtime = microtime(); $mtime = explode(' ', $mtime); $time_end = $mtime[1] + $mtime[0]; $atime = round($time_end - $time_start, 2); javascript::dialog($msg, 'src:' . __SELF__ . '?mo=html&do=CreateArticle&speed=' . $speed . '&atime=' . $atime . '&attime=' . ($atime + $attime) . '&fid=' . $fids . '&totle=' . $totle . '&loop=' . ($loop + 1) . '&i=' . $j . $isA, 'ok', 0); } else { $msg = "共生成文章{$totle}篇,用时" . $this->Hms($attime) . "<br />文章更新完毕!"; $isA && javascript::dialog($msg . "<br />开始生成列表...", 'src:' . __SELF__ . '?mo=html&do=CreateForum&fid=all&all=true'); javascript::dialog($msg); } } } elseif ($startid && $endid) { $startid > $endid && !isset($_GET['g']) && javascript::alert("开始ID不能大于结束ID"); empty($totle) && ($totle = $endid - $startid + 1); empty($i) && ($i = $startid); $tloop = ceil($totle / $speed); if ($loop <= $tloop) { $max = $i + $speed > $endid ? $endid : $i + $speed; for ($j = $i; $j <= $max; $j++) { $Art = iHtml::Article($j); $msg .= "文章ID:" . $j . "生成…<span style='color:green;'>" . ($Art == false ? '×' : '√') . "</span> "; if (($j - 1) % 2) { $msg .= '<br />'; } } javascript::dialog($msg, 'src:' . __SELF__ . '?mo=html&do=CreateArticle&startid=' . $startid . '&endid=' . $endid . '&g&loop=' . ($loop + 1) . '&i=' . $j, 'ok', 0); } else { javascript::dialog("文章更新完毕!"); } } elseif ($starttime) { $s = strtotime($starttime); $e = empty($endtime) ? time() + 86400 : strtotime($endtime); empty($totle) && ($totle = iCMS_DB::getValue("SELECT count(*) FROM `#iCMS@__article` WHERE `pubdate`>='{$s}' and `pubdate`<='{$e}' and `status`='1'")); $offset = ($loop - 1) * $speed; $totlepg = ceil($totle / $speed); $loop = min($totlepg, $loop); $offset < 0 && ($offset = 0); $rs = iCMS_DB::getArray("SELECT id FROM #iCMS@__article WHERE `pubdate`>='{$s}' and `pubdate`<='{$e}' and `status`='1' order by id DESC LIMIT {$offset} , {$speed}"); $max = count($rs); if ($loop <= $totlepg && $max > 0) { $msg = "共有文章{$totle}篇,已生成{$offset}篇,完成" . round($offset / $totle, 3) * 100 . "%<br />预计用时" . $this->Hms(ceil($totlepg * $atime / 60) * 60) . ",生成{$speed}篇用时" . $this->Hms($atime) . ",已用时" . $this->Hms($attime) . "<br />"; for ($j = 0; $j < $max; $j++) { $Art = iHtml::Article($rs[$j]['id']); $msg .= "文章ID:" . $rs[$j]['id'] . "生成…<span style='color:green;'>" . ($Art == false ? '×' : '√') . "</span> "; if ($j % 2) { $msg .= '<br />'; } } $mtime = microtime(); $mtime = explode(' ', $mtime); $time_end = $mtime[1] + $mtime[0]; $atime = round($time_end - $time_start, 2); javascript::dialog($msg, 'src:' . __SELF__ . '?mo=html&do=CreateArticle&speed=' . $speed . '&atime=' . $atime . '&attime=' . ($atime + $attime) . '&starttime=' . $starttime . '&endtime=' . $endtime . '&totle=' . $totle . '&loop=' . ($loop + 1) . '&i=' . $j, 'ok', 0); } else { javascript::dialog("共生成文章{$totle}篇,用时" . $this->Hms($attime) . "<br />文章更新完毕!"); } } else { javascript::dialog("请选择方式"); } }
function doupdateHTMLs() { empty($_POST['id']) && javascript::alert("请选择要更新的文章"); $i = 0; include iPATH . 'include/iHtml.class.php'; foreach ((array) $_POST['id'] as $aid) { iHtml::Article($aid) && $i++; } javascript::dialog($i . '个文件更新完成!', "url:1"); }
function doSave() { include_once iPATH . 'include/tag.class.php'; // print_r($_POST); // exit; set_time_limit(0); $aid = (int) $_POST['aid']; $fid = (int) $_POST['fid']; $title = dhtmlspecialchars($_POST['title']); $source = dhtmlspecialchars($_POST['source']); $author = dhtmlspecialchars($_POST['author']); $description = dhtmlspecialchars($_POST['description']); $keywords = dhtmlspecialchars($_POST['keywords']); $tags = dhtmlspecialchars($_POST['tags']); $pic = dhtmlspecialchars($_POST['pic']); $metadata = dhtmlspecialchars($_POST['metadata']); $metadata = $metadata ? addslashes(serialize($metadata)) : ''; $userid = member::$uId; $pubdate = _strtotime(); $type = 0; $orderNum = 0; $subtitle = ''; $stitle = ''; $editor = ''; $clink = ''; $url = ''; $tpl = ''; $top = 0; $vlink = ""; $related = ""; $postype = 0; $body = str_replace(array("\n", "\r", "\t"), "", $_POST['body']); empty($title) && javascript::alert('标题不能为空!'); empty($fid) && javascript::alert('请选择所属栏目'); empty($body) && javascript::alert('文章内容不能为空!'); WordFilter($title) && javascript::alert('标题包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($source) && javascript::alert('出处包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($author) && javascript::alert('作者包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($description) && javascript::alert('摘要包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($keywords) && javascript::alert('关键字包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($tags) && javascript::alert('标签包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($metadata) && javascript::alert('自定义内容包含被系统屏蔽的字符,请返回重新填写。'); WordFilter($body) && javascript::alert('文章内容包含被系统屏蔽的字符,请返回重新填写。'); if ($this->iCMS->config['AutoPage']) { if ($this->iCMS->config['AutoPageLen'] && !preg_match('/<div\\s+style=\\\\"page-break-after:.*?<\\/div>/is', $body)) { $html = autoformat($body, false); AutoPageBreak::page($html, $this->iCMS->config['AutoPageLen']); $body = implode('<!--iCMS.PageBreak-->', AutoPageBreak::$Rs); AutoPageBreak::$Rs = ''; unset($html); $this->iCMS->config['autoformat'] = false; } } $body = preg_replace(array('/<script.+?<\\/script>/is', '/<form.+?<\\/form>/is', '/<div\\s+style=\\\\"page-break-after:.*?<\\/div>/is'), array('', '', '<!--iCMS.PageBreak-->'), $body); $this->iCMS->config['autoformat'] && ($body = autoformat($body)); if ($this->iCMS->config['autodesc'] == "1" && !empty($this->iCMS->config['descLen']) && empty($description)) { $_body = preg_replace(array('/<p[^>]*>/is', '/<[\\/\\!]*?[^<>]*?>/is', "/\n+/", "/ +/", "/^\n/"), array("\n\n", '', "\n", '', ''), $this->iCMS->config['autoformat'] ? $body : autoformat($body)); $description = csubstr($_body, $this->iCMS->config['descLen']); } $tags = iTAG::split($tags, true); include iPATH . 'include/cn.class.php'; $clink = CN::pinyin($title, $this->iCMS->config['CLsplit']); $isPic = empty($pic) ? 0 : 1; $SELFURL = __SELF__ . (empty($_POST['REFERER']) ? '?mo=article&do=manage' : $_POST['REFERER']); $forum = new forum(); $status = $forum->forum[$fid]['isexamine'] ? '0' : '1'; //审核投稿 if (empty($aid)) { $hits = $good = $bad = $comments = 0; iCMS_DB::insert('article', compact('fid', 'title', 'stitle', 'clink', 'orderNum', 'url', 'source', 'author', 'editor', 'userid', 'postype', 'keywords', 'tags', 'description', 'related', 'metadata', 'isPic', 'pic', 'pubdate', 'hits', 'good', 'bad', 'comments', 'type', 'vlink', 'top', 'status')); $aid = iCMS_DB::$insert_id; iCMS_DB::insert('article_data', compact('aid', 'subtitle', 'tpl', 'body')); if ($_FILES['picfile']) { require_once iPATH . 'include/upload.class.php'; $F = iUpload::FILES("picfile", $aid, $title); iCMS_DB::query("UPDATE `#iCMS@__article` SET `isPic`='1',`pic` = '" . $F["FilePath"] . "' WHERE `id` = '{$aid}'"); } //$this->insert_db_remote($body,$aid); iTAG::add($tags, $userid, $aid, $forum->rootid($fid)); vlinkDiff($fid, '', $aid); if (!strstr($forum->forum[$fid]['contentRule'], '{PHP}') && !$forum->forum[$fid]['url'] && $forum->forum[$fid]['mode'] == "1" && $status) { include iPATH . 'include/iHtml.class.php'; iHtml::Article($aid); iHtml::forum($fid, 1, 0, 1); } if ($status) { iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count+1 WHERE `fid` ='{$fid}' LIMIT 1 "); $moreaction = array(array("text" => "查看该文章", "url" => $this->iCMS->iurl('show', array(array('id' => $aid, 'link' => $clink, 'url' => $url, 'fid' => $fid, 'pubdate' => $pubdate), $forum->forum[$fid]))->href, "o" => 'target="_blank"'), array("text" => "编辑该文章", "url" => __SELF__ . "?mo=article&do=add&id=" . $aid), array("text" => "继续添加文章", "url" => __SELF__ . "?mo=article&do=add&fid=" . $fid), array("text" => "返回文章列表", "url" => $SELFURL), array("text" => "查看网站首页", "url" => "../index.php", "o" => 'target="_blank"')); javascript::dialog('文章发布成功!<br />10秒后返回文章列表', 'url:' . $SELFURL, $moreaction, 10); } else { javascript::dialog('您的投稿文章发布成功!<br />该版块文章需要经过管理员审核才能显示!<br />请耐心等待,我们会尽快审核您的稿件!', 'url:' . $SELFURL, 'ok', 10); } } else { $art = iCMS_DB::getRow("SELECT `fid`,`tags`,`vlink` FROM `#iCMS@__article` where `id` ='{$aid}'"); iTAG::diff($tags, $art->tags, member::$uId, $aid, $forum->rootid($fid)); iCMS_DB::update('article', compact('fid', 'title', 'stitle', 'orderNum', 'clink', 'url', 'source', 'author', 'editor', 'userid', 'postype', 'keywords', 'tags', 'description', 'related', 'metadata', 'isPic', 'pic', 'pubdate', 'type', 'vlink', 'top', 'status'), array('id' => $aid)); vlinkDiff($fid, $art->vlink, $aid); iCMS_DB::update('article_data', compact('tpl', 'subtitle', 'body'), compact('aid')); if ($_FILES['picfile']) { require_once iPATH . 'include/upload.class.php'; $F = iUpload::FILES("picfile", $aid, $title); iCMS_DB::query("UPDATE `#iCMS@__article` SET `isPic`='1',`pic` = '" . $F["FilePath"] . "' WHERE `id` = '{$aid}'"); } //$this->insert_db_remote($body,$aid); if (!strstr($forum->forum[$fid]['contentRule'], '{PHP}') && !$forum->forum[$fid]['url'] && $forum->forum[$fid]['mode'] == "1" && $status) { include iPATH . 'include/iHtml.class.php'; iHtml::Article($aid); iHtml::forum($fid, 1, 0, 1); } if ($status) { if ($art->fid != $fid) { iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count-1 WHERE `fid` ='{$art->fid}' LIMIT 1 "); iCMS_DB::query("UPDATE `#iCMS@__forum` SET `count` = count+1 WHERE `fid` ='{$fid}' LIMIT 1 "); } javascript::dialog('文章编辑完成!<br />3秒后返回文章列表', 'url:' . $SELFURL); } else { javascript::dialog('您的文章编辑完成!<br />该版块文章需要经过管理员审核才能显示!<br />请耐心等待,我们会尽快审核您的稿件!', 'url:' . $SELFURL, 'ok', 10); } } }