<?
// 그릅축출방식
function cart_menu($skin_dir="",$cart_table,$bo_table,$cart_id,$options="" , $options2="2")
{
    global $g4;

    if ($skin_dir)
        $cart_menu_path = "$g4[path]/skin/sub_menu/$skin_dir";
    else
        $cart_menu_path = "$g4[path]/skin/sub_menu/cart_basic";

    $list = array();

	$mct      = " wr_reply = ''";
	


    $sql      = " select * from $cart_table where  {$mct}  order by ne_8, wr_id desc ";
    $result   = sql_query($sql);
    $total_count  = mysql_num_rows($result);

    if($total_count){
    ob_start();
    include "$cart_menu_path/cart_menu.skin.php";
    $content = ob_get_contents();
    ob_end_clean();
	}
	else{
    $content = '';
	}
    return $content;   

}

// 스킨경로를 얻는다
function get_cate_dir($skin, $len='')
{
    global $g4;

    $result_array = array();

    $dirname = "$g4[path]/skin/board/$skin/";
    $handle = opendir($dirname);
	$i=0;
    while ($file = readdir($handle)) 
    {
        if($file == "."||$file == "..") continue;

        if (!(is_dir($dirname.$file))){
           if (!(preg_match("/\.(bak)$/i", $file)))
			$result_array[] = $file;
		}
	 $i++;

    }
    closedir($handle);
    sort($result_array);

    return $result_array;
}

// 분류 cart_id 의 길이 환산
function cart_strlen($cart_table, $cart_id)
{
    global $g4;

	//분류값 검사
    $cart_sql   = " select wr_reply from $cart_table where ne_1 = '$cart_id' ";
    $cart_row   = sql_fetch($cart_sql);

    $sql_search  = "";

    $reply_len = strlen($cart_row[wr_reply]);

	if($reply_len == '1'){
     $sql_search .= " wr_22 = '$cart_id' "; //
	}
	elseif($reply_len == '2'){
     $sql_search .= " wr_23 = '$cart_id' "; //
	}
	else{
     $sql_search .= " wr_21 = '$cart_id' "; //최상단메뉴인경우
	}


    return $sql_search;
}

function banner_sero($banner_sca)
{
    global $g4;

	$list = array();
    $g4_table         = "banner";	  
    $g4_site_table    =  "g4_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><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><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();

	}

    return $content;
}

function banner_garo($banner_sca)
{
    global $g4;

	$list = array();
    $g4_table         = "banner";	  
    $g4_site_table    =  "g4_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>";

		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();

	}

    return $content;
}
?>