<?

include_once("./_common.php");


    $ext= $addr_day." 00:00:00";
      
    $sql = " SELECT * FROM $g[member_table] where mb_mailling ='' and mb_datetime >= '$ext'"; 
    
    $result = sql_query($sql);
    $cnt = @sql_num_rows($result);
    if (!$cnt)
        alert("출력할 내역이 없습니다.");
 
    header('Content-Type: application/vnd.ms-excel');
    header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    header('Content-Disposition: attachment; filename="memberlist' . date("ymd", time()) . '.xls"');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('content-transfer-encoding: binary');
	echo "<html><head>";
//	echo "<meta http-equiv='Content-Type' content='application/vnd.ms-excel;charset=euc-kr'>";
	echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>";
	echo "</head><body>";
    
    if($addr_sel == 1) { // 일반백업
    echo "<table border=1 style='font-family:돋움; font-size:10pt;'><tr>";
    echo "<td align=center>아이디</td><td align=center>이름</td><td align=center>이메일</td><td align=center>휴대폰</td><td align=center>일반전화</td><td align=center>홈페이지</td><td align=center>레벨</td><td align=center>성별</td><td align=center>생일</td><td align=center>주소</td><td align=center>주소상세</td><td align=center>직업</td><td align=center>추천인ID</td><td align=center>포인트</td><td align=center>가입일</td><td align=center>메모</td><td align=center>문자수신</td><td align=center>메일수신</td><td align=center>여분1</td><td align=center>여분2</td><td align=center>여분3</td><td align=center>여분4</td><td align=center>여분5</td><td align=center>여분6</td><td align=center>여분7</td><td align=center>여분8</td><td align=center>여분9</td><td align=center>여분10</td></tr>\n";
    for ($i=0; $row=sql_fetch_array($result); $i++) {
		echo "<tr>\n";
		echo "<td align=center>" . $row[mb_id] . "</td>\n";        
		echo "<td align=center>" . $row[mb_name] . "</td>\n";
        echo "<td align=center>" . $row[mb_email] . "</td>\n";
        echo "<td align=center>" . $row[mb_hp] . "</td>\n";
        echo "<td align=center>" . $row[mb_tel] . "</td>\n";
        echo "<td align=center>" . $row[mb_homepage] . "</td>\n";                                  
		echo "<td align=center>" . $row[mb_level] . "</td>\n";
        echo "<td align=center>" . $row[mb_sex] . "</td>\n";
        echo "<td align=center>" . $row[mb_birth] . "</td>\n";
        echo "<td align=center>" . $row[mb_addr1] . "</td>\n";
        echo "<td align=center>" . $row[mb_addr2] . "</td>\n";
        echo "<td align=center>" . $row[mb_3] . "</td>\n";        
        echo "<td align=center>" . $row[mb_recommend] . "</td>\n";        
        echo "<td align=center>" . $row[mb_point] . "</td>\n";                
        echo "<td align=center>" . $row[mb_datetime] . "</td>\n";
        echo "<td align=center>" . $row[mb_memo] . "</td>\n";        
        echo "<td align=center>" . $row[mb_mailling] . "</td>\n";
        echo "<td align=center>" . $row[mb_sms] . "</td>\n";
        echo "<td align=center>" . $row[mb_1] . "</td>\n";        
        echo "<td align=center>" . $row[mb_2] . "</td>\n";
        echo "<td align=center>" . $row[mb_3] . "</td>\n";        
        echo "<td align=center>" . $row[mb_4] . "</td>\n";
        echo "<td align=center>" . $row[mb_5] . "</td>\n";
        echo "<td align=center>" . $row[mb_6] . "</td>\n";        
        echo "<td align=center>" . $row[mb_7] . "</td>\n";
        echo "<td align=center>" . $row[mb_8] . "</td>\n";
        echo "<td align=center>" . $row[mb_9] . "</td>\n";
        echo "<td align=center>" . $row[mb_10] . "</td>\n";                 
}        
        echo "</tr>\n";
  
    
    }  else if($addr_sel == 2) { // 아웃록
    echo "<table border=1 style='font-family:돋움; font-size:10pt;'><tr>";
    echo "<td align=center>이름</td><td align=center>이메일</td><td align=center>전화번호</td><td align=center>그룹명</td><td align=center>추가전화번호1</td><td align=center>추가전화번호2</td><td align=center>추가 이메일1</td><td align=center>추가 이메일2</td><td align=center>블로그주소</td><td align=center>메신저주소</td><td align=center>회사명</td><td align=center>부서명</td><td align=center>회사주소</td><td align=center>집주소</td><td align=center>생일</td><td align=center>메모</td></tr>\n";
    for ($i=0; $row=sql_fetch_array($result); $i++) {
		echo "<tr>\n";
		echo "<td align=center>" . $row[mb_name] . "</td>\n";
        echo "<td align=center>" . $row[mb_email] . "</td>\n";
        echo "<td align=center>" . $row[mb_hp] . "</td>\n";                
		echo "<td align=center></td>\n";
		echo "<td align=center>" . $row[mb_tel] . "</td>\n";
        echo "<td align=center></td>\n";
        echo "<td align=center></td>\n";
        echo "<td align=center></td>\n";
        echo "<td align=center></td>\n";
        echo "<td align=center></td>\n";                
        echo "<td align=center></td>\n";
        echo "<td align=center></td>\n";
        echo "<td align=center>" . $row[mb_addr1]." ".$row[mb_addr2] . "</td>\n";
        echo "<td align=center></td>\n";
        echo "<td align=center>" . $row[mb_birth] . "</td>\n";
        echo "<td align=center>" . $row[mb_memo] . "</td>\n";
}        
        echo "</tr>\n";
  
    
    } else if($addr_sel == 3) { // 네이버
    echo "<table border=1 style='font-family:돋움; font-size:10pt;'><tr>";
    echo "<td align=center>이름</td><td align=center>이메일</td><td align=center>전화번호</td><td align=center>그룹명</td><td align=center>추가전화번호1</td><td align=center>추가전화번호2</td><td align=center>추가 이메일1</td><td align=center>추가 이메일2</td><td align=center>블로그주소</td><td align=center>메신저주소</td><td align=center>회사명</td><td align=center>부서명</td><td align=center>회사주소</td><td align=center>집주소</td><td align=center>생일</td><td align=center>메모</td></tr>\n";
    for ($i=0; $row=sql_fetch_array($result); $i++) {
		echo "<tr>\n";
		echo "<td align=center>" . $row[mb_name] . "</td>\n";
        echo "<td align=center>" . $row[mb_email] . "</td>\n";
        echo "<td align=center>" . $row[mb_hp] . "</td>\n";                
		echo "<td align=center></td>\n";
		echo "<td align=center>" . $row[mb_tel] . "</td>\n";
        echo "<td align=center></td>\n";
        echo "<td align=center></td>\n";
        echo "<td align=center></td>\n";
        echo "<td align=center></td>\n";
        echo "<td align=center></td>\n";                
        echo "<td align=center></td>\n";
        echo "<td align=center></td>\n";
        echo "<td align=center>" . $row[mb_addr1]." ".$row[mb_addr2] . "</td>\n";
        echo "<td align=center></td>\n";
        echo "<td align=center>" . $row[mb_birth] . "</td>\n";
        echo "<td align=center>" . $row[mb_memo] . "</td>\n";
}        
        echo "</tr>\n";
     } else if ($addr_sel == 4) { // 구글
    echo "<table border=1 style='font-family:돋움; font-size:10pt;'><tr>";
    echo "<td align=center>이름</td><td align=center>성</td><td align=center>이메일</td><td align=center>번지</td><td align=center>휴대전화</td><td align=center>일반전화</td><td align=center>웹사이트</td><td align=center>생일</td><td align=center>직업</td><td align=center>그룹</td><td align=center>메모</td></tr>\n";
    for ($i=0; $row=sql_fetch_array($result); $i++) {
		echo "<tr>\n";
		echo "<td align=center>" . $row[mb_name] . "</td>\n";
        echo "<td align=center></td>\n";                
        echo "<td align=center>" . $row[mb_email] . "</td>\n";
        echo "<td align=center>" . $row[mb_addr1]." ".$row[mb_addr2] . "</td>\n";        
        echo "<td align=center>" . $row[mb_hp] . "</td>\n";
        echo "<td align=center>" . $row[mb_tel] . "</td>\n";
        echo "<td align=center>" . $row[mb_homepage] . "</td>\n";
        echo "<td align=center>" . $row[mb_birth] . "</td>\n";
        echo "<td align=center></td>\n";        
        echo "<td align=center></td>\n";                
        echo "<td align=center>" . $row[mb_memo] . "</td>\n";                                        
    }        
        echo "</tr>\n";        
     } // 구글 end
    
    
    else if ($addr_sel == 5) { // 카페24 대량 메일
    echo "<table border=1 style='font-family:돋움; font-size:10pt;'><tr>";
    echo "<td align=center>이름</td><td align=center>성</td><td align=center>이메일</td><td align=center>번지</td><td align=center>휴대전화</td><td align=center>일반전화</td><td align=center>웹사이트</td><td align=center>생일</td><td align=center>직업</td><td align=center>그룹</td><td align=center>메모</td></tr>\n";
    for ($i=0; $row=sql_fetch_array($result); $i++) {
		echo "<tr>\n";
		echo "<td align=center>" . $row[mb_name] . "</td>\n";
        echo "<td align=center>" . $row[mb_email] . "</td>\n";
        echo "<td align=center>" . $row[mb_hp] . "</td>\n";
        echo "<td align=center>" . $row[mb_tel] . "</td>\n";
        echo "<td align=center>" . $row[mb_birth] . "</td>\n";
        echo "<td align=center>" . $row[mb_memo] . "</td>\n";                                        
    }        
        echo "</tr>\n";        
     } // 카페24 대량 end     

     
     
	echo "</table>";
	echo "</body></html>";
    if ($i == 0)
        alert("자료가 없습니다.");

    exit;
?>    