function article_repack($id, $params = array(), $syn = 0) { global $jieqiConfigs; global $jieqiModules; global $jieqi_file_postfix; if (!$syn) { $article_static_url = empty($jieqiConfigs['article']['staticurl']) ? $jieqiModules['article']['url'] : $jieqiConfigs['article']['staticurl']; $url = $article_static_url . '/makepack.php?key=' . urlencode(md5(JIEQI_DB_USER . JIEQI_DB_PASS . JIEQI_DB_NAME)) . '&id=' . intval($id); $url = trim($url); if (strtolower(substr($url, 0, 7)) != 'http://') { $url = 'http://' . $_SERVER['HTTP_HOST'] . $url; } foreach ($params as $k => $v) { if ($v) { $url .= '&packflag[]=' . urlencode($k); } } return jieqi_socket_url($url); } else { $article_handler =& JieqiArticleHandler::getInstance('JieqiArticleHandler'); $article = $article_handler->get($id); if (!is_object($article)) { return false; } else { $package = new JieqiPackage($id); $package->initPackage(array('id' => $article->getVar('articleid', 'n'), 'title' => $article->getVar('articlename', 'n'), 'creatorid' => $article->getVar('authorid', 'n'), 'creator' => $article->getVar('author', 'n'), 'subject' => $article->getVar('keywords', 'n'), 'description' => $article->getVar('intro', 'n'), 'publisher' => JIEQI_SITE_NAME, 'contributorid' => $article->getVar('posterid', 'n'), 'contributor' => $article->getVar('poster', 'n'), 'sortid' => $article->getVar('sortid', 'n'), 'typeid' => $article->getVar('typeid', 'n'), 'articletype' => $article->getVar('articletype', 'n'), 'permission' => $article->getVar('permission', 'n'), 'firstflag' => $article->getVar('firstflag', 'n'), 'fullflag' => $article->getVar('fullflag', 'n'), 'imgflag' => $article->getVar('imgflag', 'n'), 'power' => $article->getVar('power', 'n'), 'display' => $article->getVar('display', 'n')), false); $chapter_handler =& JieqiChapterHandler::getInstance('JieqiChapterHandler'); $criteria = new CriteriaCompo(new Criteria('articleid', $id, '=')); $criteria->setSort('chapterorder ASC, chapterid'); $criteria->setOrder('ASC'); $res = $chapter_handler->queryObjects($criteria); $i = 0; $articlesize = 0; while ($chapter = $chapter_handler->getObject($res)) { if ($chapter->getVar('chaptertype', 'n') == 1) { $contenttype = 'volume'; } else { $contenttype = 'chapter'; } $package->chapters[$i] = array('id' => $chapter->getVar('chaptername', 'n'), 'href' => $chapter->getVar('chapterid', 'n') . $jieqi_file_postfix['txt'], 'media-type' => 'text/html', 'content-type' => $contenttype); $i++; if ($chapter->getVar('chaptertype', 'n') == 0) { $articlesize = $articlesize + intval($chapter->getVar('size', 'n')); } if ($chapter->getVar('chapterorder', 'n') != $i) { $chapter->setVar('chapterorder', $i); $chapter_handler->insert($chapter); } } //检查文章信息和统计的是否对应 $changeflag = false; if ($article->getVar('chapters', 'n') != $i) { $article->setVar('chapters', $i); $changeflag = true; } if ($article->getVar('size', 'n') != $articlesize) { $article->setVar('size', $articlesize); $changeflag = true; } if ($changeflag) { $article_handler->insert($article); } //开始生成 $package->isload = true; //生成opf if ($params['makeopf']) { $package->createOPF(); } if ($params['makehtml']) { $chaptercount = count($package->chapters); for ($i = 1; $i <= $chaptercount; $i++) { if ($package->chapters[$i - 1]['content-type'] == 'chapter') { $package->makeHtml($i, false, false, true); } } //生成html目录 $package->makeIndex(); } //生成zip if ($params['makezip']) { $package->makezip(); } //生成全文阅读 if ($params['makefull']) { $package->makefulltext(); } //生成umd if ($params['makeumd']) { $package->makeumd(); } //生成txt全文 if ($params['maketxtfull']) { $package->maketxtfull(); } //生成jar if ($params['makejar']) { $package->makejar(); } return true; } } }
@session_write_close(); @ini_set('memory_limit', '64M'); echo ' '; ob_flush(); flush(); jieqi_getconfigs(JIEQI_MODULE_NAME, 'configs'); include_once $GLOBALS['jieqiModules']['article']['path'] . '/class/article.php'; include_once $GLOBALS['jieqiModules']['article']['path'] . '/class/chapter.php'; include_once $GLOBALS['jieqiModules']['article']['path'] . '/class/package.php'; $article_handler =& JieqiArticleHandler::getInstance('JieqiArticleHandler'); $article = $article_handler->get($_REQUEST['id']); if (!is_object($article)) { exit; } else { $package = new JieqiPackage($_REQUEST['id']); $package->initPackage(array('id' => $article->getVar('articleid', 'n'), 'title' => $article->getVar('articlename', 'n'), 'creatorid' => $article->getVar('authorid', 'n'), 'creator' => $article->getVar('author', 'n'), 'subject' => $article->getVar('keywords', 'n'), 'description' => $article->getVar('intro', 'n'), 'publisher' => JIEQI_SITE_NAME, 'contributorid' => $article->getVar('posterid', 'n'), 'contributor' => $article->getVar('poster', 'n'), 'sortid' => $article->getVar('sortid', 'n'), 'typeid' => $article->getVar('typeid', 'n'), 'articletype' => $article->getVar('articletype', 'n'), 'permission' => $article->getVar('permission', 'n'), 'firstflag' => $article->getVar('firstflag', 'n'), 'fullflag' => $article->getVar('fullflag', 'n'), 'imgflag' => $article->getVar('imgflag', 'n'), 'power' => $article->getVar('power', 'n'), 'display' => $article->getVar('display', 'n')), false); $chapter_handler =& JieqiChapterHandler::getInstance('JieqiChapterHandler'); $criteria = new CriteriaCompo(new Criteria('articleid', $_REQUEST['id'], '=')); $criteria->setSort('chapterorder ASC, chapterid'); $criteria->setOrder('ASC'); $res = $chapter_handler->queryObjects($criteria); $i = 0; $articlesize = 0; while ($chapter = $chapter_handler->getObject($res)) { if ($chapter->getVar('chaptertype', 'n') == 1) { $contenttype = 'volume'; } else { $contenttype = 'chapter'; } $package->chapters[$i] = array('id' => $chapter->getVar('chaptername', 'n'), 'href' => $chapter->getVar('chapterid', 'n') . $jieqi_file_postfix['txt'], 'media-type' => 'text/html', 'content-type' => $contenttype); $i++;
function jieqi_article_clean($aid, $usescore = false) { global $jieqiModules; global $article_handler; global $chapter_handler; global $jieqiArticleuplog; global $jieqiConfigs; $article = $article_handler->get($aid); if (!is_object($article)) { return false; } //清除文章统计 $criteria = new CriteriaCompo(new Criteria('articleid', $aid)); $fields = array('lastchapter' => '', 'lastchapterid' => 0, 'lastvolume' => '', 'lastvolumeid' => 0, 'chapters' => 0, 'size' => 0); $article_handler->updatefields($fields, $criteria); //更新最新文章 $jieqiArticleuplog['articleuptime'] = JIEQI_NOW_TIME; $jieqiArticleuplog['chapteruptime'] = JIEQI_NOW_TIME; jieqi_setcachevars('articleuplog', 'jieqiArticleuplog', $jieqiArticleuplog, 'article'); //删除文本、html及zip $package = new JieqiPackage($aid); $package->delete(); $package->initPackage(array('id' => $article->getVar('articleid', 'n'), 'title' => $article->getVar('articlename', 'n'), 'creatorid' => $article->getVar('authorid', 'n'), 'creator' => $article->getVar('author', 'n'), 'subject' => $article->getVar('keywords', 'n'), 'description' => $article->getVar('intro', 'n'), 'publisher' => JIEQI_SITE_NAME, 'contributorid' => $article->getVar('posterid', 'n'), 'contributor' => $article->getVar('poster', 'n'), 'sortid' => $article->getVar('sortid', 'n'), 'typeid' => $article->getVar('typeid', 'n'), 'articletype' => $article->getVar('articletype', 'n'), 'permission' => $article->getVar('permission', 'n'), 'firstflag' => $article->getVar('firstflag', 'n'), 'fullflag' => $article->getVar('fullflag', 'n'), 'imgflag' => $article->getVar('imgflag', 'n'), 'power' => $article->getVar('power', 'n'), 'display' => $article->getVar('display', 'n'))); //删除章节 //检查这篇文章章节发表人,扣积分用 if ($usescore) { $posterary = array(); if (!empty($jieqiConfigs['article']['scorechapter'])) { $criteria0 = new CriteriaCompo(new Criteria('articleid', $aid, '=')); $chapter_handler->queryObjects($criteria0); while ($chapterobj = $chapter_handler->getObject()) { $posterid = intval($chapterobj->getVar('posterid')); if (isset($posterary[$posterid])) { $posterary[$posterid] += $jieqiConfigs['article']['scorechapter']; } else { $posterary[$posterid] = $jieqiConfigs['article']['scorechapter']; } } unset($criteria0); } } //真正删除章节 $criteria = new CriteriaCompo(new Criteria('articleid', $aid, '=')); $chapter_handler->delete($criteria); //删除附件 include_once $jieqiModules['article']['path'] . '/class/articleattachs.php'; $attachs_handler =& JieqiArticleattachsHandler::getInstance('JieqiArticleattachsHandler'); $attachs_handler->delete($criteria); //减少文章和章节积分 if ($usescore) { include_once JIEQI_ROOT_PATH . '/class/users.php'; $users_handler =& JieqiUsersHandler::getInstance('JieqiUsersHandler'); if (!empty($jieqiConfigs['article']['scorearticle'])) { $posterid = intval($article->getVar('posterid')); if (isset($posterary[$posterid])) { $posterary[$posterid] += $jieqiConfigs['article']['scorearticle']; } else { $posterary[$posterid] = $jieqiConfigs['article']['scorearticle']; } } foreach ($posterary as $pid => $pscore) { $users_handler->changeScore($pid, $pscore, false); } } return $article; }