fpath = "./data/"; $this -> userfile = $this->fpath."sch"; $this -> lockfile = $this -> userfile.".lock"; $this -> self = getenv("SCRIPT_NAME"); $this -> titles[] = ""; $this -> errormessage = ""; $this -> readonly = $_ro; } //----- constructor end //----- footer function footer(){ $_now = getdate(); $_date = $_now["year"]."/".$_now["mon"]."/".$_now["mday"]; if(ereg("[?]",$this->self)) { $_act = $this->self."&";}else{$_act = $this->self."?";} $_act .= "scdate=".base64_encode("$_date"); $_actd = $_act."&sctype=".base64_encode("d"); $_actm = $_act."&sctype=".base64_encode("m"); $_actw = $_act."&sctype=".base64_encode("w"); print "\n"; print ""; print "
[今月][今週][今日]
\n"; } //----- read schedule function read($_year="",$_month=""){ $ret_code = false; $this -> errormessage = ""; if(strlen($_month) == 1) $_month = "0".$_month; $_fn = $this->userfile.$_year.$_month.".php"; unset($this->titles); if(!file_exists($_fn)){ $this -> errormessage = "ファイルが見つかりません."; return $ret_code; } $_f=file($_fn); $c=count($_f); $c--; for($i=2;$i<$c;$i++){ $_d=explode(",",$_f[$i]); $this->titles[$_d[1]][] = $_d; } $ret_code = true; return $ret_code; } //----- make calendar function makecalendar($_year,$_month){ unset($this->mcalen); if($_year=="" || $_month==""){ $this->errormessage="年月の指定がされていません"; return false; } $_sweek = date("w",mktime(0,0,0,$_month,1,$_year)); $_dc = date("t",mktime(0,0,0,$_month,1,$_year)); $c=1; for($i=0;$i<6;$i++){ for($w=0;$w<7;$w++){ if($i==0 && $w<$_sweek){ $this->mcalen[$i][$w]=""; } else { if($c>$_dc){ $this->mcalen[$i][$w]=""; $i=6; } else { $this->mcalen[$i][$w]=$c; $c++; } } } } return true; } //----- view schedule function view($_type="m",$_date="",$_num=""){ $ret_code = true; $_d=explode("/",$_date); $_year = $_d[0]; $_month = $_d[1]; $_day = $_d[2]; $_st=$_d[3]; $this -> errormessage = ""; if(ereg("[?]",$this->self)) { $_act = $this->self."&";}else{$_act = $this->self."?";} switch ($_type){ case "m"; $this->viewmonth($_year,$_month); break; case "w"; $this->viewweek($_year,$_month,$_day); break; case "d"; $this->viewday($_year,$_month,$_day,$_st); break; case "f"; $ret_code = $this->viewfull($_year,$_month,$_num); break; default; $this->errormessage="タイプ指定が間違っています."; $ret_code = false; } if($ret_code) $this->footer(); return $ret_code; } function viewmonth($_year,$_month){ if($_year=="")$_year=date("Y"); if($_month=="")$_month=date("m"); if($_year==date("Y") && $_month==date("m")) $_today = date("d"); else $_today = -1; $this->makecalendar($_year,$_month); $exists_title = $this->read($_year,$_month); if(ereg("[?]",$this->self)) { $_act = $this->self."&";}else{$_act = $this->self."?";} $_actm = $_act."sctype=".base64_encode("m")."&scdate="; $_actd = $_act."sctype=".base64_encode("d")."&scdate="; $_actf = $_act."sctype=".base64_encode("f")."&scdate=".base64_encode("$_year/$_month/1")."&scnum="; $_next = base64_encode(date("Y/m/d",mktime(0,0,0,$_month+1,1,$_year))); $_prev = base64_encode(date("Y/m/d",mktime(0,0,0,$_month-1,1,$_year))); unset($_sd); print "\n"; print "\n"; print ""; print "\n"; print ""; print ""; print "
$_year 年 $_month 月の月間スケジュール
<<前月 次月>>
"; $_y = $_year; $_m = $_month; print "年\n"; print "月\n"; print "\n"; print ""; print "
\n"; print ""; print ""; for($w=0;$w<7;$w++) print ""; print "\n"; for($i=0;$i<6;$i++){ print ""; for($w=0;$w<7;$w++){ if($this->mcalen[$i][0]=="" && $this->mcalen[$i][6]==""){ $w=7; } else { $c = $this->mcalen[$i][$w]; if($c==$_today){ print "\n"; } print "
".$this->weekstr[$w]."
".str_pad($c,2,"0",STR_PAD_LEFT); print " "; print "
"; } elseif($c != "") { print "
".str_pad($c,2,"0",STR_PAD_LEFT); print " "; print "
"; } else { print "

