Esempio n. 1
0
 function delete()
 {
     global $jieqiConfigs;
     global $jieqi_file_postfix;
     jieqi_delfolder($this->getDir('txtdir', true, false));
     if ($jieqiConfigs['article']['makehtml']) {
         jieqi_delfolder($this->getDir('htmldir', true, false));
     }
     if ($jieqiConfigs['article']['makezip']) {
         jieqi_delfile($this->getDir('zipdir', false, false) . '/' . $this->id . $jieqi_file_postfix['zip']);
     }
     if ($jieqiConfigs['article']['makefull']) {
         jieqi_delfile($this->getDir('fulldir', false, false) . '/' . $this->id . $jieqiConfigs['article']['htmlfile']);
     }
     if ($jieqiConfigs['article']['maketxtfull']) {
         jieqi_delfile($this->getDir('txtfulldir', false, false) . '/' . $this->id . $jieqi_file_postfix['txt']);
     }
     //if($jieqiConfigs['article']['makeumd']) jieqi_delfile($this->getDir('umddir', false, false).'/'.$this->id.$jieqi_file_postfix['umd']);
     if ($jieqiConfigs['article']['makeumd']) {
         jieqi_delfolder($this->getDir('umddir', true, false));
     }
     if ($jieqiConfigs['article']['makejar']) {
         jieqi_delfolder($this->getDir('jardir', true, false));
         jieqi_delfolder($this->getDir('jardir', true, false));
     }
     //删除附件
     $attachdir = jieqi_uploadpath($jieqiConfigs['article']['attachdir'], 'article') . jieqi_getsubdir($this->id) . '/' . $this->id;
     if (is_dir($attachdir)) {
         jieqi_delfolder($attachdir);
     }
 }
Esempio n. 2
0
 /**
  * 清理缓存
  * 
  * @param      void
  * @access     public
  * @return     bool
  */
 function clear($path = '')
 {
     if (!empty($path) && is_dir($path)) {
         jieqi_delfolder($path);
     }
 }
