묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
다이어리 php 소스 수정좀 부탁합니다..
2002.02.22 01:24
제가 해보려고 노력은 마니 했는데... 어렵네여..
php를 전혀 할줄 몰라서여...
아래는 소스 입니다.
======================================================================
<?
if(!$id) {
echo "<font style='font-size:9pt;'><b>$PHP_SELF?id=</b>";
$dir=opendir("./");
while ($list = readdir($dir)){
if(is_dir($list)){
if(($list!=".") && ($list!="..") && ($list!="icon") && ($list!="theme")){
echo "
<a href=$PHP_SELF?id=$list>$list</a>";}
}
}
closedir($dir);
exit ;
}
if($id=="icon" || $id=="theme" || !is_dir($id)){
echo " <b><font style='font-size:9pt;'>"icon","theme" 디렉토리를 제외한 디렉토리를 생성해주세요 </font></b> ";
exit ;
}
if (!is_dir("$id/data")) {
mkdir("$id/data",0777);
chmod("$id/data",0777);
}
if (!is_dir("$id/reply")) {
mkdir("$id/reply",0777);
chmod("$id/reply",0777);
}
if (file_exists("$id/config.cgi")) {
$config = file("$id/config.cgi");
$cfg = explode("|",$config[0]);
//$total_count=$cfg[0];
$password=$cfg[1];
//$list_nums=$cfg[2];
$back_image=$cfg[3];
$back_color=$cfg[4];
$back_position=$cfg[5];
$back_repeat=$cfg[6];
$icon=$cfg[7];
$align=$cfg[8];
$text_color=$cfg[9];
$link_color=$cfg[10];
$a_link_color=$cfg[11];
$v_link_color=$cfg[12];
$h_link_color=$cfg[13];
$bordercolordark=$cfg[14];
$bordercolorlight=$cfg[15];
$form_color=$cfg[16];
$form_back_color=$cfg[17];
$form_line_color=$cfg[18];
$today_color=$cfg[19];
$today_out_color=$cfg[20];
$today_over_color=$cfg[21];
$sun_color=$cfg[22];
$sun_bgcolor=$cfg[23];
$sun_out_color=$cfg[24];
$sun_over_color=$cfg[25];
$sat_color=$cfg[26];
$sat_bgcolor=$cfg[27];
$sat_out_color=$cfg[28];
$sat_over_color=$cfg[29];
$else_color=$cfg[30];
$else_bgcolor=$cfg[31];
$else_out_color=$cfg[32];
$else_over_color=$cfg[33];
$browser_title=$cfg[34];
$max_title=$cfg[35];
$max_comment=$cfg[36];
$max_name=$cfg[37];
$max_reply=$cfg[38];
$max_long_reply=$cfg[39];
$max_cut_title=$cfg[40];
$table_width=$cfg[41];
}
else {
//$total_count="0";
$password="1234";
//$list_nums="3";
$back_image="";
$back_color="#ffffff";
$back_position="right bottom";
$back_repeat="no-repeat";
$icon="black";
$align="center";
$text_color="#787878";
$link_color="#787878";
$a_link_color="#787878";
$v_link_color="#787878";
$h_link_color="#787878";
$bordercolordark="#ffffff";
$bordercolorlight="#787878";
$form_color="#787878";
$form_back_color="#ffffff";
$form_line_color="#787878";
$today_color="green";
$today_out_color="";
$today_over_color="";
$sun_color="red";
$sun_bgcolor="";
$sun_out_color="";
$sun_over_color="";
$sat_color="blue";
$sat_bgcolor="";
$sat_out_color="";
$sat_over_color="";
$else_color="black";
$else_bgcolor="";
$else_out_color="";
$else_over_color="";
$browser_title=":: Diary ::";
$max_title="30";
$max_comment="7000";
$max_name="8";
$max_reply="80";
$max_long_reply="5000";
$max_cut_title="8";
$table_width="630";
$password=crypt($password);
$new_cfg="|$password||$back_image|$back_color|$back_position|$back_repeat|$icon|$align|$text_color|$link_color|$a_link_color|$v_link_color|$h_link_color|$bordercolordark|$bordercolorlight|$form_color|$form_back_color|$form_line_color|$today_color|$today_out_color|$today_over_color|$sun_color|$sun_bgcolor|$sun_out_color|$sun_over_color|$sat_color|$sat_bgcolor|$sat_out_color|$sat_over_color|$else_color|$else_bgcolor|$else_out_color|$else_over_color|$browser_title|$max_title|$max_comment|$max_name|$max_reply|$max_long_reply|$max_cut_title|$table_width|";
$fp=fopen("$id/config.cgi","w");
flock($fp,2);
fwrite ($fp,$new_cfg);
fclose($fp);
}
//$table_width=630;//테이블 넓이
$td_width=intval($table_width / 1);
//=====================================================함수=====================================================//
//한달의 총 날짜 계산 함수
function Month_Day($i_month,$i_year){
$day=1;
while(checkdate($i_month,$day,$i_year)){
$day++;
}
$day--;
return $day;
}
//========================문자열자르기 함수==================//
function cut_string($string, $length) {
$count=2;
if(strlen($string) > $length) {
for ( $i=0; $i < $length; $i++) {
if( ord(substr($string, $i, 1)) > 127 ) {
$count+=2;
}
else { $count++;}
if( $count >= $length )
break;
}
$string = substr($string, 0, $count);
return $string."...";
}
else {
return $string;
}
}
//========================문자열자르기 함수 끝==================//
//=====================================================함수 끝=====================================================//
//오늘 날짜를 년월일별로 구하기
$today=date("Ymd");
$today_year=date("Y");
$today_month=date("m");
$today_day=date("d");
//month와 year의 변수값이 지정되어있지 않으면 오늘로 지정.
if(!$month)$month=(int)$today_month;
if(!$year)$year=$today_year;
//선택한 월의 총 일수를 구함.
$total_day=Month_Day($month,$year);
//선택한 월의 1일의 요일을 구함. 일요일은 0.
$first=date(w,mktime(0,0,0,$month,1,$year));
//윤년 확인
if($month==2){
if(!($year%4))$total_day++;
if(!($year%100))$total_day--;
if(!($year%400))$total_day++;
}
//=====================================================출력문=====================================================//
echo"
<html>
<head>
<title>$browser_title</title>
<STYLE TYPE='TEXT/CSS'>
<!--
body,table,tr,td,select,div,form,center,p,br {font-size:9pt;color:$text_color;}
.ver8 {font-family:Tahoma;font-size:8pt;}
.ver9 {font-family:Tahoma;font-size:9pt;}
.ver10 {font-family:Tahoma;font-size:10pt;}
a:link {color:$link_color; text-decoration: none;}
a:active {color:$a_link_color; text-decoration: none;}
a:visited {color:$v_link_color; text-decoration: none;}
a:hover {color:$h_link_color; text-decoration: underline;}
-->
</STYLE>
</head>";
if ($back_image!=""){//배경미미지
echo "
<body background=$back_image style='background-attachment : fixed;background-position : $back_position;background-repeat : $back_repeat;background-color :$back_color;'>";
}
else {
echo "
<body bgcolor='$back_color'>";
}
if (file_exists("$id/header.htm")){//===html헤더
include($id.'/header.htm');
}
echo "
<div align='$align'>
<table cellspacing=0 cellpadding=0 border=0>
<tr height=60>n";
//===========날짜를 테이블에 표시=================//
for($day=1;$day<=$total_day;$day++){
$count++;
//오늘 표시
if($day==$today_day && $month==$today_month && $year==$today_year){
$m_out_color=$today_out_color;
$m_over_color=$today_over_color;
$day_color=$today_color;
}
else {//오늘이 아니면...
if ($count==1) {//일요일
$m_out_color=$sun_out_color;
$m_over_color=$sun_over_color;
$day_color=$sun_color;
}
elseif ($count==7) {//토요일
$m_out_color=$sat_out_color;
$m_over_color=$sat_over_color;
$day_color=$sat_color;
}
else {//평일
$m_out_color=$else_out_color;
$m_over_color=$else_over_color;
$day_color=$else_color;
}
}//오늘이 아니면...끝
echo "
<tr><td width=200 valign=top bgcolor='$m_out_color' height=60 onMouseOut=this.style.backgroundColor='' onMouseOver=this.style.backgroundColor='$m_over_color'>
<a href='#' onClick=window.open('./diary_action.php3?id=$id&year2=$year&month2=$month&day2=$day','','scrollbars=no,width=400,height=300')><font class=ver9 color='$day_color'><b>$day</b></font></a><br>";
if(file_exists("$id/data/$year-$month-$day.cgi")){
$line = file("$id/data/$year-$month-$day.cgi");
$view = explode("|",$line[0]);
$view[4]=strip_tags($view[4]);
$cut_title=cut_string($view[4],$max_cut_title);
echo "<a href='#' onClick=window.open('./diary_action.php3?id=$id&mode=view&year=$year&month=$month&day=$day','','scrollbars=yes,width=420,height=320')><font class=ver9 color='$day_color' title='$view[4] (Hit : $view[0])'>";
if($view[8]=="yes"){echo "<img src=./icon/$icon/lock.gif border=0 align=absmiddle>";}
echo " $cut_title</font>";
if($view[9]=="yes"){echo "<img src=./icon/$icon/point.gif border=0 align=absmiddle>";}
}
if(file_exists("$id/reply/$year-$month-$day.cgi")){
$temp = file("$id/reply/$year-$month-$day.cgi");
$total_reply=count($temp);
if($total_reply>0){echo "<br><img src=./icon/$icon/head.gif border=0 align=absmiddle><font class=ver8 color='$day_color'> Re : $total_reply</font>";}
echo "</a><br>";}
echo "</td></tr>n";
}
echo "
</table>
</table>
</div>";
if (file_exists("$id/footer.htm")){//===Html Footer삽입
include($id.'/footer.htm');
}
?>
</body>
</html>
======================================================================
이 소스의 보기는...
http://mnara.nameip.net:8080/diary/diary.php3?id=m
이거구여...
제가 원하는건...
오늘 날짜로부터 3일까지만 출력이 되게 하구 싶거든여..
오늘이 22일이니까 22일 23일 24일까지 출력이 되게 하구 싶어여...
그리구 날짜 옆에 금요일 토요일 일요일 이런식으로 요일두 나오게 하구싶구여..
php 할줄 아시는분들은 수정좀 부탁합니다.
php를 전혀 할줄 몰라서여...
아래는 소스 입니다.
======================================================================
<?
if(!$id) {
echo "<font style='font-size:9pt;'><b>$PHP_SELF?id=</b>";
$dir=opendir("./");
while ($list = readdir($dir)){
if(is_dir($list)){
if(($list!=".") && ($list!="..") && ($list!="icon") && ($list!="theme")){
echo "
<a href=$PHP_SELF?id=$list>$list</a>";}
}
}
closedir($dir);
exit ;
}
if($id=="icon" || $id=="theme" || !is_dir($id)){
echo " <b><font style='font-size:9pt;'>"icon","theme" 디렉토리를 제외한 디렉토리를 생성해주세요 </font></b> ";
exit ;
}
if (!is_dir("$id/data")) {
mkdir("$id/data",0777);
chmod("$id/data",0777);
}
if (!is_dir("$id/reply")) {
mkdir("$id/reply",0777);
chmod("$id/reply",0777);
}
if (file_exists("$id/config.cgi")) {
$config = file("$id/config.cgi");
$cfg = explode("|",$config[0]);
//$total_count=$cfg[0];
$password=$cfg[1];
//$list_nums=$cfg[2];
$back_image=$cfg[3];
$back_color=$cfg[4];
$back_position=$cfg[5];
$back_repeat=$cfg[6];
$icon=$cfg[7];
$align=$cfg[8];
$text_color=$cfg[9];
$link_color=$cfg[10];
$a_link_color=$cfg[11];
$v_link_color=$cfg[12];
$h_link_color=$cfg[13];
$bordercolordark=$cfg[14];
$bordercolorlight=$cfg[15];
$form_color=$cfg[16];
$form_back_color=$cfg[17];
$form_line_color=$cfg[18];
$today_color=$cfg[19];
$today_out_color=$cfg[20];
$today_over_color=$cfg[21];
$sun_color=$cfg[22];
$sun_bgcolor=$cfg[23];
$sun_out_color=$cfg[24];
$sun_over_color=$cfg[25];
$sat_color=$cfg[26];
$sat_bgcolor=$cfg[27];
$sat_out_color=$cfg[28];
$sat_over_color=$cfg[29];
$else_color=$cfg[30];
$else_bgcolor=$cfg[31];
$else_out_color=$cfg[32];
$else_over_color=$cfg[33];
$browser_title=$cfg[34];
$max_title=$cfg[35];
$max_comment=$cfg[36];
$max_name=$cfg[37];
$max_reply=$cfg[38];
$max_long_reply=$cfg[39];
$max_cut_title=$cfg[40];
$table_width=$cfg[41];
}
else {
//$total_count="0";
$password="1234";
//$list_nums="3";
$back_image="";
$back_color="#ffffff";
$back_position="right bottom";
$back_repeat="no-repeat";
$icon="black";
$align="center";
$text_color="#787878";
$link_color="#787878";
$a_link_color="#787878";
$v_link_color="#787878";
$h_link_color="#787878";
$bordercolordark="#ffffff";
$bordercolorlight="#787878";
$form_color="#787878";
$form_back_color="#ffffff";
$form_line_color="#787878";
$today_color="green";
$today_out_color="";
$today_over_color="";
$sun_color="red";
$sun_bgcolor="";
$sun_out_color="";
$sun_over_color="";
$sat_color="blue";
$sat_bgcolor="";
$sat_out_color="";
$sat_over_color="";
$else_color="black";
$else_bgcolor="";
$else_out_color="";
$else_over_color="";
$browser_title=":: Diary ::";
$max_title="30";
$max_comment="7000";
$max_name="8";
$max_reply="80";
$max_long_reply="5000";
$max_cut_title="8";
$table_width="630";
$password=crypt($password);
$new_cfg="|$password||$back_image|$back_color|$back_position|$back_repeat|$icon|$align|$text_color|$link_color|$a_link_color|$v_link_color|$h_link_color|$bordercolordark|$bordercolorlight|$form_color|$form_back_color|$form_line_color|$today_color|$today_out_color|$today_over_color|$sun_color|$sun_bgcolor|$sun_out_color|$sun_over_color|$sat_color|$sat_bgcolor|$sat_out_color|$sat_over_color|$else_color|$else_bgcolor|$else_out_color|$else_over_color|$browser_title|$max_title|$max_comment|$max_name|$max_reply|$max_long_reply|$max_cut_title|$table_width|";
$fp=fopen("$id/config.cgi","w");
flock($fp,2);
fwrite ($fp,$new_cfg);
fclose($fp);
}
//$table_width=630;//테이블 넓이
$td_width=intval($table_width / 1);
//=====================================================함수=====================================================//
//한달의 총 날짜 계산 함수
function Month_Day($i_month,$i_year){
$day=1;
while(checkdate($i_month,$day,$i_year)){
$day++;
}
$day--;
return $day;
}
//========================문자열자르기 함수==================//
function cut_string($string, $length) {
$count=2;
if(strlen($string) > $length) {
for ( $i=0; $i < $length; $i++) {
if( ord(substr($string, $i, 1)) > 127 ) {
$count+=2;
}
else { $count++;}
if( $count >= $length )
break;
}
$string = substr($string, 0, $count);
return $string."...";
}
else {
return $string;
}
}
//========================문자열자르기 함수 끝==================//
//=====================================================함수 끝=====================================================//
//오늘 날짜를 년월일별로 구하기
$today=date("Ymd");
$today_year=date("Y");
$today_month=date("m");
$today_day=date("d");
//month와 year의 변수값이 지정되어있지 않으면 오늘로 지정.
if(!$month)$month=(int)$today_month;
if(!$year)$year=$today_year;
//선택한 월의 총 일수를 구함.
$total_day=Month_Day($month,$year);
//선택한 월의 1일의 요일을 구함. 일요일은 0.
$first=date(w,mktime(0,0,0,$month,1,$year));
//윤년 확인
if($month==2){
if(!($year%4))$total_day++;
if(!($year%100))$total_day--;
if(!($year%400))$total_day++;
}
//=====================================================출력문=====================================================//
echo"
<html>
<head>
<title>$browser_title</title>
<STYLE TYPE='TEXT/CSS'>
<!--
body,table,tr,td,select,div,form,center,p,br {font-size:9pt;color:$text_color;}
.ver8 {font-family:Tahoma;font-size:8pt;}
.ver9 {font-family:Tahoma;font-size:9pt;}
.ver10 {font-family:Tahoma;font-size:10pt;}
a:link {color:$link_color; text-decoration: none;}
a:active {color:$a_link_color; text-decoration: none;}
a:visited {color:$v_link_color; text-decoration: none;}
a:hover {color:$h_link_color; text-decoration: underline;}
-->
</STYLE>
</head>";
if ($back_image!=""){//배경미미지
echo "
<body background=$back_image style='background-attachment : fixed;background-position : $back_position;background-repeat : $back_repeat;background-color :$back_color;'>";
}
else {
echo "
<body bgcolor='$back_color'>";
}
if (file_exists("$id/header.htm")){//===html헤더
include($id.'/header.htm');
}
echo "
<div align='$align'>
<table cellspacing=0 cellpadding=0 border=0>
<tr height=60>n";
//===========날짜를 테이블에 표시=================//
for($day=1;$day<=$total_day;$day++){
$count++;
//오늘 표시
if($day==$today_day && $month==$today_month && $year==$today_year){
$m_out_color=$today_out_color;
$m_over_color=$today_over_color;
$day_color=$today_color;
}
else {//오늘이 아니면...
if ($count==1) {//일요일
$m_out_color=$sun_out_color;
$m_over_color=$sun_over_color;
$day_color=$sun_color;
}
elseif ($count==7) {//토요일
$m_out_color=$sat_out_color;
$m_over_color=$sat_over_color;
$day_color=$sat_color;
}
else {//평일
$m_out_color=$else_out_color;
$m_over_color=$else_over_color;
$day_color=$else_color;
}
}//오늘이 아니면...끝
echo "
<tr><td width=200 valign=top bgcolor='$m_out_color' height=60 onMouseOut=this.style.backgroundColor='' onMouseOver=this.style.backgroundColor='$m_over_color'>
<a href='#' onClick=window.open('./diary_action.php3?id=$id&year2=$year&month2=$month&day2=$day','','scrollbars=no,width=400,height=300')><font class=ver9 color='$day_color'><b>$day</b></font></a><br>";
if(file_exists("$id/data/$year-$month-$day.cgi")){
$line = file("$id/data/$year-$month-$day.cgi");
$view = explode("|",$line[0]);
$view[4]=strip_tags($view[4]);
$cut_title=cut_string($view[4],$max_cut_title);
echo "<a href='#' onClick=window.open('./diary_action.php3?id=$id&mode=view&year=$year&month=$month&day=$day','','scrollbars=yes,width=420,height=320')><font class=ver9 color='$day_color' title='$view[4] (Hit : $view[0])'>";
if($view[8]=="yes"){echo "<img src=./icon/$icon/lock.gif border=0 align=absmiddle>";}
echo " $cut_title</font>";
if($view[9]=="yes"){echo "<img src=./icon/$icon/point.gif border=0 align=absmiddle>";}
}
if(file_exists("$id/reply/$year-$month-$day.cgi")){
$temp = file("$id/reply/$year-$month-$day.cgi");
$total_reply=count($temp);
if($total_reply>0){echo "<br><img src=./icon/$icon/head.gif border=0 align=absmiddle><font class=ver8 color='$day_color'> Re : $total_reply</font>";}
echo "</a><br>";}
echo "</td></tr>n";
}
echo "
</table>
</table>
</div>";
if (file_exists("$id/footer.htm")){//===Html Footer삽입
include($id.'/footer.htm');
}
?>
</body>
</html>
======================================================================
이 소스의 보기는...
http://mnara.nameip.net:8080/diary/diary.php3?id=m
이거구여...
제가 원하는건...
오늘 날짜로부터 3일까지만 출력이 되게 하구 싶거든여..
오늘이 22일이니까 22일 23일 24일까지 출력이 되게 하구 싶어여...
그리구 날짜 옆에 금요일 토요일 일요일 이런식으로 요일두 나오게 하구싶구여..
php 할줄 아시는분들은 수정좀 부탁합니다.