<?
include "ȯ°æ ¼³Á¤ ÆÄÀϵé";
// DB¸¦ Á¤ÀÇÇÕ´Ï´Ù. ¿©±â¼´Â DB Ŭ·¡½º ÆÄÀÏÀ» includeÇؼ »ç¿ëÇß½À´Ï´Ù.
$DB = new DB_Mysql($WEB_HOST,$WEB_USER,$WEB_PASS,$WEB_DB);
// ³»º¸³¾ µ¥ÀÌÅ͸¦ °¡Á®¿É´Ï´Ù.
$sql = "select * from Å×À̺í¸í order by idx desc";
$DB->query($sql);
// CSV ÆÄÀÏ ÃÖ»ó´Ü¿¡ Ç¥±â ÇÒ ³»¿ëÀÔ´Ï´Ù.
$csv_dump .= "ID,UID,¹ß¼ÛÀÚ,¹ß¼ÛÀÚ¸ÞÀÏÁÖ¼Ò,¼ö½ÅÀÚID,¼ö½ÅÀÚUID,¼ö½ÅÀÚ¸ÞÀÏÁÖ¼Ò,¸ÞÀÏÁÖ¼Ò°ø°³¿©ºÎ,¸ÞÀϳ»¿ë,¹ß¼Û³¯Â¥,";
$csv_dump .= "\r\n";
// while ·Î µ¥ÀÌÅ͸¦ º¯¼ö¿¡ ¾µ¾î ³Ö½À´Ï´Ù -_-;
while ($row = $DB->fetch_array()) {
// CSVÀúÀå ½Ã CR+LF ¹× , Ç¥½Ã°¡ ÀÖÀ¸¸é ¾ÈµÇ¹Ç·Î ġȯ½Ãŵ´Ï´Ù.
$row[mail_txt] = str_replace("\r\n","",$row[mail_txt]);
$row[mail_txt] = str_replace(","," ",$row[mail_txt]);
// Çà °ªÀ» csv_dump ¿¡ ¾µ¾î´ã½À´Ï´Ù -_-;
$csv_dump .= $row[UserID].",";
$csv_dump .= $row[UserUID].",";
$csv_dump .= $row[send_char].",";
$csv_dump .= $row[send_mail].",";
$csv_dump .= $row[re_UserID].",";
$csv_dump .= $row[re_UserUID].",";
$csv_dump .= $row[re_mail].",";
$csv_dump .= $row[mailagree].",";
$csv_dump .= $row[mail_txt].",";
$csv_dump .= $row[regdate].",";
$csv_dump .= "\r\n";
} // while¹® Á¾·á
// CSV ÆÄÀÏ·Î ÀúÀåÇÕ´Ï´Ù. ÆÄÀϸíÀ» ³¯Â¥¸¦ ºÙ¿© »ý¼ºÇÕ´Ï´Ù.
$date = date("YmdHi");
$filename = "csvoutput_".$date.".csv";
header( "Content-type: application/vnd.ms-excel;charset=KSC5601" );
header("Content-Disposition: attachment; filename=$filename");
header( "Content-Description: PHP4 Generated Data" );
echo $csv_dump;
$DB->close();
?>
|