2 //=========================================================
5 // https://sourceforge.jp/projects/immt/
6 // 作者:Shohei Yokoyama (http://shohei.yokoyama.ac/)
8 // ご利用はat own your riskで。
11 //=========================================================
14 //imode.netのユーザ名(多分携帯電話番号)
19 $TO = "foo@gmail.com";
22 //--- ご自身の環境に応じて書き換えてください
23 /* HTML保存ファイル:書き込み可能なファイル */
24 $outHtml = "/home/foo/imode.html";
25 /* COOKIE保存ファイル:書き込み可能なファイル */
26 $outCookie = "/home/foo/imode.txt";
27 /* 絵文字保存フォルダ:書き込み可能なフォルダ(Webに公開されている場所) */
28 $emojiPath = "/home/foo/public_html/imode/";
29 /* 絵文字保存URL:上記のフォルダをWebから見た時のURL */
30 $emojiUrl = "http://hogehoge.jp/~foo/imode/";
35 $prefixSubject="[imode] ";
37 $prefixMail = "========================<br>
38 ※ このメールはimodeメールの転送です ※<br>
39 <a href=\"https://imode.net/cmn/m/\">https://imode.net/cmn/m/</a><br>
40 ========================<br>
44 /* コマンド:特に変更する必要は無いです */
45 $cmdEmoji = "wget --load-cookies=".$outCookie." ";
46 $cmdListWithLogin = "wget --quiet --save-cookies ".$outCookie." --keep-session-cookies -O ".$outHtml." --post-data 'HIDEURL=%3FWM_AK%3Dhttps%253a%252f%252fimode.net%252fsmfag%26path%3D%252fimail%252fm%252fsmarttop%26query%3D&LOGIN=WM_LOGIN&WM_KEY=0&MDCM_UID=".$UID."&MDCM_PWD=".$PWD."' https://imode.net/smf/dfw";
47 $cmdListWithoutLogin = "wget --quiet --load-cookies ".$outCookie." -O ".$outHtml." --post-data 'func_id_PWS301_F04=%e6%9c%80%e6%96%b0%e6%83%85%e5%a0%b1%e3%81%b8%e6%9b%b4%e6%96%b0&fid=0&pno=1&startdate=".date("YmdHis")."&chkdate=".date("YmdHis")."&bdid=0' https://imode.net/imail/m/e6uao/acgi/smart";
49 function getNewMail(){
50 global $outHtml,$cmdListWithLogin,$cmdListWithoutLogin;
51 exec($cmdListWithOutLogin);
52 if(strpos(file_get_contents($outHtml),'input name="MDCM_UID"')!==FALSE){
53 exec($cmdListWithLogin);
57 $cmdMail = "wget --quiet -O imode.html --load-cookies ".$outCookie." ";
58 $cmdMailUrl = "https://imode.net/imail/m/e6uao/acgi/";
62 $list = file($outHtml);
64 foreach($list as $line){
65 if(strpos($line,'<span class="unread">')!==FALSE){
67 $a = strpos($line,'<a href="')+11;
68 $z = strpos($line,'"',$a);
69 $cmd = $cmdMail.escapeshellarg($cmdMailUrl.html_entity_decode(substr($line,$a,$z-$a)));
71 $mail = file($outHtml);
72 $hit = false;$cc=0;$date="";$from="";$subject="";$text="";
73 foreach($mail as $row){
74 if($cc <= 3 and $hit){
77 list($gomi,$date) = explode(":",html_entity_decode(strip_tags($row)),2);
83 list($gomi,$from) = explode(":",html_entity_decode(strip_tags($from.$row)),2);
86 list($gomi,$subject) = explode(":",html_entity_decode(strip_tags($row)),2);
90 if(strpos($row,'<td colspan="2">')!==FALSE){
92 $text = html_entity_decode(substr($row,16,strlen($row)-23));
93 $text = "<html><head><base href=\"".$cmdMailUrl."\"></head><body>".$text."</body></html>";
94 $headers = 'MIME-Version: 1.0' . "\r\n";
95 $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";;
96 $headers .= 'From: '.$from."\r\n";
97 //echo "==========-\n";
100 //echo $subject."\n";
101 //echo "-----------\n".html_entity_decode($text)."\n-------------\n";
104 '|<img src="(\\.\\./[^"]*)"|U',
105 $text, $out, PREG_SET_ORDER
108 foreach($out as $emoji){
110 $filename = uniqid().".gif";
111 $emojis[html_entity_decode($emoji[1])] = $emojiUrl.$filename;
112 exec($cmdEmoji."-O ".$emojiPath.$filename." '".$cmdMailUrl.html_entity_decode($emoji[1])."'");
113 $text = str_replace($emoji[1],$emojis[html_entity_decode($emoji[1])],$text);
114 echo "\n\n\n".$text."\n\n\n";
116 mail($TO,$prefixSubject.$subject,$prefixMail.$text,$headers);
122 if(strpos($row,'<tr class="mailinfo">')!==FALSE){