顯示具有 fopen 標籤的文章。 顯示所有文章
顯示具有 fopen 標籤的文章。 顯示所有文章

2015年2月3日 星期二

phpmailer

參考資料
http://belleaya.pixnet.net/blog/post/27410978-%5B%E6%95%99%E5%AD%B8%5D-php-%E5%88%A9%E7%94%A8-phpmailer-%E9%80%8F%E9%81%8E-gmail-%E5%AF%84%E4%BF%A1
http://blog.jsdan.com/php-%E4%BD%BF%E7%94%A8phpmailer%E9%80%8F%E9%81%8Egmail%E5%AF%84%E4%BF%A1/
http://who-know.com/use-phpmailer-to-send-emails-via-gmail-smtp/
while try catch自動分行讀取
http://kris-14.blogspot.tw/2009/12/php-txt.html
http://phpwrite.blogspot.tw/2010/05/php5try-catch.html
fopen 檔案路徑寫法
http://www.php.net/manual/en/function.fopen.php
輸入及呼叫
http://www.dami.tw/2013/11/11phpcode.html
http://www.php5.idv.tw/html.php?mod=article&do=show&shid=54
http://www.php5.idv.tw/html.php?mod=article&do=show&shid=68
http://stackoverflow.com/questions/15890627/phpmailer-body-with-variables
php重複定義
http://witmax.cn/php-cannot-redeclare-class.html
html註解
http://ant4html.blogspot.tw/2008/11/blog-post.html
php運行時間限制以及後台運行
ignore_user_abort(true);
set_time_limit(0);
http://www.ptt.cc/man/PHP/DEAA/M.1359052474.A.47F.html
http://www.blueshop.com.tw/board/FUM20041006152627A9N/BRD2012020312083365R.html
http://www.allenj.net/archives/1910
http://blog.wu-boy.com/2007/06/php-%E5%96%84%E7%94%A8-ignore_user_abort-%E5%87%BD%E5%BC%8F/
http://www.isdee.com/notes/ecshop_phpmailer.html
http://hi.baidu.com/yxl7808/item/00b9ca9c85628ae62916471d
http://sourceforge.net/p/phpmailer/discussion/81620/thread/6819cd16/
清除收件者欄位
由於預設是用addaddress()所以當跑迴圈時會重複寄送
因此需使用clearaddresses()並且不能用unset(), unset只是暫時重設,下次再呼叫時會讀取unset前之數值
http://www.wibibi.com/info.php?tid=236
http://chan15.blogspot.tw/2011/11/phpmailer.html
textarea
使用input只有一行,因此一般的留言板都應該使用textarea
另外input可以設定長度跟高度,雖然還是只能輸入一行
http://stackoverflow.com/questions/4391344/how-can-i-set-the-size-of-the-box-of-a-form
http://crazy.molerat.net/learner/cpuroom/programmer/reading.php?filename=1010407112825.dov
http://www.php-example.com/2011/05/php-html-form-textarea-example.html
斷行處理
http://chensh.loxa.edu.tw/php/X_8.php
http://www.jollen.org/php/jollen_php_book_79_textarea.html
http://itgroup.blueshop.com.tw/ann71727/ann71727?n=convew&i=6032

selenium download file, php

Download File [Arguments] ${COOKIE} ${URL} ${FILENAME} ${COOKIE_VALUE} = Call Selenium API get_cookie_by_name ${COOKIE} Run and Return RC wget --cookies=on --header "Cookie: ${COOKIE}=${COOKIE_VALUE}" -O ${OUTPUT_DIR}${/}${FILENAME} ${URL}

php POST變數.$_POST["item"]後方如果要接字必須以 "," or "." 隔開,否則會出錯

fopen file時在linux下會有權限問題,要注意需給予使用者read權限否則會無法讀取。

使用fgets取得txt資料時,會帶出行尾的特殊符號,以windows為例為\r\n。因此在做比對時,不論是使用==或strcmp()函數都需要先將這些特殊符號消去(或是在輸入端增加),才能成功比對。

我是使用ereg_replace("\r\n","",變數)來做。供參考。順帶一提,如果將\0消去則整個字串會消失。

想要驗證則可以使用strlen()函數來觀察字串的長度,就可以知道其實有特殊符號的存在。

最後apache的預設使用者是www-data(可去/etc/apache2/envvar修改),如果要使用fopen讀取檔案記得將www-data加到owner群組內,virtualbox shared folder共用資料夾則是要將www-data加到vboxsf群組內才可正常讀取。

#sudo gpasswd -a www-data vboxsf

#sudo usermod -G vboxsf www-data 有一樣效果

以下code可以查看group內成員
$ sudo grep ^群組名稱: /etc/group

過程中由於出錯使得apache內的log資料量暴增,一開始不知道只覺得硬碟空間怎麼消失這麼快,後來使用指令列出資料夾大小才找出來。max-depth是指只顯示一層,-B M是以MB表示,sort -g是照大小排列。

du -B M --max-depth=1 | sort -g

參考資料
自己經驗
https://blog.codecentric.de/en/2010/07/file-downloads-with-selenium-mission-impossible/
http://php.net/manual/en/function.shell-exec.php
http://stackoverflow.com/questions/2404794/strcmp-on-a-line-read-with-fgets
將ubuntu內資料夾所佔空間列出
http://banco.pixnet.net/blog/post/21967119-%5Bubuntu%5D-%E5%88%A9%E7%94%A8du%E6%90%AD%E9%85%8Dsort%E4%BE%86%E6%9F%A5%E7%9C%8B%E7%A3%81%E7%A2%9F%E4%BD%BF%E7%94%A8%E7%A9%BA%E9%96%93
fget
http://qaautomationworld.blogspot.in/2014/02/file-downlaoding-using-selenium.html
http://stackoverflow.com/questions/7618155/how-to-duplicate-a-request-using-wget-or-curl-with-raw-headers
https://addons.mozilla.org/zh-TW/firefox/addon/export-cookies/
http://stackoverflow.com/questions/4272770/wget-with-authentication