Beispiel #1
0
 function makejar_volume($vk = 0)
 {
     if ((JIEQI_MODULE_VTYPE == '' || JIEQI_MODULE_VTYPE == 'Free') && empty($GLOBALS['jieqi_license_modules']['waparticle']) || $GLOBALS['jieqi_license_modules']['waparticle'] == 'Free') {
         return true;
     }
     if (!function_exists('gzcompress') || !function_exists('iconv')) {
         return false;
     }
     global $jieqiConfigs;
     global $jieqi_file_postfix;
     include_once JIEQI_ROOT_PATH . '/lib/compress/jar.php';
     $jardir = $this->getDir('jardir', true, true);
     $txtdir = $this->getDir('txtdir', true, false);
     $vk = intval($vk);
     $vd = intval(JIEQI_JAR_DEFAULT_SIZE);
     //每卷程序占用几K
     $vc = floatval(JIEQI_JAR_COMPRESS_RATE);
     //压缩比例
     $vinfo = array();
     if (empty($vk) || $vk < $vd) {
         $jar = new JieqiJar();
         $jar->setcharset(strtoupper(JIEQI_SYSTEM_CHARSET));
         $jar->setinfo(array('id' => $this->id, 'title' => $this->metas['dc:Title'], 'author' => $this->metas['dc:Creator'], 'publisher' => $this->metas['dc:Publisher'], 'corver' => ''));
         //设置文章信息
         $volume = '';
         $fromvolume = '';
         $fromchapter = '';
         $fromchapterid = 0;
         $tovolume = '';
         $tochapter = '';
         $tochapterid = 0;
         $chapters = 0;
         $volumes = 0;
         $firstflag = true;
         foreach ($this->chapters as $k => $chapter) {
             if ($chapter['content-type'] == 'volume') {
                 $volume = $chapter['id'];
                 if ($firstflag) {
                     $fromvolume = $volume;
                 }
                 $tovolume = $volume;
                 $volumes++;
             } else {
                 $jar->addchapter($volume . ' ' . $chapter['id'], '<' . $volume . ' ' . $chapter['id'] . '>' . "\r\n" . jieqi_readfile($txtdir . '/' . $chapter['href']));
                 if ($fromchapter == '') {
                     $fromchapter = $chapter['id'];
                 }
                 $tochapter = $chapter['id'];
                 $tmpint = strpos($chapter['href'], '.');
                 if ($tmpint > 0) {
                     $tmpcid = intval(trim(substr($chapter['href'], 0, $tmpint)));
                 } else {
                     $tmpcid = 0;
                 }
                 if ($fromchapterid == 0) {
                     $fromchapterid = $tmpcid;
                 }
                 $tochapterid = $tmpcid;
                 $chapters++;
             }
             $firstflag = false;
         }
         $jar->makejar($jardir . '/' . $this->id . $jieqi_file_postfix['jar']);
         unset($jar);
         $vinfo['chapters'] = $chapters;
         $vinfo['volumes'] = $volumes;
         $vinfo['fromvolume'] = $fromvolume;
         $vinfo['fromchapter'] = $fromchapter;
         $vinfo['fromchapterid'] = $fromchapterid;
         $vinfo['tovolume'] = $tovolume;
         $vinfo['tochapter'] = $tochapter;
         $vinfo['tochapterid'] = $tochapterid;
         $vinfo['maketime'] = JIEQI_NOW_TIME;
         $vinfo['filesize'] = filesize($jardir . '/' . $this->id . $jieqi_file_postfix['jar']);
         $vinfo['jadsize'] = filesize($jardir . '/' . $this->id . $jieqi_file_postfix['jad']);
         include_once JIEQI_ROOT_PATH . '/lib/xml/xmlarray.php';
         $xmlarray = new XMLArray();
         $xmldata = $xmlarray->array2xml($vinfo);
         jieqi_writefile($jardir . '/' . $this->id . '.xml', $xmldata);
     } elseif ($vk > $vd) {
         $vid = 1;
         //第几卷
         $vnew = true;
         //是否需要新增卷
         $vsize = 0;
         $volume = '';
         foreach ($this->chapters as $k => $chapter) {
             if ($chapter['content-type'] == 'volume') {
                 $volume = $chapter['id'];
                 $vinfo[$vid]['volumes']++;
             } else {
                 $filedata = jieqi_readfile($txtdir . '/' . $chapter['href']);
                 $vcdata = '<' . $volume . ' ' . $chapter['id'] . '>' . "\r\n";
                 $filelen = strlen($filedata) + strlen($vcdata);
                 if ($vsize > 0 && ($vsize + $filelen) / 1024 * $vc > $vk - $vd) {
                     $jar->makejar($jardir . '/' . $this->id . '_' . $vk . '_' . $vid . $jieqi_file_postfix['jar']);
                     unset($jar);
                     $vinfo[$vid]['maketime'] = JIEQI_NOW_TIME;
                     $vinfo[$vid]['filesize'] = filesize($jardir . '/' . $this->id . '_' . $vk . '_' . $vid . $jieqi_file_postfix['jar']);
                     $vinfo[$vid]['jadsize'] = filesize($jardir . '/' . $this->id . '_' . $vk . '_' . $vid . $jieqi_file_postfix['jad']);
                     $vid++;
                     $vsize = 0;
                     $vnew = true;
                 }
                 if ($vnew) {
                     $jar = new JieqiJar();
                     $jar->setcharset(strtoupper(JIEQI_SYSTEM_CHARSET));
                     $jar->setinfo(array('id' => $this->id, 'title' => $this->metas['dc:Title'] . '_' . $vk . '_' . $vid, 'author' => $this->metas['dc:Creator'], 'publisher' => $this->metas['dc:Publisher'], 'corver' => ''));
                     //设置文章信息
                     $vnew = false;
                     $vinfo[$vid]['chapters'] = 0;
                     $vinfo[$vid]['volumes'] = 0;
                     $vinfo[$vid]['fromvolume'] = $volume;
                     $vinfo[$vid]['fromchapter'] = $chapter['id'];
                     $tmpint = strpos($chapter['href'], '.');
                     if ($tmpint > 0) {
                         $vinfo[$vid]['fromchapterid'] = intval(trim(substr($chapter['href'], 0, $tmpint)));
                     } else {
                         $vinfo[$vid]['fromchapterid'] = 0;
                     }
                 }
                 $jar->addchapter($volume . ' ' . $chapter['id'], $vcdata . $filedata);
                 $vsize = $vsize + $filelen;
                 $vinfo[$vid]['chapters']++;
                 $vinfo[$vid]['tovolume'] = $volume;
                 $vinfo[$vid]['tochapter'] = $chapter['id'];
                 $tmpint = strpos($chapter['href'], '.');
                 if ($tmpint > 0) {
                     $vinfo[$vid]['tochapterid'] = intval(trim(substr($chapter['href'], 0, $tmpint)));
                 } else {
                     $vinfo[$vid]['tochapterid'] = 0;
                 }
             }
         }
         if (!$vnew) {
             $jar->makejar($jardir . '/' . $this->id . '_' . $vk . '_' . $vid . $jieqi_file_postfix['jar']);
             $vinfo[$vid]['tovolume'] = $volume;
             $vinfo[$vid]['tochapter'] = $chapter['id'];
             $tmpint = strpos($chapter['href'], '.');
             if ($tmpint > 0) {
                 $vinfo[$vid]['tochapterid'] = intval(trim(substr($chapter['href'], 0, $tmpint)));
             } else {
                 $vinfo[$vid]['tochapterid'] = 0;
             }
             $vinfo[$vid]['maketime'] = JIEQI_NOW_TIME;
             $vinfo[$vid]['filesize'] = filesize($jardir . '/' . $this->id . '_' . $vk . '_' . $vid . $jieqi_file_postfix['jar']);
             $vinfo[$vid]['jadsize'] = filesize($jardir . '/' . $this->id . '_' . $vk . '_' . $vid . $jieqi_file_postfix['jad']);
             unset($jar);
         }
         include_once JIEQI_ROOT_PATH . '/lib/xml/xmlarray.php';
         $xmlarray = new XMLArray();
         $xmldata = $xmlarray->array2xml($vinfo);
         jieqi_writefile($jardir . '/' . $this->id . '_' . $vk . '.xml', $xmldata);
     } else {
         return false;
     }
 }
Beispiel #2
0
         $jieqiTpl->assign('vsize', 0);
     }
     $packrows = array();
     if ($_REQUEST['vsize'] <= 1) {
         $packxml = jieqi_uploadpath($jieqiConfigs['article']['umddir'], 'article') . jieqi_getsubdir($_REQUEST['id']) . '/' . $_REQUEST['id'] . '/' . $_REQUEST['id'] . '.xml';
     } else {
         $packxml = jieqi_uploadpath($jieqiConfigs['article']['umddir'], 'article') . jieqi_getsubdir($_REQUEST['id']) . '/' . $_REQUEST['id'] . '/' . $_REQUEST['id'] . '_' . $_REQUEST['vsize'] . '.xml';
     }
     //文件不存在或者过期自动生成
     if (!is_file($packxml) || filemtime($packxml) + 600 < $lastupdate) {
         include_once JIEQI_ROOT_PATH . '/modules/article/include/repack.php';
         article_repack($_REQUEST['id'], array('makeumd' => 1), 1);
     }
     if (is_file($packxml)) {
         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']);