\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } /*------------------------------------------------------------------- プログラムデバッグ出力 引数 :$msg --------------------------------------------------------------------*/ function trace_log( $msg ) { $addstr = gethostbyaddr(getenv("REMOTE_ADDR")); $filename = $addstr."_trace.txt"; //$_COOKIE["user_id"] $timestamp = date("Y-m-d H:i.s" ); $fp = fopen( $filename, "a+" ); fputs( $fp, "\n#" .$timestamp ." ". $msg ); fclose( $fp ); return; } /*------------------------------------------------------------------- エラーログ出力 --------------------------------------------------------------------*/ function err_log( $msg ) { $addstr = gethostbyaddr(getenv("REMOTE_ADDR")); $timestamp = date("Y-m-d H:i.s" ); $fp = fopen( "error.log", "a+" ); fputs( $fp, "\n[".$addstr."]".$timestamp ." ". $msg ); fclose( $fp ); return; } /*------------------------------------------------------------------- エラーページ出力 --------------------------------------------------------------------*/ function cm_err_page($pmsg){ // err_log($pmsg); include getenv("DOCUMENT_ROOT")."/ircm_getenv.inc"; // include $IRCM_BASE_DIR."/include/header.inc"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
"; echo ""; echo "

"; echo "

"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
エラー"; echo "
$pmsg


[前の画面に戻る]
"; echo "
"; echo "\n"; echo "\n"; } /*------------------------------------------------------------------- ファイル削除 --------------------------------------------------------------------*/ function cm_file_kill($pfname){ if ( file_exists($pfname) && is_file($pfname) ){ return unlink($pfname); } return true;//?? } /*------------------------------------------------------------------- ファイル保存 --------------------------------------------------------------------*/ function cm_uploaded_file($ftmp, $fup){ $uploadfile = $fup; if (is_uploaded_file($ftmp)){ if (move_uploaded_file($ftmp, $uploadfile)){ return true; } } return false; } /*------------------------------------------------------------------- エラーページ出力 --------------------------------------------------------------------*/ function cm_err_login(){ global $BASE_URL; include getenv("DOCUMENT_ROOT")."/ircm_getenv.inc"; include $IRCM_BASE_DIR."php/include/furusato_env.inc"; // include $IRCM_BASE_DIR."include/header.inc"; echo "
\n"; echo "\n"; echo "\n"; echo "
\n"; echo "
\n"; echo "\n"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
ログインエラー
ログインされていません。下記よりログインしてください。
\n"; echo "
\n"; echo "
\n"; echo "[ログイン画面]\n"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; exit(); } // $val : $xxx["name1"] :値の配列 /*------------------------------------------------------------------- エラーページ出力(appli04.php) --------------------------------------------------------------------*/ function cm_err_nyuukai(){ global $BASE_URL; include getenv("DOCUMENT_ROOT")."/ircm_getenv.inc"; include $IRCM_BASE_DIR."php/include/furusato_env.inc"; // include $IRCM_BASE_DIR."include/header.inc"; echo "
\n"; echo "\n"; echo "\n"; echo "
\n"; echo "
\n"; echo "\n"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
エラー
お客様情報に不備があります。下記フォームより入会手続きを行ってください。
\n"; echo "
\n"; echo "
\n"; echo "[入会申し込みフォーム]
\n"; echo "
\n"; echo "\n"; echo "\n"; exit(); } Function buil_tmpsub( $file, $val ){ $fp = fopen($file,"rb"); if($fp==false){ return ""; // @@@ 20070530 } $all = fread($fp,filesize($file)); if($all == false){ fclose($fp); return ""; // @@@ 20070530 } // $code = build_atag($all); $code = build_val($all, $val); fclose($fp); // trace_log($code); return $code; } /*---------------------------------------------------- 文章中にAタグ指定を探し <A〜>に書換え -----------------------------------------------------*/ Function build_atag( $str ){ #translate \r\n to \n $str=str_replace("\r\n","\n",$str); $kuri=array(); $str2=$str; $acc=1; # Aタグ指定の {@ }を探す while(preg_match('/\{@ ([^\}]+)\}/',$str2,$match)){ $m=$match[1]; $ar=split(":",$m); // 分割 $str3 = ""; $str3 .= $ar[1].""; //echo "$m >> $str3
"; $str2 = str_replace("{@ $m}",$str3, $str2); } return $str2; } /*---------------------------------------------------------- 文章中に{val xxx}#を探し 対応変数に置き換え?? ------------------------------------------------------------*/ Function build_val( $str, $val ){ $kuri=array(); $str2=$str; $acc=1; # interpretation of #〜# while(preg_match('/\{val ([^\}]+)\}/',$str2,$match)){ $m=$match[1]; // echo $m."->". $val[$m]."
"; $ar=split("/",$m); $ind=""; $rui=array(); $str2=str_replace("{val $m}",$val[$m],$str2); } return $str2; } /*------------------------------------------------- 指定ディレクトリ下の全ファイル削除 $expfs : array 削除対象外 --------------------------------------------------*/ function rm_dirfile($dirname, $expfs){ if(($handle = opendir($dirname))) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if($expfs && in_array($file, $expfs)){ // 削除除外指定 }else{ /* ファイルの削除 */ $sts0 = unlink($dirname."/".$file); if(!$sts0){ closedir($handle); return -2; } } } } closedir($handle); }else{ return -1; } return 0; } /*------------------------------------------------- テーブルタグ間は\nを置換しない --------------------------------------------------*/ function chk_strtag($str){ // trace_log("0 son>>".$str); $str = " ".$str; $pos1 = strpos($str, ">".$pos1); $str2 = str_replace("\n","
",substr($str, 0, $pos1-1)); $pos2 = strrpos($str, ""); if($pos2){ $str2 .= substr($str, $pos1, $pos2-$pos1+8); // trace_log("2 >>".$pos2); $str2 .= str_replace("\n","
",substr($str, $pos2+8)); }else{ $str2 .= substr($str, $pos1-1); } }else{ $str2 = str_replace("\n","
",$str); } return $str2; } /*------------------------------------------------- テンプレートHTML置換出力 --------------------------------------------------*/ function html_out( $pagename, $mode, $hospital_id ){ global $BASE_DIR; global $HTML_DIR; global $PREVIEW_TMP; // ページのテンプレート名  $tmppath = $BASE_DIR.$TMPLT_DIR.$pagename.".html"; //trace_log("html_out>>> tmplate=".$tmppath); // テンプレートのval入替え $code = buil_tmpsub($tmppath, $val); // モード、ページ名を見て吐出し先を決める if($mode == "design"){ // トップpreview用PATHはここ $fpath = $BASE_DIR.$HTML_DIR."h".$hospital_id."/".$PREVIEW_TMP."index.html"; }else{ switch($pagename){ case "toppage": $fpath = $BASE_DIR.$HTML_DIR."h".$hospital_id."/index.html"; break; default: $fpath = $BASE_DIR.$HTML_DIR."h".$hospital_id."/".$pagename."/index.html"; break; } } //trace_log("FPATH>>".$fpath); /*------------------------------------------------- HTMLファイル作成 --------------------------------------------------*/ $fp = fopen($fpath,"w+"); if($fp){ fwrite($fp, $code); fclose($fp); }else{ return -5; /* db_tran_rollback(); cm_err_page("HTML作成でエラーが発生しました。"); exit(); */ } return 0; } /*---------------------------------------------------- メール送信共通モジュール -----------------------------------------------------*/ function sendmail($from, $to, $replyto, $subject, $message, $headers, $files = NULL) { // PHPサーバーのコード mb_language("Ja"); mb_internal_encoding("SJIS"); $boundary = "----=_NextPart_".uniqid(rand(),1); $subject = mb_encode_mimeheader(mb_convert_encoding($subject, "JIS", "auto"), "JIS"); $body = mb_convert_encoding($message, "JIS", "auto"); $headers .= "From: ".$from."\r\n"; if($replyto != NULL) $headers .= "Reply-To: ".$replyto."\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "X-Mailer: sendmail.php\r\n"; if(count($files) > 0) { $headers .= "Content-type: multipart/mixed; boundary=\"$boundary\"\r\n"; $message = "--$boundary\r\n"; $message .= "Content-Type: text/plain; charset=\"ISO-2022-JP\"\r\n\r\n"; $message .= "$body\r\n"; for($i = 0; $i < count($files); $i++) { $fileinfo = $files[$i]; $message .= "--$boundary\r\n"; if($fileinfo["nameencode"] != NULL) { $fileinfo["filename"] = mb_convert_encoding($fileinfo["filename"], $fileinfo["nameencode"], "auto"); $fileinfo["filename"] = mb_encode_mimeheader($fileinfo["filename"]); } $message .= "Content-Type: application/octet-stream; name=\"".$fileinfo["filename"]."\"\r\n"; $message .= "Content-Transfer-Encoding: base64\r\n"; $message .= "Content-Disposition: attachment; filename=\"".$fileinfo["filename"]."\"\r\n\r\n"; $fileinfo["binary"] = chunk_split(base64_encode($fileinfo["binary"])); $message .= $fileinfo["binary"]."\r\n\r\n"; } $message .= "--$boundary\r\n"; } else { $headers .= "Content-Type: text/plain; charset=\"ISO-2022-JP\""; $message = "$body\r\n"; } return mail($to, $subject, $message, $headers); } /*----------------------------------------------------- @@@ 20061201 kwak -------------------------------------------------------*/ Function check_and_make_directory($directory){ if(!file_exists($directory)){ if(!mkdir($directory, 0777)){ return false; } } return true; } /*----------------------------------------------------- @@@ 20061204 kwak -------------------------------------------------------*/ Function delete_All_Files_And_Directory($directory){ if(is_dir($directory)){ if ($dh = opendir($directory)) { while (($file = readdir($dh)) !== false) { if($file != "." && $file != ".."){ if(is_dir($directory."/".$file)){ delete_All_Files_And_Directory($directory."/".$file); }else{ if(!unlink($directory."/".$file )){ return false; } } } } closedir($dh); } rmdir($directory); } return true; } /*----------------------------------------------------- @@@ 20061204 kwak -------------------------------------------------------*/ Function backup_All_Files_And_Directory($directory){ $targetdirectory=$directory."_old"; check_and_make_directory($directory."_old"); if(!copy_all_files($directory,$targetdirectory)){ return false; }; return true; } /*----------------------------------------------------- @@@ 20061204 kwak -------------------------------------------------------*/ Function rollback_All_Files_And_Directory($directory){ $sourcedirectory=$directory."_old"; if(!copy_all_files($sourcedirectory,$directory)){ return false; }; delete_All_Files_And_Directory($sourcedirectory); return true; } /*----------------------------------------------------- @@@ 20061201 kwak -------------------------------------------------------*/ Function copy_all_files($sourcedirectory,$targetdirectory){ //フォルダの存在確認して無かったら生成(check_and_make_directory->common.inc) if(!check_and_make_directory($targetdirectory)){ return false; } if ($handle = opendir($sourcedirectory)){ while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if(!is_dir($sourcedirectory."/".$file)){ if( file_exists ( $targetdirectory."/".$file)){ if(!unlink($targetdirectory."/".$file)){ return false; } } if(!copy($sourcedirectory."/".$file,$targetdirectory."/".$file)){ return false; } }else{ if( !file_exists($targetdirectory."/".$file)){ if(!mkdir($targetdirectory."/".$file, 0777)){ return false; } }else{ if(!unlink($targetdirectory."/".$file)){ return false; } if(!mkdir($targetdirectory."/".$file, 0777)){ return false; } } copy_all_files($sourcedirectory."/".$file,$targetdirectory."/".$file); } } } closedir($handle); } return true; } /*----------------------------------------------------- @@@ 20061204 kwak -------------------------------------------------------*/ // FTPでIMAGEとCSS FOLDER内の全てのファイルとフォルダをアップロード (引数(ex./html/h13/image)) Function allfiles_up_by_ftp($sourcedirectory,$targetdirectory,$pretargetdirectory){ global $BASE_DIR; global $HTML_DIR; global $DESIGN_DIR; global $HTML_HOME; // FTP接続 // FTPサーバー情報 $sql = "select * from hospital_mst where hospital_id=".$_COOKIE["hospital_id"]; $rs = db_query($sql); if($rs==0){ return false; } // サーバー名が指定されていれば if($rs[0]["ftp_server"] != ""){ $ftp_port = 21; $ftp_timeout = 1000; // 基本的な接続を設定 $conn_id = ftp_connect($rs[0]["ftp_server"],$ftp_port,$ftp_timeout); if(!$conn_id){ cm_err_page("ファイル転送でエラーが発生しました。[99]"); exit(); } // ユーザ名とパスワードを指定してログイン $login_result = ftp_login($conn_id, $rs[0]["ftp_usrname"], $rs[0]["ftp_pass"]); // パッシブモードのON/OFF turn passive mode on -- important! if($rs[0]["pasv_mode"]=='1'){ ftp_pasv ( $conn_id, true ); }else{ ftp_pasv ( $conn_id, false ); } // 接続を確認 if ((!$conn_id) || (!$login_result)) { return false; } }else{ return false; } $ftp_initpath=$rs[0]["ftp_initpath"]; $pwd = ftp_pwd ($conn_id); // ROOTに指定ルートホルダー移動 ftp_chdir($conn_id, $ftp_initpath); // ディレクトリ情報を得る(get_ftp_nlist->common.inc) $nlist = get_ftp_nlist($conn_id,$pretargetdirectory); //html内のフォルダのリストをえる // デフォルト ログインルート $token = strtok($pretargetdirectory, "/" ); while($token!=NULL){ if(!ftp_chdir($conn_id,$token)){ return false; } $token = strtok( "/" ); } // 指定ホルダーが無ければ作成する if(!in_array($targetdirectory, $nlist)){ if(!ftp_mkdir($conn_id, $targetdirectory)){ return false; } } if(ftp_chdir($conn_id, $targetdirectory)){ if (($handle = opendir($sourcedirectory))) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { // アップロード $upload = ftp_put($conn_id, $file, $sourcedirectory."/".$file, FTP_BINARY); // アップロードのステータスを確認 if (!$upload) { return false; } } } closedir($handle); } // FTPストリームを閉じる ftp_quit($conn_id); return true; }else{ return false; } // FTPストリームを閉じる ftp_quit($conn_id); } /*----------------------------------------------------- link -------------------------------------------------------*/ Function kakunin_link($category_no, $tenpo_no){ switch($category_no){ case "01": $kakunin_link = "life_member.php?tenpo_no=".$tenpo_no; break; case "02": $kakunin_link = "study_member.php?tenpo_no=".$tenpo_no; break; case "03": $kakunin_link = "work_member.php?tenpo_no=".$tenpo_no; break; case "04": $kakunin_link = "live_member.php?tenpo_no=".$tenpo_no; break; default: $kakunin_link = ""; } return $kakunin_link; } Function detail_link($category_no){ switch($category_no){ case "01": $detail_link = "life_detail.php"; break; case "02": $detail_link = "study_detail.php"; break; case "03": $detail_link = "work_detail.php"; break; case "04": $detail_link = "live_detail.php"; break; } return $detail_link; } /*----------------------------------------------------- アクセスカウンタ(1:基本情報ページ/2:お知らせページ) -------------------------------------------------------*/ Function access_count($tenpo_no,$kiji_no,$kinds){ switch($kinds){ case "1": //基本情報ページ $sql = "select * from tenpo where tenpo_no='".$tenpo_no."'"; $rs = db_query($sql); if($rs[0]["access_count"] == ""){ $count = 1; $count2 = 1; } else{ $count = $rs[0]["access_count"] + 1; $count2 = $rs[0]["access_cnt_all"] + 1; } $sql = "update tenpo set access_count=".$count.",access_cnt_all=".$count2; $sql.= " where tenpo_no='".$tenpo_no."'"; db_query($sql); break; case "2": //お知らせページ $sql = "select * from kiji where tenpo_no='".$tenpo_no."' and kiji_no='".$kiji_no."'"; $rs = db_query($sql); if($rs[0]["access_count"] == ""){ $count = 1; $count2 = 1; } else{ $count = $rs[0]["access_count"] + 1; $count2 = $rs[0]["access_cnt_all"] + 1; } $sql = "update kiji set access_count=".$count.",access_cnt_all=".$count2; $sql.= " where tenpo_no='".$tenpo_no."' and kiji_no='".$kiji_no."'"; db_query($sql); break; } } /*-------------------------------- 文字コード調査 POSTで文字化けする為EUC-JP→SJIS ---------------------------------*/ function charcode_grep($tmp){ if(mb_detect_encoding($tmp[0],"UTF-8,EUC-JP,SJIS") == "EUC-JP"){ $i = 0; while($tmp[$i] != ""){ $tmp[$i] = mb_convert_encoding($tmp[$i],"SJIS","EUC-JP"); $i++; } } return $tmp; } ?> 0){ $cnt = ($page * $PAGE_ROW) - $PAGE_ROW; if(($cnt + $PAGE_ROW) > $rows){ $cntMax = $rows; }else{ $cntMax = $cnt + $PAGE_ROW; } $pageMax = ceil($rows / $PAGE_ROW); //総件数の設定 if($rows > 0){ if( ($cnt+1) == $cntMax){ $w_kensu = number_format($rows)."件中 ".($cnt+1)."件目を表示"; } else{ $w_kensu = number_format($rows)."件中 ".($cnt+1)."〜".$cntMax."件目を表示"; } } //前への設定 $w_page_previous = ""; if($page > 1){ $w_page_previous = "<<前へ"; } //次への設定 $w_page_next = ""; if($page < $pageMax){ $w_page_next = "次へ>>"; } //ページ数の設定 $w_page_sel = ""; for($i = 1; $i <= $pageMax; $i++){ if($page == $i){ //指定のページならリンクなし・太字 $w_page_sel.="[".$i."]"; }else{ $w_page_sel.="[".$i."]"; } } }else{ // @@@20061030 $w_page_sel =""; } } function set_page_pack2( $rows, &$cnt, &$page, &$w_kensu, &$cntMax, $PAGE_ROW2){ // ページ設定 $roop_flg = 0; do{ if($roop_flg == 0){ $page = $_POST["p"]; } else{ // $page = $page -1; } if(!is_numeric($page)){ $page = 1; } if($rows > 0){ $cnt = ($page * $PAGE_ROW2) - $PAGE_ROW2; if(($cnt + $PAGE_ROW2) > $rows){ $cntMax = $rows; }else{ $cntMax = $cnt + $PAGE_ROW2; } //総件数の設定 if(($cnt+1) <= $rows){ if( ($cnt+1) == $cntMax){ $w_kensu = number_format($rows)."件中 ".($cnt+1)."件目を表示"; } else{ $w_kensu = number_format($rows)."件中 ".($cnt+1)."〜".$cntMax."件目を表示"; } $roop_flg = 0; } else{ $w_kensu = ""; $roop_flg = 1; } } }while($roop_flg == 1); } ?>