徹夜する。
会社に届いたファックスを、社内LANのサーバーを経由してブラウザ(iPad含)で見る。
先日、EPSON-PX-B750F の複合機を購入した。
24時間電源を入れっぱなしのPCから、受信データをサーバーに保存する(pdf)。web ページ用のディレクトリにマウントして、PHP を利用して、pdf を閲覧できるようにした。
ちょっとばかり便利になった。
しかし、問題もある。複合機にファックスの着信があったことを、数分置きに確認しなければならないこと。どうも取引関係者は、ファックスを送信すると速攻で確認の電話をかけてくる。
確認まで、間に合いそう似ない。おちつけよ!みんな!
結局、外出していてもファックスを見ることができるようになった。
めずらしく、PHP で書いた。ちょっと JavaScript と勝手が違う。
html5 css3 javascript php ajax mysql 組み合わせは無限大だ!
プログラム中にある、new.gif の画像。
<!DOCTYPE html> <title>FAX受信フォルダ</title> <meta charset="utf-8"> <meta name = "viewport" content = "width = 640, initial-scale = 1.2, user-scalable = no"> <style> #FAX_LIST > li { font-size : large; padding-bottom : 1ex; margin-bottom : 1ex; border-bottom : 3px #f88 dotted; margin-right : 4em; width : 36em; } em.error { color : red; } em.time { color : green; } </style> <body> <?php //___________________________________________________________ $LOCAL_PATH = "/home/share/data/FAX/"; $DOMAIN_PATH = "./data/"; $IMAGE_PATH = "./"; $timeA = time (); $html = ''; // もし DEL_NAMEがあるのならば、ファイルを消してしまおうか?; // onload forEach ($_POST['DEL_NAME'] as $fname) { if (file_exists ($fname)) unlink ($fname); } //___________________________________________________________ $list = getPDFFile ($LOCAL_PATH, $DOMAIN_PATH); //pdffile 取得 usort ($list, "cmpFileTime"); //ソート foreach ($list as $name) { $timeB = filemtime ($name); $timeC = $timeA - $timeB; $getInfo_reg = "/^.+(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})_(.+)_(\d+\.pdf)$/i"; $mess = date("着信 : Y年m月d日 H時i分", $timeB); $new = "<img src=\"${IMAGE_PATH}new.gif\">"; switch (true) { case ($timeC < 600) : // < 10min $mess.= "<em class=\"time\">(". round ($timeC / 60). "分前)</em>". $new; break; case ($timeC < 3600) : // < 1hour $mess.= "<em class=\"time\">(約". round ($timeC / 60). "分前)</em>". $new; break; case ($timeC < 86400) : // < 1day $mess.= "<em class=\"time\">(もう". round ($timeC / 3600). "時間前)</em>". $new; break; case ($timeC < 86400 * 31) : // < 1month $mess.= "<em class=\"time\">(すでに". round ($timeC / 84600) . "日前)</em>"; break; case ($timeC < 86400 * 93) : // < 100day $mess.= "<em class=\"time\">(消してしまえるほどの". round ($timeC / 84600*31). "ヶ月前)</em>"; break; default : $mess.= "<em class=\"time\">(もう消せよ!ってくらい前)</em>"; break; } // pdf ファイルの情報を探る if (1 === preg_match ($getInfo_reg, $name, $info)) { list ($all, $yy, $mm, $dd, $hh, $mn, $sc, $num, $fname) = $info; $acquaintance = whoisthis ($num); } else { $acquaintance = $number = 'unknown'; $fname = 'Worning !! unknone file.'; $num = '**********'; } $html .= " <li>"; $html .= " <input type=\"checkbox\" name=\"DEL_NAME[]\" value=\"${name}\">"; $html .= " ${mess}<br>"; $html .= " From : <a href=\"faxto: ${num}\">${acquaintance}</a> / "; $html .= " File : ${DOMAIN_PATH}<a href=\"${name}\" target=\"_blank\">〜${fname}</a>"; $html .= " </li>"; } //___________________________________________________________ // pdf ファイルを取得する。名前の最後が、数字で5文字であること。 function getPDFFile ($path, $path2) { $result = array (); $handle = opendir ($path. '.'); $isPDF_reg = '/^.+_\d{5}\.pdf/i'; while (false !== ($file = readdir ($handle))) if ($file != "." && $file != "..") if (1 === preg_match ($isPDF_reg, $file)) $result[ ] = $path2. $file; return $result; } // ファイルを日付順で並び替えする function cmpFileTime ($A, $B) { return (filemtime ($B) - filemtime ($A)); } //ファックス番号から相手を特定する function whoisthis ($faxno) { switch ($faxno) { case '0194662181': $n = '東長寺'; break; default : $n = $faxno; } return $n; } ?> <h1>FAX受信データ</h1> <form action="#" method="post"> <ol id="FAX_LIST"> <?php echo $html; ?> </ol> <p> チェックしたファイルを削除しますか? <input type="submit" value="削除"> </p> </form>