<?php   if(!defined('DEDEINC')) exit('Request Error!');
/**
 * @自动更新HTML静态文件模块
 * 
 * 
 * @适合用于使用虚拟主机的个人站点
 * 
 * @织梦技术研究中心   http://bbs.dedejs.com
 *
 * @版本	AutoHtml V5.7.4 Final
 */
function lib_autohtml(&$ctag, &$refObj)
{
	global $_sys_globals,$_arclistEnv,$cfg_cmspath;
	require_once(DEDEINC.'/autohtml.class.php');
	$ah = new AutoHtml();
	$curfile = $_sys_globals['curfile'];

	//freelist,index,spec,archives,list
	$type = $rs = '';
	if($curfile=='partview')
	{
		$type = ($_arclistEnv=='index') ? 'index' : 'freelist';
	}
	else if($curfile=='list')
	{
		$type = ($refObj->Fields['issystem']=='-1') ? 'sglist' : 'list';
	}
	else if($curfile=='archives')
	{
		$type = 'archives';
	}
	else if(empty($curfile))
	{
		$type = class_exists('SpecView') ? 'spec' : '' ;
	}

	include($ah->cacheglobal);
	$focus_dir = empty($focus_dir) ? $cfg_cmspath.'/plus/' : $focus_dir;
	$filepath = $focus_dir.'autohtml.php';
	$webroot = str_replace("\\", '/', substr(DEDEROOT,0,-strlen($cfg_cmspath)) );
	if(!file_exists($webroot.$filepath)) $filepath = $cfg_cmspath.'/plus/autohtml.php';

	//$filepath = '/ah.php';

	switch($type)
	{
	    case "list" : 
		$rs = "<script language=\"javascript\" type=\"text/javascript\" src=\"{$filepath}?type=list&id={$refObj->Fields['typeid']}\"></script>";

	    break;
	    case "sglist" : 
		$rs = "<script language=\"javascript\" type=\"text/javascript\" src=\"{$filepath}?type=list&sg=sg&id={$refObj->Fields['typeid']}\"></script>";

	    break;
	    case "freelist" : 
		$rs = "<script language=\"javascript\" type=\"text/javascript\" src=\"{$filepath}?type=freelist&id={$refObj->Fields['typeid']}\"></script>";

	    break;
	    case "archives" : 
		$rs = "<script language=\"javascript\" type=\"text/javascript\" src=\"{$filepath}?type=archives&id={$refObj->Fields['aid']}\"></script>";

	    break;
	    case "spec" :
		$rs = "<script language=\"javascript\" type=\"text/javascript\" src=\"{$filepath}?type=spec\"></script>";

	    break;
	    case "index" :
		$rs = "<script language=\"javascript\" type=\"text/javascript\" src=\"{$filepath}?type=index\"></script>";
	
	    break;
	    default : break;
	}
	autohtml_docheck($ah);
	return $rs;
}

function autohtml_docheck($ah)
{
	include($ah->cacheglobal);
	if($check_open != 'Y') return;

	$nowtime = Time();
	$check_interval = is_numeric($check_interval) ? $check_interval : 0;
	$check_uptime = isset($check_uptime) && is_numeric($check_uptime) ? $check_uptime : 0;

	$nextruntime = $check_uptime + $check_interval * 60;

	if($nextruntime < $nowtime)
	{
		$ctarr = array();
		$nowh = date("H",$nowtime);
		$ched = $achtml = $hs = $ts = '';
		if(!empty($check_time))
		{
			$checkt = explode(',',$check_time);
			foreach($checkt as $k1 => $v1) $ctarr[$v1] = $v1;
			unset($k1);unset($v1);unset($checkt);
		}
		if(empty($ctarr) || in_array($nowh,$ctarr))
		{
			$check_pages = is_numeric($check_pages) ? $check_pages : 20;

			if($check_pages == '0' && $check_makearc == 'N')
			{
				$ah->make->checkall();
			}
			else
			{
				$ah->make->checkarc();
			}
		}
	}
}
?>