<?php
/*
 * Copyright(C). D-cube,Inc. All Rights Reserved.
 */

/*
 * @file		MakeHtaccess.class.php
 * @brief		htaccess生成クラス
 * @date		2007.01.29
 */

require_once(CLASS_DIR."/PageRender.class.php");
require_once(CLASS_DIR."/adodb/GroupManager.class.php");

class MakeHtaccess extends PageRender
{
	function execute()
	{
		$group_dao = new GroupManager();
		$sql  = " select ";
		$sql .= " $group_dao->group.group_code ";
		$sql .= " ,$group_dao->group.group_dir_name ";
		$sql .= " ,$group_dao->group.group_upload_dir_name ";
		$sql .= " ,$group_dao->group.group_rss1_output ";
		$sql .= " ,$group_dao->group.group_rss1_file_name ";
		$sql .= " ,$group_dao->group.group_rss2_output ";
		$sql .= " ,$group_dao->group.group_rss2_file_name ";
		$sql .= " ,$group_dao->group.group_atom_output ";
		$sql .= " ,$group_dao->group.group_atom_file_name ";
		$sql .= " from ";
		$sql .= " $group_dao->group ";
		$sql .= " where $group_dao->group.is_delete = 0 ";
		
		$this->assign("group_array",$group_dao->GetAll($sql));
		
		// ファイル書き出し
		if(!$handle = fopen(ROOT_PATH.".htaccess","w"))
			return false;
		if(!fwrite($handle,$this->fetch("../htaccess.tpl")))
			return false;
		fclose($handle);
		
		return true;
	}
}
