<?
if (!defined('_GNUBOARD_')) exit;

$margin = $config[cf_home_margin];

function banner_sero($banner_sca)
{
    global $g4, $is_admin, $margin; 

	$list = array();
    $g4_table         = "banner";	  
    $g4_site_table    = $g4['table_prefix']."site_".$g4_table;  
    $mct              = " where po_poll1 = '$banner_sca' ";
    $sql              = " select * from $g4_site_table $mct order by po_cnt4, po_id ";
    $result           = sql_query($sql);
	$total_count      = mysql_num_rows($result);


	if($total_count){
    ob_start();
		     echo "<table cellpadding=0 cellspacing=0>";
		for ($i=0; $row = sql_fetch_array($result); $i++){

             //파일 확장자 검색, 오류예방
	         $path_info       =  pathinfo($row[po_poll19]);
	         //  $path_info["extension"];

			 
			 if($path_info["extension"] == 'swf'){//플레쉬 파일일경우
		     echo "<tr height='".$config[cf_home_margin]."'><td></td></tr><tr><td align='center'>";
                 ?>
                <script>
                doc_write(flash_movie("<?=$g4[path]?>/data/file/banner/<?=$row[po_poll19]?>", "myfile", "<?=$row[po_cnt5]?>", "<?=$row[po_cnt6]?>", "transparent"));
                </script>
				 <?
			 echo "</td></tr>";
			 }
			 else{
		     echo "<tr height='".$config[cf_home_margin]."'><td></td></tr><tr><td align='center'>";
			 echo "<a href='$row[po_poll4]' target='$row[po_poll5]' >"; // 연결할 주소
             echo "<img src='$g4[path]/data/file/banner/$row[po_poll19]' title='$row[po_subject]'  border='0'>";
			 echo "</a>";
			 echo "</td></tr>";
			 }
		}
		     echo "</table>";
    $content = ob_get_contents();
    ob_end_clean();

	}
	else{
    ob_start();
	  if($is_admin){
	    $set_url = "관리자화면에서 배너를 등록하세요.</span> 카테고리 :<a href=".$g4[path]."/adm/category_list.php?url=banner>";
		echo "<table width='100%' border=0 cellpadding=0 cellspacing=0 align='center'><tr height='".$margin."'><td></td></tr></table>";
		echo "[{$set_url}{$banner_sca}</a>]";
	   }

    $content = ob_get_contents();
    ob_end_clean();
	}

    return $content;
}

function banner_garo($banner_sca)
{
    global $g4, $is_admin, $margin;

	$list = array();
    $g4_table         = "banner";	  
    $g4_site_table    = $g4['table_prefix']."site_".$g4_table; 


    $mct              = " where po_poll1 = '$banner_sca' ";
    $sql              = " select * from $g4_site_table $mct order by po_cnt4, po_id ";
    $result           = sql_query($sql);
	$total_count      = mysql_num_rows($result);

	$banner_target    = $result[po_poll1]; // 대상프레임


	if($total_count){
    ob_start();
		     echo "<table cellpadding=0 cellspacing=0><tr height='".$config[cf_home_margin]."'><td></td></tr><tr>";

		for ($i=0; $row = sql_fetch_array($result); $i++){

             //파일 확장자 검색, 오류예방
	         $path_info       =  pathinfo($row[po_poll19]);
	         //  $path_info["extension"];

			 if($path_info["extension"] == 'swf'){//플레쉬 파일일경우
		     echo "<td align='center'>";             
                 ?>
                <script>
                doc_write(flash_movie("<?=$g4[path]?>/data/file/banner/<?=$row[po_poll19]?>", "myfile", "<?=$row[po_cnt5]?>", "<?=$row[po_cnt6]?>", "transparent"));
                </script>
				 <?
			 echo "</td>";
			 }
			 else{
		     echo "<td align='center'>";             
			 echo "<a href='$row[po_poll4]' target='$row[po_poll5]'>"; // 연결할 주소
             echo "<img src='$g4[path]/data/file/banner/$row[po_poll19]' title='$row[po_subject]'  border='0'>";
			 echo "</a>";
			 echo "</td>";
			 }
		}
		     echo "</tr></table>";
    $content = ob_get_contents();
    ob_end_clean();
	}
	else{
    ob_start();
	  if($is_admin){
	    $set_url = "관리자화면에서 배너를 등록하세요.</span> 카테고리 :<a href=".$g4[path]."/adm/category_list.php?url=banner>";
		echo "<table width='100%' border=0 cellpadding=0 cellspacing=0 align='center'><tr height='".$margin."'><td></td></tr></table>";
		echo "[{$set_url}{$banner_sca}</a>]";
	   }

    $content = ob_get_contents();
    ob_end_clean();
	}

    return $content;
}

function banner_rand($banner_sca)
{
    global $g4, $is_admin, $margin;

	$list = array();
    $g4_table         = "banner";	  
    $g4_site_table    = $g4['table_prefix']."site_".$g4_table; 


    $mct              = " where po_poll1 = '$banner_sca' ";
    $sql              = " select * from $g4_site_table $mct order by po_cnt4, po_id ";
    $result           = sql_query($sql);
	$total_count      = mysql_num_rows($result);
	$t_c              = $total_count -1;

	$banner_target    = $result[po_poll1]; // 대상프레임


	if($total_count){
    ob_start();
		     echo "<table width='100%' border=0 cellpadding=0 cellspacing=0 align='center'><tr height='".$margin."'><td></td></tr><tr>";
		     echo "<td align='center'>"; 

		for ($i=0; $row = sql_fetch_array($result); $i++){

             //파일 확장자 검색, 오류예방
	         $path_info       =  pathinfo($row[po_poll19]);
	         //  $path_info["extension"];

			 if($path_info["extension"] == 'swf'){//플레쉬 파일일경우

             $data[$i] = "<script>doc_write(flash_movie('$g4[path]/data/file/banner/$row[po_poll19]', 'myfile', '$row[po_cnt5]', '$row[po_cnt6]', 'transparent'));</script>";

			 }
			 else{           

			 $data[$i] = "<a href='$row[po_poll4]' target='$row[po_poll5]'><img src='$g4[path]/data/file/banner/$row[po_poll19]' title='$row[po_subject]'  border='0'></a>";

			 }
		}

            $rand         = mt_rand(0,$t_c); 
            $data_view    = "$data[$rand]";

			 echo $data_view;
			 echo "</td>";
		     echo "</tr></table>";

    $content = ob_get_contents();
    ob_end_clean();
	}
	else{
    ob_start();
	   if($is_admin){
	    $set_url = "관리자화면에서 배너를 등록하세요.</span> 카테고리 :<a href=".$g4[path]."/adm/category_list.php?url=banner>";
		echo "<table width='100%' border=0 cellpadding=0 cellspacing=0><tr height='".$margin."'><td></td></tr></table><table width='100%' border=0 cellpadding=0 cellspacing=1 bgcolor='#d9d9d9'><tr height='100'><td bgcolor='#ffffff' align='center'>[{$set_url}{$banner_sca}</a>]</td></tr></table>";
	   }else{
		echo "<table width='100%' border=0 cellpadding=0 cellspacing=0><tr height='".$margin."'><td></td></tr></table><table width='100%' border=0 cellpadding=0 cellspacing=1 bgcolor='#d9d9d9'><tr height='100'><td bgcolor='#ffffff' align='center'>등록된 배너가 없습니다.</td></tr></table>";
	   }

    $content = ob_get_contents();
    ob_end_clean();
	}

    return $content;
}
?>