웹마스터 팁

cal.JPG
<!--
        // 달력
        // 작성자 : 최문혁
        // 작성일 : 2005-9-5
-->
<style>
        a:link{color:white;text-decoration:none;}
        a:visited{color:white;text-decoration:none;}
        a:active{color:white;text-decoration:none;}
        a:hover{color:#ff0000;text-decoration:underline}
</style>

<?php
        
        //$curM = 2;
        //처음 시작할때.. 그러니까 월을 선택하지 않았을때...
        if ($curM =="")
        {
                //오늘을 기준으로 연도와 달을 찾는다.
                $tmpDate = getdate();
                $curY = $tmpDate[year];
                $curM = $tmpDate[mon];
                $curD = $tmpDate[mday];
        }
        
        //유닉스 타임스탬프 형식으로 현재달의 1일을 찾아 둔다.
        $preM = $curM - 1;
        $nextM = $curM + 1;
        $preY = $curY;
        $nextY = $curY;
        
        if ($curM==1)
        {
                $preM = 12;
                $preY = $curY - 1;
        }
        elseif($curM==12)
        {
                $nextM = 1;
                $nextY = $curY + 1;
        }
                
        $preDate = mktime(0,0,0,$preM, 1,$preY);
        $curDate = mktime(0,0,0,$curM, 1,$curY);
        $nextDate = mktime(0,0,0,$nextM, 1,$nextY);

        $preMaxday = date(t,$preDate);
        $curMaxday = date(t,$curDate);
        $nextMaxday = date(t,$nextDate);

        $preFw = date(w,$preDate);        //요일을 숫자로 나타낸것(0=일요일,1=월요일)
        $curFw = date(w,$curDate);        //요일을 숫자로 나타낸것(0=일요일,1=월요일)
        $nextFw = date(w,$nextDate);        //요일을 숫자로 나타낸것(0=일요일,1=월요일)

        $preJu = floor(($preMaxday+$preFw)/7)+1 ;         //
        $curJu =floor(($curMaxday+$curFw)/7)+2 ;         //
        $nextJu = floor(($nextMaxday+$nextFw)/7)+1 ;         //
        $yoil = array('','SUN','MON','TUE','WEN','THR','FRI','SAT');
        $month = array('','January','February','May','April','March','June'+ ','July','August','September','October','November','December');
        
        //양옆 미니달력 만들기 함수
        function mk_mCal($y,$m,$ju,$fw,$maxday)
        {
                GLOBAL $preM, $preY, $preJu, $preFw, $preMaxday, $nextJu, $nextFw, $nextMaxday, $yoil, $month;
                $cur=0;
                echo "<center><font face=굴림 size=2 color='#3399FF'>".$y."-".$m."</font></center><table  cellspacing=2 cellpadding=0 height=150>";
                        for($row = 0;$row<=$ju;$row++)
                        {
                                echo "<tr align=center>";
                                for($col = 1;$col<=7;$col++)
                                {
                                        echo "<td><font face=굴림 size=2 color='#3399FF'>";
                                        if ($row==0)
                                        {
                                                echo "<u>".$yoil[$col]."</u>";
                                        }
                                        else
                                        {
                                                $cur++;
                                                if (($cur <= $fw) || ($cur-$fw>$maxday)==true)
                                                {
                                                        echo " ";
                                                }
                                                else
                                                {
                                                        if ($cur-$preFw<10)
                                                        {
                                                                echo "0";
                                                                echo $cur-$fw;
                                                        }
                                                        else
                                                        {
                                                                echo $cur-$fw;
                                                        }//헉
                                                }//헉
                                        }//헉
                                }//헉
                        }//헉
                echo "</table>";
        }

        //좌측,우측에 작은 달력.
        echo "<table width=100% ><tr><td>";
        //여기 전달 달력
        mk_mCal($preY,$preM,$preJu, $preFw, $preMaxday);
        echo "</td><td width=70% align=center>";
        //여기 현재 달
        echo "<b>".$curY."   <font size=10>".$curM."</font>  ".$month[$curM]."</font></b>";
        echo "</td><td>";
        //여기 다음달 달력
        mk_mCal($nextY,$nextM,$nextJu,$nextFw,$nextMaxday);
        echo "</td></tr></table>";


        //메인테이블 시작
        $cur = 0;
        echo "<table border=0 width=100% height=70% cellspacing=1 cellpadding=0 bgcolor='#6699CC'>";
        for($row = 0;$row<=$curJu;$row++)
        {
                //row에 대한 첫번째 루프라면 현재달과 전달 다음달을 표시하기위한 칸
                if ($row==0)
                {
                        echo "<tr height=10><td colspan=3><font size=2 color=white> <a href=$PHP_SELF?curY=$preY&curM=$preM&curD=$curD>이전달</a>  ";
                        echo "<a href=$PHP_SELF>오늘</a>  <a href=$PHP_SELF?curY=$nextY&curM=$nextM&curD=$curD>다음달</a></font></td></tr>";
                }
                else
                {                        
                        echo "<tr bgcolor='#FFFFFF'>";         //한줄 그린다.
                        
                        for($col = 1;$col<=7;$col++)        //한주가 7일이니깐 7번 돈다.
                        {                                
                                if($row==1)         //요일을 넣기위한 칸^^
                                {
                                        echo "<td height=30 width=14.2857% align=center><font face='arial black'>";
                                        echo "<font color=black>";
                                        if ($col==1) echo "<font color=red>";
                                        if ($col==7) echo "<font color=blue>";
                                        echo "<h4>$yoil[$col]</h></font><br>";
                                }else{                                        
                                        $cur++;        //공백까지 포함해서 1씩 증가하는데, 일자를 출력할땐 공백의 갯수 뺀다.
                                        if (($cur<=$curFw) || ($cur > ($curMaxday+$curFw)) == true)
                                        {                                                
                                                echo "<td valign=top> ";        
                                        }else{
                                                
                                                if (($cur-$curFw)==$curD)//오늘일자 하이라이트.
                                                {
                                                        echo "<td valign=top bgcolor=#6699CC>";        //한칸 그리고
                                                }else{
                                                        echo "<td valign=top>";        //한칸 그리고
                                                }
                                                
                                                //일자 표시 부분... 각각 테이블이 들어간다. 디자인을 위해서..
                                                echo "<table border=0 height=10 width=100% height=100% bgcolor=EEEEEE cellspacing=0 cellpadding=0><tr><td align=right>";
                                                echo "<font color=black>";
                                                if ($col==1) echo "<font color=red>";
                                                if ($col==7) echo "<font color=blue>";
                                                echo $cur-$curFw;                                        
                                                echo "</font> </td></tr></table>";
                                        }
                                }
                                echo "</td>";
                        }
                        echo "</tr>";
                }
        }

        echo "</table>";

?>
제목 글쓴이 날짜
새로운 뉴스티커 [1] 아렌티 2006.04.25
[이 컨트롤을 활성화하고..] 해결하기 [2] 모그422 2006.04.29
플래시 영역에 박스가 생기는것 [4] 로그인 2006.05.03
웹FTP 적용하기 - 꽁수 [4] whenji 2006.05.02
홈페이지 하단 링크주소 없에는 소스 2 [4] 인터니즈 2006.04.27
홈페이지 하단 링크주소 없에는 소스 [6] 인테리어뱅크 2006.04.10
내 홈페이지에 유명사이트 검색엔진을 달자...(네이버,다음,야후 등등) [3] 트래비스 2006.05.10
익스플러로 플래시 영역 박스 생김과 이 컨트롤을 활성화.. [14] 도토리맘 2006.05.15
[소스] 개발자,디자이너 전용 통합검색 스크립트 [1] 김성대 2006.05.19
부모창과 함께 닫히는 팝업창(IE, FF) 행복한고니 2006.07.06
깔끔한 이미지 펼침박스 [2] ▩윤미 2006.07.11
환상적인 이미지 갤러리 (4차원세계에 빠져보세요) [5] ▩윤미 2006.07.11
상단 타이틀바 흐르는 텍스트 왜,그러지 2006.07.14
위에서 아래로 좌에서 우로... [1] 왜,그러지 2006.07.14
날라서 붙는 텍스트 [1] 왜,그러지 2006.07.17
자바스크립트로 만든 테트리스 일명 자트리스 ^^;; [12] beMax 2006.07.27
배경색을 마우스로 크릭하여 지정하여 준다. 왜,그러지 2006.07.27
로또 번호 추출기 [3] 왜,그러지 2006.07.27
텍스트 선택하기 행복한고니 2006.09.06
로또 번호 생성기 허접..ㅋㅋ [5] 삐따기 2006.10.04