{"id":553,"date":"2011-09-06T21:25:14","date_gmt":"2011-09-06T12:25:14","guid":{"rendered":"http:\/\/takanix.com\/?p=553"},"modified":"2011-09-06T21:38:13","modified_gmt":"2011-09-06T12:38:13","slug":"%e3%80%90pear%e3%80%91%e3%81%95%e3%81%8f%e3%82%89%e3%82%b5%e3%83%bc%e3%83%90%e3%83%bc%e3%81%a7%e3%80%81%e7%94%bb%e5%83%8f%e6%b7%bb%e4%bb%98%e3%83%a1%e3%83%bc%e3%83%ab%e3%81%ae%e7%94%bb%e5%83%8f","status":"publish","type":"post","link":"https:\/\/takanix.com\/?p=553","title":{"rendered":"\u3010PEAR\u3011\u3055\u304f\u3089\u30b5\u30fc\u30d0\u30fc\u3067\u3001\u753b\u50cf\u6dfb\u4ed8\u30e1\u30fc\u30eb\u306e\u753b\u50cf\u3092\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u53d6\u308a\u51fa\u3059\u3002"},"content":{"rendered":"<p>\u307e\u305a\u3001\u3055\u304f\u3089\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u30b5\u30fc\u30d0\u30fc\u3067\u4ee5\u4e0b\u306e2\u70b9\u306f\u5b8c\u4e86\u3057\u3066\u304a\u3044\u3066\u4e0b\u3055\u3044\u3002<br \/>\n\u4ee5\u524d\u50d5\u304c\u30d6\u30ed\u30b0\u5185\u3067\u66f8\u3044\u305f\u3082\u306e\u3067\u3059\u3002<\/p>\n<ol>\n<li><a href=\"https:\/\/takanix.com\/?p=481\">\u3010PEAR\u3011\u3055\u304f\u3089\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u30b5\u30fc\u30d0\u30fc\u3067PEAR\u3092\u4f7f\u3046<\/a><\/li>\n<li><a href=\"https:\/\/takanix.com\/?p=420\">\u3010\u7a7a\u30e1\u30fc\u30eb\u3011\u3055\u304f\u3089\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u3067\u3001\u7a7a\u30e1\u30fc\u30eb\u304b\u3089PHP\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5b9f\u884c\u3059\u308b\u3002<\/a><\/li>\n<\/ol>\n<p>2\u756a\u3067\u7528\u610f\u3057\u305fPHP\u30d5\u30a1\u30a4\u30eb\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<p>1\u756a\u3067\u884c\u3063\u305fPEAR\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u5834\u6240\u3067\u8a18\u8ff0\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u6587\u5b57\u30a8\u30f3\u30b3\u30fc\u30c9\u306f\u3001UTF-8\u3067\u66f8\u3044\u3066\u3044\u307e\u3059\u3002<\/p>\n<p><span style=\"color: #ff0000;\">&#8212;&#8212;&#8212;&#8212;&#8211;\u3053\u3053\u304b\u3089&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/span><\/p>\n<p><span style=\"color: #ff0000;\">#!\/usr\/local\/bin\/php \u00a0 \/\/\u2190\u3055\u304f\u3089\u30b5\u30fc\u30d0\u30fc\u306f\u3053\u306e\u8a18\u8ff0<\/span><\/p>\n<p>&lt;?php<br \/>\n\/\/PEAR\u306e\u30d1\u30b9\u3092\u8a2d\u5b9a<br \/>\n$path = &#8216;\/home\/(\u30e6\u30fc\u30b6\u30fc\u540d)\/pear\/PEAR\/&#8217;;<br \/>\nset_include_path(get_include_path() . PATH_SEPARATOR . $path);<br \/>\nrequire_once &#8216;\/home\/(\u30e6\u30fc\u30b6\u30fc\u540d)\/pear\/PEAR\/Mail\/mimeDecode.php&#8217;;<\/p>\n<p>\/\/\u53d7\u4fe1\u30e1\u30fc\u30eb\u304b\u3089\u8aad\u307f\u8fbc\u307f<\/p>\n<p>$params[&#8216;include_bodies&#8217;] = true;<br \/>\n$params[&#8216;decode_bodies&#8217;] = true;<br \/>\n$params[&#8216;decode_headers&#8217;] = true;<br \/>\n$params[&#8216;input&#8217;] = file_get_contents(&#8220;php:\/\/stdin&#8221;);<br \/>\n$params[&#8216;crlf&#8217;] = &#8220;\\r\\n&#8221;; \u00a0\/\/Shift_JIS\u3067\u8a18\u8ff0\u3059\u308b\u5834\u5408\u306f\u3001\\\u3092\u00a5\u3067\u3002<\/p>\n<p>if (!$params[&#8216;input&#8217;]) {<\/p>\n<p>\/\/ \u8aad\u307f\u8fbc\u307f\u5931\u6557<\/p>\n<p>exit();<\/p>\n<p>}<\/p>\n<p>$structure = Mail_mimeDecode::decode($params);<\/p>\n<p>\/\/\u9001\u4fe1\u8005\u306e\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3092\u62bd\u51fa<\/p>\n<p>$mail = $structure-&gt;headers[&#8216;from&#8217;];<br \/>\n$mail = addslashes($mail);<br \/>\n$mail = str_replace(&#8216;&#8221;&#8216;,&#8221;,$mail);<br \/>\n$mail = preg_replace(&#8216;\/(^.*&lt;|&gt;$)\/&#8217;, &#8221;, $mail);<\/p>\n<p>\/\/ \u4ef6\u540d\u3092\u53d6\u5f97<\/p>\n<p>$subject = $structure-&gt;headers[&#8216;subject&#8217;];<\/p>\n<p>\/\/ \u672c\u6587\u3001\u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\uff08\u753b\u50cf\uff09\u3092\u62bd\u51fa<\/p>\n<p>switch (strtolower($structure-&gt;ctype_primary)) {<br \/>\ncase &#8220;text&#8221;:<\/p>\n<p>\/\/ \u30b7\u30f3\u30b0\u30eb\u30d1\u30fc\u30c8(\u30c6\u30ad\u30b9\u30c8\u306e\u307f)<\/p>\n<p>$body = $structure-&gt;body;<br \/>\nbreak;<br \/>\ncase &#8220;multipart&#8221;:<\/p>\n<p>\/\/ \u30de\u30eb\u30c1\u30d1\u30fc\u30c8(\u753b\u50cf\u4ed8\u304d)<\/p>\n<p>foreach ($structure-&gt;parts as $part) {<br \/>\nswitch (strtolower($part-&gt;ctype_primary)) {<br \/>\ncase &#8220;text&#8221;:<br \/>\n$body = $part-&gt;body;<br \/>\nbreak;<br \/>\ncase &#8220;image&#8221;:<\/p>\n<p>\/\/ \u753b\u50cf\u306e\u62e1\u5f35\u5b50\u3092\u53d6\u5f97\u3059\u308b<\/p>\n<p>$type = strtolower($part-&gt;ctype_secondary);<\/p>\n<p>\/\/ \u6dfb\u4ed8\u30d5\u30a1\u30a4\u30eb\u4fdd\u5b58<\/p>\n<p>$photo = &#8220;sample&#8221;.$type;<\/p>\n<p>$tmpName = &#8216;\/home\/(\u30e6\u30fc\u30b6\u30fc\u540d)\/www\/dir\/&#8217; . $photo;<span style=\"color: #ff0000;\"> \/\/\u753b\u50cf\u306e\u4fdd\u5b58\u5834\u6240\u3067\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #ff0000;\">\/\/\u2191\u5fc5\u305a\u30b5\u30fc\u30d0\u30fc\u30d1\u30b9\u3067\u8a18\u8ff0\u3057\u307e\u3059\u3002.\/dir\/\u306a\u3069\u306e\u76f8\u5bfe\u30d1\u30b9\u3067\u306f\u99c4\u76ee\u3067\u3059\u3002<br \/>\n\u4eca\u56de\u306f\u3001\u30b5\u30f3\u30d7\u30eb\u3067\u753b\u50cf\u540d\u306f\u3001sample\u306b\u3057\u3066\u3044\u307e\u3059\u3002 <\/span><\/p>\n<p>if ($fp = fopen($tmpName, &#8220;w&#8221;)) {<\/p>\n<p>$length = strlen($part-&gt;body);<\/p>\n<p>fwrite($fp, $part-&gt;body, $length);<\/p>\n<p>fclose($fp);<\/p>\n<p>}<\/p>\n<p>break;<br \/>\n}<br \/>\n}<br \/>\nbreak;<br \/>\ndefault:<br \/>\n$body = &#8220;&#8221;;<br \/>\n}<\/p>\n<p>?&gt;<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8211;\u3053\u3053\u307e\u3067&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>&nbsp;<\/p>\n<p>\u4fdd\u5b58\u3059\u308b\u300cdir\u300d\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f\u3001\u6a29\u9650\u3092777\u306b\u3057\u3066\u4e0b\u3055\u3044\u306d\u3002<br \/>\n\u30a8\u30e9\u30fc\u3084\u4fdd\u5b58\u3067\u304d\u306a\u3044\u7406\u7531\u306e\u591a\u304f\u306f\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u6a29\u9650\u3067\u3059\u3002<\/p>\n<p><span style=\"color: #0000ff;\">\/home\/(\u30e6\u30fc\u30b6\u30fc\u540d)\/pear\/PEAR\/\u3000\u3055\u304f\u3089\u306f\u3053\u308c\u304c\u30b5\u30fc\u30d0\u30fc\u30d1\u30b9\u3067\u3059\u3002<\/span><\/p>\n<p><span style=\"color: #0000ff;\">\u3061\u306a\u307f\u306b\u3001Drive Network\u306f\u3001\/home\/(\u30e6\u30fc\u30b6\u30fc\u756a\u53f7)\/(\u30c9\u30e1\u30a4\u30f3)<\/span><span style=\"color: #0000ff;\">\/(\u4fdd\u5b58\u30c7\u30a3\u30ec\u30af\u30c8\u30ea)\/pear\/PEAR\/\u3067\u3059\u3002<\/span><\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"color: #000000;\"><span>\u4ef6\u540d\u306f\u3001$subject<br \/>\n<\/span><span>\u672c\u6587\u306f\u3001$body\u3067\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002<br \/>\n\u9001\u4fe1\u8005\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u306f\u3001$mail\u3067\u53d6\u308c\u307e\u3059\u3002<\/span><\/span><\/p>\n<p><span style=\"color: #000000;\"><span>\u53d6\u5f97\u3057\u305f\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3084\u4ef6\u540d\u306f\u3001\u30c7\u30fc\u30bf\u30fc\u30d9\u30fc\u30b9\u306b\u767b\u9332\u3059\u308b\u306a\u308a\u3001\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306b\u4fdd\u5b58\u3059\u308b\u306a\u308a\u3001\u30e1\u30fc\u30eb\u3067\u9001\u308a\u306a\u308a\u3057\u3066\u4e0b\u3055\u3044\u3002<br \/>\n<\/span><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u307e\u305a\u3001\u3055\u304f\u3089\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u30b5\u30fc\u30d0\u30fc\u3067\u4ee5\u4e0b\u306e2\u70b9\u306f\u5b8c\u4e86\u3057\u3066\u304a\u3044\u3066\u4e0b\u3055\u3044\u3002 \u4ee5\u524d\u50d5\u304c\u30d6\u30ed\u30b0\u5185\u3067\u66f8\u3044\u305f\u3082\u306e\u3067\u3059\u3002 \u3010PEAR\u3011\u3055\u304f\u3089\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u30b5\u30fc\u30d0\u30fc\u3067PEAR\u3092\u4f7f\u3046 \u3010\u7a7a\u30e1\u30fc\u30eb\u3011\u3055\u304f\u3089\u30a4\u30f3\u30bf\u30fc\u30cd\u30c3\u30c8\u3067\u3001\u7a7a\u30e1\u30fc\u30eb\u304b\u3089PHP [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":""},"categories":[78,1,245],"tags":[286,604,311,309,310],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/takanix.com\/index.php?rest_route=\/wp\/v2\/posts\/553"}],"collection":[{"href":"https:\/\/takanix.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/takanix.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/takanix.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/takanix.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=553"}],"version-history":[{"count":9,"href":"https:\/\/takanix.com\/index.php?rest_route=\/wp\/v2\/posts\/553\/revisions"}],"predecessor-version":[{"id":566,"href":"https:\/\/takanix.com\/index.php?rest_route=\/wp\/v2\/posts\/553\/revisions\/566"}],"wp:attachment":[{"href":"https:\/\/takanix.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/takanix.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=553"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/takanix.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}