/**
  *  生成静态HTML
  *
  * @access    public
  * @param     int    $isremote  是否远程
  * @return    string
  */
 function MakeHtml($isremote = 0)
 {
     global $cfg_remote_site, $fileFirst;
     if ($this->IsError) {
         return '';
     }
     $this->Fields["displaytype"] = "st";
     //预编译$th
     $this->LoadTemplet();
     $this->ParAddTable();
     $this->ParseTempletsFirst();
     $this->Fields['senddate'] = empty($this->Fields['senddate']) ? '' : $this->Fields['senddate'];
     $this->Fields['title'] = empty($this->Fields['title']) ? '' : $this->Fields['title'];
     $this->Fields['arcrank'] = empty($this->Fields['arcrank']) ? 0 : $this->Fields['arcrank'];
     $this->Fields['ismake'] = empty($this->Fields['ismake']) ? 0 : $this->Fields['ismake'];
     $this->Fields['money'] = empty($this->Fields['money']) ? 0 : $this->Fields['money'];
     $this->Fields['filename'] = empty($this->Fields['filename']) ? '' : $this->Fields['filename'];
     //分析要创建的文件名称
     $filename = GetFileNewName($this->ArcID, $this->Fields['typeid'], $this->Fields['senddate'], $this->Fields['title'], $this->Fields['ismake'], $this->Fields['arcrank'], $this->TypeLink->TypeInfos['namerule'], $this->TypeLink->TypeInfos['typedir'], $this->Fields['money'], $this->Fields['filename']);
     $filenames = explode(".", $filename);
     $this->ShortName = $filenames[count($filenames) - 1];
     if ($this->ShortName == '') {
         $this->ShortName = 'html';
     }
     $fileFirst = preg_replace("/\\." . $this->ShortName . "\$/i", "", $filename);
     $this->Fields['namehand'] = basename($fileFirst);
     $filenames = explode("/", $filename);
     $this->NameFirst = preg_replace("/\\." . $this->ShortName . "\$/i", "", $filenames[count($filenames) - 1]);
     if ($this->NameFirst == '') {
         $this->NameFirst = $this->arcID;
     }
     //获得当前文档的全名
     $filenameFull = GetFileUrl($this->ArcID, $this->Fields['typeid'], $this->Fields["senddate"], $this->Fields["title"], $this->Fields["ismake"], $this->Fields["arcrank"], $this->TypeLink->TypeInfos['namerule'], $this->TypeLink->TypeInfos['typedir'], $this->Fields["money"], $this->Fields['filename'], $this->TypeLink->TypeInfos['moresite'], $this->TypeLink->TypeInfos['siteurl'], $this->TypeLink->TypeInfos['sitepath']);
     $this->Fields['arcurl'] = $this->Fields['fullname'] = $filenameFull;
     //对于已设置不生成HTML的文章直接返回网址
     if ($this->Fields['ismake'] == -1 || $this->Fields['arcrank'] != 0 || $this->Fields['money'] > 0 || $this->Fields['typeid'] == 0 && $this->Fields['channel'] != -1) {
         return $this->GetTrueUrl($filename);
     } else {
         for ($i = 1; $i <= $this->TotalPage; $i++) {
             if ($this->TotalPage > 1) {
                 $this->Fields['tmptitle'] = empty($this->Fields['tmptitle']) ? $this->Fields['title'] : $this->Fields['tmptitle'];
                 if ($i > 1) {
                     $this->Fields['title'] = $this->Fields['tmptitle'] . "({$i})";
                 }
             }
             if ($i > 1) {
                 $TRUEfilename = $this->GetTruePath() . $fileFirst . "_" . $i . "." . $this->ShortName;
             } else {
                 $TRUEfilename = $this->GetTruePath() . $filename;
             }
             $this->ParseDMFields($i, 1);
             $this->dtp->SaveTo($TRUEfilename);
             //如果启用远程发布则需要进行判断
             if ($cfg_remote_site == 'Y' && $isremote == 1) {
                 //分析远程文件路径
                 $remotefile = str_replace(DEDEROOT, '', $TRUEfilename);
                 $localfile = '..' . $remotefile;
                 //创建远程文件夹
                 $remotedir = preg_replace("#[^\\/]*\\.html#", '', $remotefile);
                 $this->ftp->rmkdir($remotedir);
                 $this->ftp->upload($localfile, $remotefile, 'ascii');
             }
         }
     }
     $this->dsql->ExecuteNoneQuery("Update `#@__archives` SET ismake=1 WHERE id='" . $this->ArcID . "'");
     return $this->GetTrueUrl($filename);
 }
	function GetFileNewName($aid,$typeid,$timetag,$title,$ismake=0,$rank=0,$namerule="",$artdir="",$money=0,$siterefer="",$sitepath=""){
		$articleRule = "";
		$articleDir = "";
		if($namerule!="") $articleRule = $namerule;
		else if(is_array($this->TypeInfos)) $articleRule = $this->TypeInfos['namerule'];
		if($artdir!="") $articleDir = $artdir;
		else if(is_array($this->TypeInfos)) $articleDir = $this->GetTypeDir();
		return GetFileNewName($aid,$typeid,$timetag,$title,$ismake,$rank,$articleRule,$articleDir,$money,$siterefer,$sitepath);
	}
