blog.visualp.com
$file_name_only = substr($userfile_name,0,strrpos($userfile_name,"."));//파일이름
$file_name_ext = substr($userfile_name,strrpos($userfile_name,"."));//확장자이름
<?
header("Content-Type: application/vnd.ms-excel");
header("Content-Type: application/vnd.ms-excel; charset=euc-kr");
header("Content-Type: application/x-msdownload");
header("Content-Disposition: attachment; filename=$fileName.xls");
header("Content-Description: PHP4 Generated Data");
header("Pragma: no-cache");
header("Expires: 0");
header("Content-Type: file/unknown");
?>
<html>
<head><title>엑셀변환</title>
<script language="javascript">
self.close();
</script>
<style type="text/css">
body { font-family: "굴림"; font-size: 9pt; color: #595959; line-height:130%}
td { font-family: "굴림"; font-size: 9pt; color: #595959; line-height:130%}
A:visited { color: #595959; text-decoration: none;}
A:hover { color:#595959; text-decoration: none; }
A:active { color: #595959; text-decoration: none; }
A:link { color: #595959; text-decoration: none; }
</style>
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#DEDBDE">
<tr>
<?
for($i=0;$i<count($fieldName);$i++)
{
echo "<td align='center' bgcolor='#F7F3F7' height='25'><b>".$fieldName[$i]."</b></td>";
}
?>
</tr>
<?
$sql = str_replace("\\", "", "$sql");
$re = $DB->setResult($sql);
$j = 0;
for($i=0;$i<$re[cnt];$i++)
{
$row = mysql_fetch_array($re[result]);
if($j == 0) echo "<TR>";
for($k=0;$k<count($fieldValue);$k++) { echo "<td align='center' bgcolor='#FFFFFF'> ".$row[$fieldValue[$k]]."</td>"; }
if($j == count($fieldName)) { echo "</tr>"; $j = 0; }
}
?>
</tr>
</table>
</body>
</html>
[참고] php에서 post방식으로 업로드를 진행 할 경우 post_max_size 의 크기를 확인 해
봐야 한다. upload_max_filesize 크기를 100로 하더라도 post방식으로 업로드를 하게 되면
post_file_size 도 100로 설정을 해야 한다.
일반적으로 post_file_size 는 8M로 설정 되어 있다.
<?
//indexer.php 주소 체계
class indexer{
//config
///##아이디 길이 설정##///
var $MaxLenId = 12;
var $MinLenId = 6;
///###################///
var $post;
var $tb;
var $id;
var $url;
var $_url;
var $errType; //추후 Exception타입을 결정하기 위한 변수 나중에 확장성을 위해서 선언
///##모드 변수 action을 결정하는 변수 ##///
var $mode;
//mode type = nomal,post,tb,errType
//nomal = domain/아이디 일 경우
//post = domain/아이디/글번호
//tb = domain/tb/아이디/글번호
//errtype = 아이디가 존재 하지 않거나 주소 체계가 잘못 된 경우
function indexer($_url){
$this->_url = $_url;
$str = explode("/",$this->_url);
$this->url = $str[1];
}// end indexer
function idChk($id){
$strCount=0; //문자의 개수
$NumCount=0; //숫자의 개수
if($this->MinLenId<=strlen($id) && strlen($id)<=$this->MaxLenId){
for($cnt=0; $cnt<strlen($id); $cnt++){
//문자일 경우
if(is_numeric($id[$cnt])==1){
$numCount++;
}
else{
$strCount++;
}
}
// echo $numCount ." numCount <br>";
// echo $strCount ." strCount <br>";
//합당한 아이디 인지 검사
if($numCount==6 && $strCount==0){
$this->mode="errType";
}
else{
$result="ok";
}//end if
}else{
$this->mode ="errType";
}//end if
return $result;
}//end idChk
function IsId(){
$numCount=0;
$strCount=0;
// 아이디 인지 트랙백 주소인지 체크
//트랙백 주소인경우
$str = explode("/",$this->_url);
$ctr=0;
if($this->url == "tb"){
if(indexer::idChk($str[2])=="ok" && is_numeric($str[3])==1){
$this->post = $str[3];
$this->id = $str[2];
$this->mode = "tb";
}
else{
$this->mode = "errType";
}
}
//아이디인 경우
else{
if(indexer::idChk($this->url)=="ok" && is_numeric($str[2])==1){
$this->post=$str[2];
$this->id = $str[1];
$this->mode = "post";
}
else if(indexer::idChk($this->url)=="ok"){
$this->id =$str[1];
$this->mode="nomal";
}
}//end if
}//end Isid
//페이지 경로 설정
function go(){
$redirect;
switch($this->mode){
case "nomal":
$redirect="blog_index.html?id=".$this->id;
header("Location: http://".$_SERVER['HTTP_HOST']
. dirname($_SERVER['PHP_SELF'])
. "/" . $redirect);
break;
case "post":
$redirect="blog_index.html?id=".$this->id."&post=".$this->post;
header("Location: http://".$_SERVER['HTTP_HOST']
. dirname($_SERVER['PHP_SELF'])
. "/" . $redirect);
break;
case "tb":
$redirect="Module/TrackBack/TrackBack.html?id=".$this->id."&post=".$this->post;
//트랙백 개발시 트랙백 모듈에 전송해야 함.
header("Location: http://".$_SERVER['HTTP_HOST']
. dirname($_SERVER['PHP_SELF'])
. "/" . $redirect);
break;
default:
$redirect="Module/NotFound/NotFound.html";
header("Location: http://".$_SERVER['HTTP_HOST']
. dirname($_SERVER['PHP_SELF'])
. "/" . $redirect);
break;
}
}//end go
//###### 클래스 생성후 Load메소드 호출 ###########//
function Load(){
indexer::IsId();
indexer::go();
}//end Load
//###### 클래스 생성후 Load메소드 호출 ###########//
} //end class
?>
<?php
session_start();
include_once 'SHJUploader.inc.php.zend';
SHJUploaderClearFiles();
?>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script src="http://activex.off.co.kr/SHJUploader.js"></script>
</head>
<body bgcolor="#eeeeee">
<div id="message"></div>
<form method="post" enctype="multipart/form-data" action="post.php" target="_bg" onsubmit="return SHJUploaderSubmit(this);">
<input type="submit" value="올리기" /><br />
<input type="text" name="subject" value="test" /><br />
<input type="checkbox" name="check" value="1" /><br />
<input type="radio" name="radio" value="1" />
<input type="radio" name="radio" value="2" checked="" />
<textarea name="contents">test
test</textarea><br />
<div style="border-width:1px; border-style:solid; background-color:#cccccc; width:500px;">
<script>
SHJUploader('files', 500, 150, '<!--param name="DropImage" value="/drop.png" /--><param name="EraseImage" value="/del.png" /><param name="EraseOnImage" value="/del_on.png" />');
</script>
</div>
</form>
<div style="background-color:#eedddd;">
<a href="SHJUploader.inc.php.zend">SHJUploader.inc.php.zend</a>
</div>
<div style="background-color:#ddddee;">
<?php
highlight_file(__FILE__);
?>
</div>
<div style="background-color:#ddeedd;">
<?php
highlight_file('post.php');
?>
</div>
<iframe name="_bg" style="display:none;"></iframe>
</body>
</html>
$this_year=date(Y); // 년
$this_month = date(n); //월
$this_day = date(d); //일
$today =$this_year.conv_num($this_month).conv_num($this_day);
$timestamp = mktime(0,0,0,$this_month,$this_day,$this_year);
$t_day=date(w,$timestamp);
//오늘 날짜를 기준으로 일주일 날짜 지정
$st_time =$t_day*60*60*24;
$ed_time =(6-$t_day)*60*60*24;
$st_year = date(Y,$timestamp-$st_time);
$st_month = conv_num(date(n,$timestamp-$st_time));
$st_day = date(d,$timestamp-$st_time);
$ed_year = date(Y,$timestamp+$ed_time);
$ed_month = conv_num(date(n,$timestamp+$ed_time));
$ed_day = date(d,$timestamp+$ed_time);
//시작 일
$week_day_start=$st_year.$st_month.$st_day;
//종료일
$week_day_end=$ed_year.$ed_month.$ed_day;
function conv_num($num){
if($num<10){
$num="0".$num;
}
return $num;
}