"; } if($exists_title && $c!=""){ if(is_array($this->titles[$c])){ print ""; foreach($this->titles[$c] as $_v){ if($_v[6] != 0) $_pub = "(秘)"; else $_pub =""; if($_v[6] != 0 && $this->readonly){;}else{ if($_v[2]=="") $s=" ☆"; else $s=">".$_v[2]."- "; $s .= ""; $s .= $this->decode($_v[4]); $s .= "$_pub
"; $_sd[] = $s; } } if(is_array($_sd)){ sort($_sd); foreach($_sd as $_v) print $_v; } unset($_sd); print "
"; } } } } print "
\n"; } function viewweek($_year,$_month,$_day){ if($_year=="")$_year=date("Y"); if($_month=="")$_month=date("m"); $d = mktime(0,0,0,$_month,$_day,$_year); $w = date("w",$d); $_day = $_day - $w; $d = mktime(0,0,0,$_month,$_day,$_year); $_year = date("Y",$d); $_month = date("m",$d); $_day = date("d",$d); $exists_title = $this->read($_year,$_month); if($_year==date("Y") && $_month==date("m")) $_today = date("d"); else $_today = -1; if(ereg("[?]",$this->self)) { $_act = $this->self."&";}else{$_act = $this->self."?";} $_actw = $_act."sctype=".base64_encode("w")."&scdate="; $_actd = $_act."sctype=".base64_encode("d")."&scdate="; $_actf = $_act."sctype=".base64_encode("f")."&scdate="; $_next = base64_encode(date("Y/m/d",mktime(0,0,0,$_month,$_day+9,$_year))); $_prev = base64_encode(date("Y/m/d",mktime(0,0,0,$_month,$_day-3,$_year))); unset($_sd); print "\n"; print "\n"; print ""; print "
".$this->nickname."$_year 年 $_month 月 $_day 日からの週間スケジュール
<<前週 次週>>
\n"; print ""; for($w=0;$w<7;$w++){ $_y = date("Y",mktime(0,0,0,$_month,$_day,$_year)); $_m = date("m",mktime(0,0,0,$_month,$_day,$_year)); $_d = date("d",mktime(0,0,0,$_month,$_day,$_year)); if($_y != $_year || $_m !=$_month){ $_year = $_y; $_month = $_m; $_day = $_d; $exists_title = $this->read($_year,$_month); if($_year==date("Y") && $_month==date("m")) $_today = date("d"); else $_today = -1; } if($_d==$_today){ print ""; print ""; print ""; print "\n"; ++$_day; } print "
"; } else { print "
"; } print "$_m/$_d (".$this->weekstr[$w].")"; print " "; print ""; if($exists_title){ $_d += 0; if(is_array($this->titles[$_d])){ foreach($this->titles[$_d] as $_v){ if($_v[6] != 0) $_pub = "(非公開)"; else $_pub =""; if($_v[6] != 0 && $this->readonly){;}else{ if($_v[2]=="") $s = " ☆"; else $s = $_v[2]." - "; $s .= $_v[3]." "; $s .= $this->decode($_v[4]); $s .= "$_pub
"; $_sd[] = $s; } } if(is_array($_sd)){ sort($_sd); foreach($_sd as $_v) print $_v; } } } unset($_sd); print "
\n"; } function viewday($_year,$_month,$_day,$_st){ if($_year=="")$_year=date("Y"); if($_month=="")$_month=date("m"); if($_day=="")$_month=date("d"); $_day += 0; //$this->makecalendar($_year,$_month); if(ereg("[?]",$this->self)) { $_act = $this->self."&";}else{$_act = $this->self."?";} $_actf = $_act."sctype=".base64_encode("f")."&scdate=".base64_encode("$_year/$_month/$_day")."&scnum="; $_actm = $_act."sctype=".base64_encode("m")."&scdate=".base64_encode("$_year/$_month/$_day"); $_actw = $_act."sctype=".base64_encode("w")."&scdate=".base64_encode("$_year/$_month/$_day"); $_actd = $_act."sctype=".base64_encode("d")."&scdate="; if($_st != "" && !$this->readonly){ $_et = $_st + 1; $_st = str_pad($_st,2,"0",STR_PAD_LEFT); $_et = str_pad($_et,2,"0",STR_PAD_LEFT); $this->writeform($_year,$_month,$_day,$_st,$_et); print "[戻る]"; print "
\n"; } else { print "\n"; print "\n"; print ""; print "
".$this->nickname."$_year 年 $_month 月 $_day 日のスケジュール
[月間カレンダー][週間カレンダー]
\n"; if($this->read($_year,$_month)){ if(is_array($this->titles[$_day])){ foreach($this->titles[$_day] as $_v){ if($_v[2] != ""){ if($_v[6] != 0) $_pub = "(非公開)"; else $_pub =""; if($_v[6] != 0 && $this->readonly){;}else{ $s = "$_v[2] - $_v[3]"; $s .= " ".$this->decode($_v[4])."$_pub
\n"; $_d[] = $s; } } } if(is_array($_d)){ sort($_d); foreach($_d as $_v) $_t[] =substr($_v,0,2); } } } print "\n"; for($i=0;$idaytime);$i++){ print ""; print ""; } print "
".str_pad($this->daytime[$i],2,"0",STR_PAD_LEFT).":00"; print " daytime[$i]).">"; if($this->daytime[$i]==$this->daytimelast) $c=23; else $c=$this->daytime[$i+1]; if(is_array($_t)){ $_flag = false; for($j=0;$j"; } else { print "
"; } print "
\n"; unset($_d); unset($_t); } } function viewfull($_year,$_month,$_num){ $ret_code = false; $this -> errormessage = ""; if(strlen($_month) == 1) $_month = "0".$_month; $_fn = $this->userfile.$_year.$_month.".php"; if(!file_exists($_fn)){ $this -> errormessage = "ファイルが見つかりません."; return $ret_code; } $_f = file($_fn); $_p = "^$_num,"; foreach($_f as $_v){ if(ereg($_p,$_v)){ $_d = explode(",",$_v); $_day = $_d[1]; $_st = $_d[2]; $_et = $_d[3]; $_title = $this->decode($_d[4]); $_mess = $this->decode($_d[5]); if($_d[6] != 0) $_pub = "(非公開)"; else $_pub =""; if($_d[6] != 0 && $this->readonly){ $this -> errormessage = "閲覧権限がありません."; return $ret_code; } if(ereg("[?]",$this->self)) { $_act = $this->self."&";}else{$_act = $this->self."?";} $_actm = $_act."sctype=".base64_encode("m")."&scdate=".base64_encode("$_year/$_month/$_day"); $_actw = $_act."sctype=".base64_encode("w")."&scdate=".base64_encode("$_year/$_month/$_day"); print "\n"; print "\n"; if($_st == "") $s = "終日"; else $s ="$_st - $_et"; print ""; if(!$this->readonly){ //----- edit button print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print ""; //----- delete button print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print ""; } else { print ""; } print ""; print "
".$this->nickname."$_year 年 $_month 月 $_day 日のスケジュール
【 $_title 】< $s >$_pub
"; print "
"; print "

$_mess\n
"; print "
[月間カレンダー][週間カレンダー]
\n"; print "
\n"; break; } } unset($_f); $ret_code=true; return $ret_code; } //----- edit schedule function edit($_pal=""){ $ret_code = false; $this -> errormessage = ""; $_year = $_pal["scyear"]; $_month = $_pal["scmonth"]; $_num = $_pal["scnum"]; if($_num=="" || $_year=="" || $_month==""){ $this -> errormessage ="パラメータが足りません."; } else { if(strlen($_month) == 1) $_month = "0".$_month; $_fn = $this->userfile.$_year.$_month.".php"; if(!file_exists($_fn)){ $this->errormessage="ファイルが見つかりません."; return $ret_code; } $_f = file($_fn); $_p = "^$_num,"; foreach($_f as $_v){ if(ereg($_p,$_v)){ $_d = explode(",",$_v); $_day = $_d[1]; if($_d[2] == ""){ $_st = ""; $_sti = ""; $_et = ""; $_eti = ""; $_whole = true; } else { $s = explode(":",$_d[2]); $_st = $s[0]; $_sti = $s[1]; $s = explode(":",$_d[3]); $_et = $s[0]; $_eti = $s[1]; $_whole = false; } $ret_code = $this->writeform($_year,$_month,$_day,$_st,$_et,$_num,$_sti,$_eti,$_d[4],$_d[5],$_d[6],$_whole); break; } } unset($_f); } if($ret_code){ if(ereg("[?]",$this->self)) { $_act = $this->self."&";}else{$_act = $this->self."?";} $_actd = $_act."sctype=".base64_encode("d")."&scdate=".base64_encode("$_year/$_month/$_day"); print "[戻る]"; } $this->footer(); return $ret_code; } //----- delete schedule function delete($_pal=""){ $ret_code = false; $this -> errormessage = ""; $_year = $_pal["scyear"]; $_month = $_pal["scmonth"]; $_num = $_pal["scnum"]; if($_num=="" || $_year=="" || $_month==""){ $this -> errormessage ="パラメータが足りません."; } else { if(strlen($_month) == 1) $_month = "0".$_month; $_fn = $this->userfile.$_year.$_month.".php"; if(!file_exists($_fn)){ $this->errormessage="ファイルが見つかりません."; return $ret_code; } //----- file lock $_lfp = fopen($this->lockfile,"w"); flock($_lfp,LOCK_EX); //----- $_f = file($_fn); $_p = "^$_num,"; for($i=0;$ilockfile); } return $ret_code; } //----- write schedure function write($_pal=""){ $ret_code = false; $this -> errormessage = ""; if(!is_array($_pal)){ $this -> errormessage ="パラメータが足りません."; } else { //----- editだったらとりあえず削除 if($_pal["scnum"] != -1) $this->delete($_pal); //----- file lock $_lfp = fopen($this->lockfile,"w"); flock($_lfp,LOCK_EX); //----- $_year = $_pal["scyear"]; $_month = $_pal["scmonth"]; if(strlen($_month) == 1) $_month = "0".$_month; $_day = $_pal["scday"]; //if(strlen($_day) == 1) $_day = "0".$_day; if($_pal["scwhole"] == "whole"){ $_st = ""; $_et = ""; } else { $_st = $_pal["scstimeh"].":".$_pal["scstimei"]; $_et = $_pal["scetimeh"].":".$_pal["scetimei"]; } $_title = $this->encode($_pal["sctitle"]); $_mess = $this->encode($_pal["scmess"]); $_pub = $_pal["scpublic"]; $_fn = $this->userfile.$_year.$_month.".php"; if(file_exists($_fn)){ $_f = file($_fn); $_c = str_replace("\n","",$_f[1]); $_c = str_replace("\r","",$_c); } else { $_f = array("0","0","*/ ?>"); $_c = 0; } ++$_c; $_f[0] = "$_c\n"; $_f[1] = "$_c,$_day,$_st,$_et,$_title,$_mess,$_pub\n"; $_fp = fopen($_fn,"w"); fwrite($_fp,"lockfile); } return $ret_code; } //function writeform($_year=date("Y"),$_month="",$_day="",$_st="",$_et=""){ function writeform($_year="",$_month="",$_day="",$_st="",$_et="",$_num=-1,$_sti="",$_eti="",$_title="",$_mess="",$_pub=0,$_whole=false){ $ret_code = false; $this -> errormessage = ""; if($_year=="")$_year=date("Y"); if($_month=="")$_month=date("m"); if($_day=="")$_day=date("d"); print "\n"; print "\n"; print "
$_year 年 $_month 月 $_day 日のスケジュール登録
\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print ""; print "\n"; $_mess = str_replace("
","\n",$this->decode($_mess)); print "\n"; print "\n"; print "
時間"; print ""; print " : "; print ""; print " 〜 "; print ""; print " : "; print ""; if($_whole) $s = "checked"; else $s = ""; print " 終日"; print "
件名(8文字まで)
詳細
"; print ""; print " 
\n"; $ret_code = true; return $ret_code; } //----- writeform end //----- 禁則処理 function decode($_val){ $_val = str_replace("%%2C",",",$_val); $_val = str_replace("\\","",$_val); $_val = str_replace("%%5C","\\",$_val); return $_val; } function encode($_val){ $_val = str_replace("<","<",$_val); $_val = str_replace(">",">",$_val); $_val = str_replace("\n","
",$_val); $_val = str_replace("\r","",$_val); $_val = str_replace(",","%%2C",$_val); $_val = str_replace("\\\\","%%5C",$_val); return $_val; } } //----- class end ?>