function getfilenameonly($arcid, $typeid, $senddate, $title, $ismake, $arcrank, $money)
{
	global $dsql;
	require_once DEDEINC.'/inc_channel_unit_functions.php';
 
	$row = $dsql->getone("select namerule, typedir, siterefer, sitepath ,channeltype from #@__arctype where ID='$typeid'");

	if(is_array($row)){
		if($row['channeltype'] == -2) return $GLOBALS['cfg_plus_dir']."/view.php?aid=$arcid";
		$filename = GetFileNewName($arcid, $typeid, $senddate, $title, $ismake, $arcrank, $row['namerule'],
												$row['typedir'],$money,$row['siterefer'], $row['sitepath']);
	}else{
		showmsg('栏目id错误','-1');
		exit;
	}
	if($filename=="") $filename = $GLOBALS['cfg_plus_dir']."/view.php?aid=$arcid";
	return $filename;
}
 function MakeHtml()
 {
     if ($this->IsError) {
         return '';
     }
     $this->Fields["displaytype"] = "st";
     //预编译$th
     $this->LoadTemplet();
     $this->ParAddTable();
     $this->ParseTempletsFirst();
     //分析要创建的文件名称
     $filename = GetFileNewName($this->ArcID, $this->Fields['typeid'], $this->Fields['senddate'], $this->Fields['title'], $this->Fields['ismake'], $this->Fields['arcrank'], $this->TypeLink->TypeInfos['namerule'], $this->TypeLink->TypeInfos['typedir'], $this->Fields['money'], $this->Fields['filename']);
     $filenames = explode(".", $filename);
     $this->ShortName = $filenames[count($filenames) - 1];
     if ($this->ShortName == '') {
         $this->ShortName = 'html';
     }
     $fileFirst = eregi_replace("\\." . $this->ShortName . "\$", "", $filename);
     $this->Fields['namehand'] = basename($fileFirst);
     $filenames = explode("/", $filename);
     $this->NameFirst = eregi_replace("\\." . $this->ShortName . "\$", "", $filenames[count($filenames) - 1]);
     if ($this->NameFirst == '') {
         $this->NameFirst = $this->arcID;
     }
     //获得当前文档的全名
     $filenameFull = GetFileUrl($this->ArcID, $this->Fields['typeid'], $this->Fields["senddate"], $this->Fields["title"], $this->Fields["ismake"], $this->Fields["arcrank"], $this->TypeLink->TypeInfos['namerule'], $this->TypeLink->TypeInfos['typedir'], $this->Fields["money"], $this->Fields['filename'], $this->TypeLink->TypeInfos['moresite'], $this->TypeLink->TypeInfos['siteurl'], $this->TypeLink->TypeInfos['sitepath']);
     $this->Fields['arcurl'] = $this->Fields['fullname'] = $filenameFull;
     //对于已设置不生成HTML的文章直接返回网址
     if ($this->Fields['ismake'] == -1 || $this->Fields['arcrank'] != 0 || $this->Fields['money'] > 0 || $this->Fields['typeid'] == 0 && $this->Fields['channel'] != -1) {
         return $this->GetTrueUrl($filename);
     } else {
         for ($i = 1; $i <= $this->TotalPage; $i++) {
             if ($this->TotalPage > 1) {
                 $this->Fields['tmptitle'] = empty($this->Fields['tmptitle']) ? $this->Fields['title'] : $this->Fields['tmptitle'];
                 if ($i > 1) {
                     $this->Fields['title'] = $this->Fields['tmptitle'] . "({$i})";
                 }
             }
             if ($i > 1) {
                 $truefilename = $this->GetTruePath() . $fileFirst . "_" . $i . "." . $this->ShortName;
             } else {
                 $truefilename = $this->GetTruePath() . $filename;
             }
             $this->ParseDMFields($i, 1);
             $this->dtp->SaveTo($truefilename);
         }
     }
     $this->dsql->ExecuteNoneQuery("Update `#@__archives` set ismake=1 where id='" . $this->ArcID . "'");
     return $this->GetTrueUrl($filename);
 }