示例#1
0
文件: package.php 项目: thu0ng91/jmc
 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);
     }
 }
示例#2
0
文件: funpost.php 项目: thu0ng91/jmc
/**
 * 编辑帖子时处理老的附件是否需要删除
 * 
 * @param      array       $post_set 发帖信息设置
 * @param      array       $configs 配置参数
 * @param      object      $attachs_handler 附件查询句柄
 * @access     public
 * @return     void
 */
function jieqi_post_attachold(&$post_set, $configs, &$attachs_handler)
{
    //处理旧附件
    $tmpattachs = $post_set['attachment'];
    $attacholds = array();
    if (!empty($tmpattachs)) {
        $tmpattachary = unserialize($tmpattachs);
        if (!is_array($tmpattachary)) {
            $tmpattachary = array();
        }
        if (!is_array($post_set['oldattach'])) {
            if (is_string($post_set['oldattach'])) {
                $post_set['oldattach'] = array($post_set['oldattach']);
            } else {
                $post_set['oldattach'] = array();
            }
        }
        foreach ($tmpattachary as $val) {
            if (in_array($val['attachid'], $post_set['oldattach'])) {
                $attacholds[] = $val;
            } else {
                //删除旧附件
                $attachs_handler->delete($val['attachid']);
                $afname = jieqi_uploadpath($configs['attachdir'], JIEQI_MODULE_NAME) . '/' . date('Ymd', $post_set['posttime']) . '/' . $post_set['postid'] . '_' . $val['attachid'] . '.' . $val['postfix'];
                if (file_exists($afname)) {
                    jieqi_delfile($afname);
                }
            }
        }
    }
    return $attacholds;
}
示例#3
0
             $attachs_handler =& JieqiArticleattachsHandler::getInstance('JieqiArticleattachsHandler');
             $attachs_handler->delete($val['attachid']);
             $afname = jieqi_uploadpath($jieqiConfigs['article']['attachdir'], 'article') . jieqi_getsubdir($chapter->getVar('articleid', 'n')) . '/' . $chapter->getVar('articleid', 'n') . '/' . $chapter->getVar('chapterid', 'n') . '/' . $val['attachid'] . '.' . $val['postfix'];
             jieqi_delfile($afname);
         }
     }
 } else {
     $oldattachary = array();
 }
 //新附件入库
 if ($attachnum > 0) {
     include_once $jieqiModules['article']['path'] . '/class/articleattachs.php';
     if (!is_object($attachs_handler)) {
         $attachs_handler =& JieqiArticleattachsHandler::getInstance('JieqiArticleattachsHandler');
     }
     $attachdir = jieqi_uploadpath($jieqiConfigs['article']['attachdir'], 'article');
     if (!file_exists($attachdir)) {
         jieqi_createdir($attachdir);
     }
     $attachdir .= jieqi_getsubdir($chapter->getVar('articleid'));
     if (!file_exists($attachdir)) {
         jieqi_createdir($attachdir);
     }
     $attachdir .= '/' . $chapter->getVar('articleid');
     if (!file_exists($attachdir)) {
         jieqi_createdir($attachdir);
     }
     $attachdir .= '/' . $chapter->getVar('chapterid');
     if (!file_exists($attachdir)) {
         jieqi_createdir($attachdir);
     }
示例#4
0
文件: packdown.php 项目: thu0ng91/jmc
        if (isset($_REQUEST['vsize'])) {
            $_REQUEST['vsize'] = intval($_REQUEST['vsize']);
        } else {
            $_REQUEST['vsize'] = 0;
        }
        if ($_REQUEST['vsize'] == 1) {
            $_REQUEST['vsize'] = 0;
        }
        if (!isset($vsflags[$_REQUEST['vsize']]) || ($jieqiConfigs['article']['makejar'] & $vsflags[$_REQUEST['vsize']]) == 0) {
            jieqi_printfail($jieqiLang['article']['down_file_notopen']);
        }
        if (empty($_REQUEST['vsize'])) {
            $path = jieqi_uploadpath($jieqiConfigs['article']['jardir'], 'article') . jieqi_getsubdir($_REQUEST['id']) . '/' . $_REQUEST['id'] . '/' . $_REQUEST['id'] . $jieqi_file_postfix['jad'];
            $checkfile = $path;
        } else {
            $path = jieqi_uploadpath($jieqiConfigs['article']['jardir'], 'article') . jieqi_getsubdir($_REQUEST['id']) . '/' . $_REQUEST['id'] . '/' . $_REQUEST['id'] . '_' . intval($_REQUEST['vsize']) . '_' . intval($_REQUEST['vid']) . $jieqi_file_postfix['jad'];
            $checkfile = dirname($path) . '/' . $_REQUEST['id'] . '_' . intval($_REQUEST['vsize']) . '.xml';
        }
        //文件不存在或者过期自动生成(jad暂不检测,只检测jar)
        /*
        if(!is_file($checkfile) || filemtime($checkfile) + 600 < $lastupdate){
        	include_once(JIEQI_ROOT_PATH.'/modules/article/include/repack.php');
        	article_repack($_REQUEST['id'], array('makejar'=>1), 1);
        }
        */
        $ret = pack_down_do($path, $jieqiConfigs['article']['scorejardown'], false, $_REQUEST['fname']);
        break;
    default:
        jieqi_printfail(LANG_ERROR_PARAMETER);
        break;
}
示例#5
0
文件: packshow.php 项目: thu0ng91/jmc
            include_once JIEQI_ROOT_PATH . '/lib/xml/xmlarray.php';
            $xmlarray = new XMLArray();
            if ($_REQUEST['vsize'] <= 1) {
                $packrows[1] = $xmlarray->xml2array(jieqi_readfile($packxml));
            } else {
                $packrows = $xmlarray->xml2array(jieqi_readfile($packxml));
            }
        }
        $jieqiTpl->assign_by_ref('packrows', $packrows);
        $jieqiTset['jieqi_contents_template'] = $jieqiModules['article']['path'] . '/templates/packumd.html';
        break;
    case 'txtchapter':
    default:
        $jieqiTpl->assign('type', 'txtchapter');
        $jieqiConfigs['article']['maketxt'] = intval($jieqiConfigs['article']['maketxt']);
        if (empty($jieqiConfigs['article']['maketxt'])) {
            jieqi_printfail($jieqiLang['article']['down_file_notopen']);
        }
        $packsize = array();
        $jieqiTpl->assign_by_ref('packsize', $packsize);
        $jieqiTpl->assign('vsize', 0);
        foreach ($opf_chapters as $k => $v) {
            $path = jieqi_uploadpath($jieqiConfigs['article']['txtdir'], 'article') . jieqi_getsubdir($_REQUEST['id']) . '/' . $_REQUEST['id'] . '/' . $v['chapterid'] . $jieqi_file_postfix['txt'];
            $opf_chapters[$k]['maketime'] = intval(@filemtime($path));
            $opf_chapters[$k]['filesize'] = intval(@filesize($path));
        }
        $jieqiTpl->assign_by_ref('packrows', $opf_chapters);
        $jieqiTset['jieqi_contents_template'] = $jieqiModules['article']['path'] . '/templates/packtxtchapter.html';
        break;
}
include_once JIEQI_ROOT_PATH . '/footer.php';
示例#6
0
 $obook->setVar('sortid', $_POST['sortid']);
 $obook->setVar('intro', $_POST['intro']);
 $obook->setVar('notice', $_POST['notice']);
 $imgflag = $obook->getVar('imgflag');
 if (!empty($_FILES['obookspic']['name'])) {
     $imgflag = $imgflag | 1;
 }
 if (!empty($_FILES['obooklpic']['name'])) {
     $imgflag = $imgflag | 2;
 }
 $obook->setVar('imgflag', $imgflag);
 if (!$obook_handler->insert($obook)) {
     jieqi_printfail($jieqiLang['obook']['edit_obook_failure']);
 } else {
     $_REQUEST['id'] = $obook->getVar('obookid');
     $imagedir = jieqi_uploadpath($jieqiConfigs['obook']['imagedir'], 'obook');
     if (!file_exists($imagedir)) {
         jieqi_createdir($imagedir);
     }
     $imagedir .= jieqi_getsubdir($_REQUEST['id']);
     if (!file_exists($imagedir)) {
         jieqi_createdir($imagedir);
     }
     $imagedir .= '/' . $_REQUEST['id'];
     if (!file_exists($imagedir)) {
         jieqi_createdir($imagedir);
     }
     //保存小图
     if (!empty($_FILES['obookspic']['name'])) {
         if (strstr(strtolower($_FILES['obookspic']['name']), strtolower($jieqiConfigs['obook']['imagetype'])) == strtolower($jieqiConfigs['obook']['imagetype'])) {
             jieqi_copyfile($_FILES['obookspic']['tmp_name'], $imagedir . '/' . $_REQUEST['id'] . 's' . $jieqiConfigs['obook']['imagetype'], 0777, true);
示例#7
0
文件: avatar.php 项目: thu0ng91/jmc
    } else {
        $_REQUEST['type'] = $userobj->getVar('avatar');
    }
}
$base_avatar = '';
if ($_REQUEST['type'] == 0) {
    $_REQUEST['uid'] = 'noavatar';
    $base_avatar = JIEQI_ROOT_PATH . '/images';
    $prefix = '.jpg';
} elseif (!isset($jieqi_image_type[$_REQUEST['type']])) {
    exit('wrong image file type!');
} else {
    $prefix = $jieqi_image_type[$_REQUEST['type']];
}
if (empty($base_avatar)) {
    $base_avatar = jieqi_uploadpath($jieqiConfigs['system']['avatardir'], 'system') . jieqi_getsubdir($_REQUEST['uid']);
}
switch ($_REQUEST['size']) {
    case 's':
        $imgfile = $avatar_cut ? $base_avatar . '/' . $_REQUEST['uid'] . 's' . $prefix : $base_avatar . '/' . $_REQUEST['uid'] . $prefix;
        break;
    case 'i':
        $imgfile = $avatar_cut ? $base_avatar . '/' . $_REQUEST['uid'] . 'i' . $prefix : $base_avatar . '/' . $_REQUEST['uid'] . $prefix;
        break;
    case 'l':
    default:
        $imgfile = $base_avatar . '/' . $_REQUEST['uid'] . $prefix;
        break;
}
if (is_file($imgfile)) {
    switch ($prefix) {
示例#8
0
function replace_path($articleid, $dirtype, $filetype, $idisdir = true)
{
    global $showinfo;
    global $fromary;
    global $toary;
    global $jieqiLang;
    $dirname = jieqi_uploadpath($dirtype, 'article') . jieqi_getsubdir($articleid);
    if ($idisdir) {
        $dirname .= '/' . $articleid;
    } else {
        $dirname .= '/' . $articleid . $filetype;
    }
    if (file_exists($dirname)) {
        echo '                                                                                                                                                                                                                                                                ';
        echo sprintf($jieqiLang['article']['replace_id_doing'], $articleid);
        ob_flush();
        flush();
        if (is_dir($dirname)) {
            $handle = @opendir($dirname);
            while ($file = @readdir($handle)) {
                if ($file != '.' && $file != '..') {
                    $filename = $dirname . '/' . $file;
                    if (is_file($filename) && is_writable($filename) && substr($filename, 0 - strlen($filetype)) == $filetype) {
                        if (empty($_REQUEST['filesize']) || $_REQUEST['filesize'] == 'sizeunlimit' || $_REQUEST['filesize'] == 'sizeless' && filesize($filename) <= 1024 || $_REQUEST['filesize'] == 'sizemore' && filesize($filename) >= 1024) {
                            $filedata = jieqi_readfile($filename);
                            if ($_REQUEST['replacetype'] == 1) {
                                $filedata = str_replace($fromary, $toary, $filedata);
                            } else {
                                $filedata = str_replace($_REQUEST['txtsearch'], $_REQUEST['txtreplace'], $filedata);
                            }
                            jieqi_writefile($filename, $filedata);
                        }
                    }
                }
            }
        } elseif (is_file($dirname)) {
            $filename = $dirname;
            if (is_file($filename) && is_writable($filename) && substr($filename, 0 - strlen($filetype)) == $filetype) {
                if (empty($_REQUEST['filesize']) || $_REQUEST['filesize'] == 'sizeunlimit' || $_REQUEST['filesize'] == 'sizeless' && filesize($filename) <= 1024 || $_REQUEST['filesize'] == 'sizemore' && filesize($filename) >= 1024) {
                    $filedata = jieqi_readfile($filename);
                    if ($_REQUEST['replacetype'] == 1) {
                        $filedata = str_replace($fromary, $toary, $filedata);
                    } else {
                        $filedata = str_replace($_REQUEST['txtsearch'], $_REQUEST['txtreplace'], $filedata);
                    }
                    jieqi_writefile($filename, $filedata);
                }
            }
        }
        $showinfo = $jieqiLang['article']['replace_success_next'];
    } else {
        $showinfo = $jieqiLang['article']['replace_noid_next'];
    }
}
示例#9
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;
}
示例#10
0
 foreach ($jieqi_image_type as $k => $v) {
     if ($image_postfix == $v) {
         $image_type = $k;
         break;
     }
 }
 $old_avatar = $jieqiUsers->getVar('avatar', 'n');
 $jieqiUsers->unsetNew();
 $jieqiUsers->setVar('avatar', $image_type);
 if (!$users_handler->insert($jieqiUsers)) {
     jieqi_printfail($jieqiLang['system']['avatar_set_failure']);
 } else {
     //<!--jieqi insert license check-->
     //保存图片
     if (!empty($_FILES['avatarimage']['name'])) {
         $imagefile = jieqi_uploadpath($jieqiConfigs['system']['avatardir'], 'system');
         if (!file_exists($retdir)) {
             jieqi_createdir($imagefile);
         }
         $imagefile .= jieqi_getsubdir($jieqiUsers->getVar('uid', 'n'));
         if (!file_exists($retdir)) {
             jieqi_createdir($imagefile);
         }
         if ($old_avatar > 0 && isset($jieqi_image_type[$old_avatar])) {
             $old_imagefile = $imagefile . '/' . $jieqiUsers->getVar('uid', 'n') . $jieqi_image_type[$old_avatar];
             if (is_file($old_imagefile)) {
                 jieqi_delfile($old_imagefile);
             }
         }
         $imagefile .= '/' . $jieqiUsers->getVar('uid', 'n') . $image_postfix;
         jieqi_copyfile($_FILES['avatarimage']['tmp_name'], $imagefile, 0777, true);