Esempio n. 3
0
function jieqi_clean_pagecache()
{
    global $jieqiCache;
    global $jieqiModules;
    if (is_a($jieqiCache, 'JieqiCacheMemcached')) {
        $jieqiCache->clear(JIEQI_CACHE_PATH);
    } else {
        foreach ($jieqiModules as $mod) {
            $dirname = JIEQI_CACHE_PATH . $mod['dir'] . '/templates';
            $handle = @opendir($dirname);
            while ($file = @readdir($handle)) {
                if ($file != '.' && $file != '..' && $file != 'blocks') {
                    if (is_dir($dirname . DIRECTORY_SEPARATOR . $file)) {
                        jieqi_delfolder($dirname . DIRECTORY_SEPARATOR . $file, true);
                    } else {
                        @unlink($dirname . DIRECTORY_SEPARATOR . $file);
                    }
                }
            }
            @closedir($handle);
        }
    }
}
Esempio n. 4
0
function jieqi_article_delchapter($aid, $criteria, $usescore = false)
{
    global $jieqiModules;
    global $article_handler;
    global $chapter_handler;
    global $jieqiArticleuplog;
    global $jieqiConfigs;
    global $jieqi_file_postfix;
    if (!is_object($criteria)) {
        return false;
    }
    $criteria->add(new Criteria('articleid', intval($aid)));
    $article = $article_handler->get($aid);
    if (!is_object($article)) {
        return false;
    }
    //查询符合条件章节
    $posterary = array();
    $chapter_handler->queryObjects($criteria);
    $chapterary = array();
    $k = 0;
    $cids = '';
    $lastchapterid = intval($article->getVar('lastchapterid'));
    $lastvolumeid = intval($article->getVar('lastvolumeid'));
    $uplastchapter = false;
    //是否更新最新章节
    $uplastvolume = false;
    //是否更新最新章节
    $subsize = 0;
    while ($chapterobj = $chapter_handler->getObject()) {
        $chapterary[$k]['id'] = intval($chapterobj->getVar('chapterid'));
        if ($chapterary[$k]['id'] == $lastchapterid) {
            $uplastchapter = true;
        }
        if ($chapterary[$k]['id'] == $lastvolumeid) {
            $uplastvolume = true;
        }
        if ($cids != '') {
            $cids .= ',';
        }
        $cids .= $chapterary[$k]['id'];
        $chapterary[$k]['size'] = $chapterobj->getVar('size');
        $subsize += intval($chapterary[$k]['size']);
        $chapterary[$k]['attach'] = $chapterobj->getVar('attachment', 'n') == '' ? 0 : 1;
        $k++;
        if (!empty($jieqiConfigs['article']['scorechapter'])) {
            $posterid = intval($chapterobj->getVar('posterid'));
            if (isset($posterary[$posterid])) {
                $posterary[$posterid] += $jieqiConfigs['article']['scorechapter'];
            } else {
                $posterary[$posterid] = $jieqiConfigs['article']['scorechapter'];
            }
        }
    }
    //删除章节
    $chapter_handler->delete($criteria);
    //删除附件数据库
    if ($cids != '') {
        $criteria1 = new CriteriaCompo();
        $criteria1->add(new Criteria('chapterid', '(' . $cids . ')', 'IN'));
        include_once $jieqiModules['article']['path'] . '/class/articleattachs.php';
        $attachs_handler =& JieqiArticleattachsHandler::getInstance('JieqiArticleattachsHandler');
        $attachs_handler->delete($criteria1);
    }
    //删除文本文件、附件文件、html
    $txtdir = jieqi_uploadpath($jieqiConfigs['article']['txtdir'], 'article') . jieqi_getsubdir($aid) . '/' . $aid;
    $htmldir = jieqi_uploadpath($jieqiConfigs['article']['htmldir'], 'article') . jieqi_getsubdir($aid) . '/' . $aid;
    $attachdir = jieqi_uploadpath($jieqiConfigs['article']['attachdir'], 'article') . jieqi_getsubdir($aid) . '/' . $aid;
    foreach ($chapterary as $c) {
        if (is_file($txtdir . '/' . $c['id'] . $jieqi_file_postfix['txt'])) {
            jieqi_delfile($txtdir . '/' . $c['id'] . $jieqi_file_postfix['txt']);
        }
        if (is_file($htmldir . '/' . $c['id'] . $jieqiConfigs['article']['htmlfile'])) {
            jieqi_delfile($htmldir . '/' . $c['id'] . $jieqiConfigs['article']['htmlfile']);
        }
        if (is_dir($attachdir . '/' . $c['id'])) {
            jieqi_delfolder($attachdir . '/' . $c['id']);
        }
    }
    //重新生成网页和打包
    include_once $jieqiModules['article']['path'] . '/include/repack.php';
    $ptypes = array('makeopf' => 1, 'makehtml' => $jieqiConfigs['article']['makehtml'], 'makezip' => $jieqiConfigs['article']['makezip'], 'makefull' => $jieqiConfigs['article']['makefull'], 'maketxtfull' => $jieqiConfigs['article']['maketxtfull'], 'makeumd' => $jieqiConfigs['article']['makeumd'], 'makejar' => $jieqiConfigs['article']['makejar']);
    article_repack($aid, $ptypes, 0);
    //减少文章和章节积分
    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);
        }
    }
    //更新文章信息
    $newsize = $article->getVar('size') - $subsize;
    if ($newsize < 0) {
        $newsize = 0;
    }
    $article->setVar('size', $newsize);
    if ($uplastchapter) {
        $criteria = new CriteriaCompo(new Criteria('articleid', $article->getVar('articleid')));
        $criteria->add(new Criteria('chaptertype', 0, '='));
        $criteria->setSort('chapterorder');
        $criteria->setOrder('DESC');
        $criteria->setStart(0);
        $criteria->setLimit(1);
        $chapter_handler->queryObjects($criteria);
        $tmpchapter = $chapter_handler->getObject();
        if ($tmpchapter) {
            $article->setVar('lastchapter', $tmpchapter->getVar('chaptername', 'n'));
            $article->setVar('lastchapterid', $tmpchapter->getVar('chapterid', 'n'));
            unset($tmpchapter);
        } else {
            $article->setVar('lastchapter', '');
            $article->setVar('lastchapterid', 0);
        }
    }
    if ($uplastvolume) {
        $criteria = new CriteriaCompo(new Criteria('articleid', $article->getVar('articleid')));
        $criteria->add(new Criteria('chaptertype', 1, '='));
        $criteria->setSort('chapterorder');
        $criteria->setOrder('DESC');
        $criteria->setStart(0);
        $criteria->setLimit(1);
        $chapter_handler->queryObjects($criteria);
        $tmpchapter = $chapter_handler->getObject();
        if ($tmpchapter) {
            $article->setVar('lastvolume', $tmpchapter->getVar('chaptername', 'n'));
            $article->setVar('lastvolumeid', $tmpchapter->getVar('chapterid', 'n'));
            unset($tmpchapter);
        } else {
            $article->setVar('lastvolume', '');
            $article->setVar('lastvolumeid', 0);
        }
    }
    $article_handler->insert($article);
    //更新最新文章
    $jieqiArticleuplog['articleuptime'] = JIEQI_NOW_TIME;
    $jieqiArticleuplog['chapteruptime'] = JIEQI_NOW_TIME;
    jieqi_setcachevars('articleuplog', 'jieqiArticleuplog', $jieqiArticleuplog, 'article');
    return $article;
}