2013-05-01
2013-04-13
CODE - 執行 php 出現的 Host key verification failed. 255 / Host key verification failed
php code
會顯示
Host key verification failed. 255 / Host key verification failed.
(或用 exec , retval 是 255 的情況)
解決方法 :
由執行 php code 的機器(這裡是 stage), 用 wwwrun 的身份去 ssh 該主機, 按 yes 即可
大概是因為 vm clone 好後, 雖 stage 的 public key 已加在該主機的 authorized_keys2 裡,
但實際上卻未曾連過, 只要連過 public key 便可在 authorized_keys2 裡生效
$cmd = '/usr/bin/ssh root@x.x.x.x cat /home/logs/consumer.log 2>&1'; $last_line = system($cmd, $retval); echo json_encode($retval).' / '.$last_line;
會顯示
Host key verification failed. 255 / Host key verification failed.
(或用 exec , retval 是 255 的情況)
解決方法 :
由執行 php code 的機器(這裡是 stage), 用 wwwrun 的身份去 ssh 該主機, 按 yes 即可
大概是因為 vm clone 好後, 雖 stage 的 public key 已加在該主機的 authorized_keys2 裡,
但實際上卻未曾連過, 只要連過 public key 便可在 authorized_keys2 裡生效
2013-03-28
2013-03-27
2013-03-15
2013-02-27
2013-01-07
2012-11-16
2012-10-13
CODE - php 字串取代
example :
$path = '/home/nas/webhd_14/e2/c3/10107664/50012/sync/a3/string'; $path = preg_replace('/home\/nas/', 'net', $path); # output: /net/webhd_14/e2/c3/10107664/50012/sync/a3/string
$str = 'hello.@.@world'; $key = preg_replace(array('/\./', '/\@/'), '_', $str); # output: hello||||world
2012-09-11
2012-08-22
2012-08-18
2012-07-23
CODE - php xml to array
code as below
cf : http://jaspreetchahal.org/php-xml-to-array-simplest-way/
//$xml = implode('', $output); $xmlObj = simplexml_load_string($xml); $json = json_encode($xmlObj); $arr = json_decode($json, true); print_r($arr);
cf : http://jaspreetchahal.org/php-xml-to-array-simplest-way/
2012-07-16
CODE - 讓單一網頁不被搜尋引擎 search 到的方法
在網頁加入以下這段
<meta Name="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
但這只能規範比較乖的 search engine,
碰到不遵守 robots.txt 及 meta 協議的 search engine 時, 就沒有用了
只防君子不防小人啊~
cf :
https://sites.google.com/site/csfinal2011/google-sou-xun-zhi-w...igoogle-sou-xun-de-wang-ye
http://productforums.google.com/forum/#!topic/websearch-zh-tw/B5YzxtSKIHk
http://lanlanlu.tw/document-files-google-search/
<meta Name="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
但這只能規範比較乖的 search engine,
碰到不遵守 robots.txt 及 meta 協議的 search engine 時, 就沒有用了
只防君子不防小人啊~
cf :
https://sites.google.com/site/csfinal2011/google-sou-xun-zhi-w...igoogle-sou-xun-de-wang-ye
http://productforums.google.com/forum/#!topic/websearch-zh-tw/B5YzxtSKIHk
http://lanlanlu.tw/document-files-google-search/
2012-07-06
2012-05-09
CODE - 用 java 發 get 的 http request
... String getUrl = "http://xx.xx/test.php?sn=xx&path=xx"; URL url = new URL(getUrl); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.connect(); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8")); loggerHelper.log("Contents of get request"); // 取得 return 值 String lines; while ((lines = reader.readLine()) != null){ loggerHelper.log("lines: "+lines); } reader.close(); connection.disconnect(); ...
cf :
http://www.jiucool.com/java-sending-http-requests-get-and-post-method-request/
http://www.exampledepot.com/egs/java.net/post.html
2012-04-23
2012-04-10
2012-03-15
訂閱:
文章 (Atom)