網頁

2020年8月14日 星期五

Lotus Notes 快速設定

 將 C:\Users\account\AppData\Local\IBM\Notes\Data\* 內的檔案全數複製到新的主機內即可。

2020年7月17日 星期五

MySQL 多版本並存 @ Windows

同主機內多版本 MySQL並存安裝方式:

下載 MySQL instraller ,點選並執行它。安裝過程參考附圖。過程中要注意的事項如下:
  1. 由於是要同主機多版本並存使用,所以 installer 的第一個頁面要選擇 Cancel後,再點選 Add 按鈕 (圖二)。
  2. port 衝突的問題,記得預設 port 號要更改。
  3.  Authentication Method 更動,主要是考量到版本相容性而已。
附圖參考:



















相關參考:

2020年5月20日 星期三

LDAP 相關資料



LDAP Code example

https://www.exchangecore.com/blog/using-ldap-active-directory-authentication-php

https://github.com/anthony-b/simple-php-LDAP-Authentication/blob/master/ldap.php

https://www.php.net/manual/en/ref.ldap.php

https://icodding.blogspot.com/2015/10/php-php-ad-server.html?m=0

https://www.php.net/manual/en/function.ldap-get-option.php

PHP 7.1 added support for configuring the LDAP CA/Cert environment directly

ldap_set_option(NULL, LDAP_OPT_X_TLS_CERTFILE, "/path/file.crt");

ldap_set_option(NULL, LDAP_OPT_X_TLS_KEYFILE, "/path/file.key");

https://bojack.pixnet.net/blog/post/23832296-%E3%80%90%E7%A8%8B%E5%BC%8F%E3%80%91%E5%88%A9%E7%94%A8-php-%E6%90%9C%E5%B0%8B-ldap---ad-%E8%B3%87%E8%A8%8A

https://ithelp.ithome.com.tw/questions/10167400

https://shuohsuanli-bear.blogspot.com/2016/11/phpactive-directory.html


LDAP Intro.

https://segmentfault.com/a/1190000014683418

https://blog.tomy168.com/2019/07/centos76-openldap.html

https://blog.xuite.net/tolarku/blog/151029105-LDAP+%E5%9F%BA%E7%A4%8E%E8%AA%AA%E6%98%8E

https://itman.pixnet.net/blog/post/26817279

https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/77626/


LDAP Online Test Server

https://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/

https://www.youtube.com/watch?v=AEjGhzZpGlg


LDAP Tools

Apache Directory Studio.

phpLDAPadmin

LDAP Admin

More
The Difference Between Active Directory and LDAP

2020年2月11日 星期二

cygwin 檔案及目錄設定不同權限的做法

按原 cygwin 的預設預設權限權限方式為目錄 770 檔案 750 ,但不知為什麼有少數幾台主機所使用的目錄與檔案預設權限都是 770 (查詢 umask 後都是正確的 0022)。

可以使用以下方式直接重設想要的權限:

使用 find 來執行 chmod:

find Apache2/ -type d -exec chmod 770 {} \; <= /www 內所有目錄
find Apache2/ -type f -exec chmod 750 {} \; <= /www 內所有檔案

find 的 -type 參數可以指定檔案的類型,常用的選項有:

d:目錄。

p:具名的 pipe(FIFO)。

f:一般的檔案。

l:連結檔,如果與 -L 或 -follow 參數同時使用時,就只會搜尋到有問題的連結檔,如果想要與 -L 同時使用,請改用 -xtype。

s:socket 檔案。

其它用的到的 find 指令

//找出當下目錄權限為 777 的所有檔案

find . -type f -perm 0770

//找出當下目錄權限不是 777 的所有檔案
find . -type f ! -perm 0770
雜記

目前遇到的狀況是在 htdocs 目錄內新增的檔案或目錄的權限會變成 ---rwx--- 的權限異常狀況。這也是為什麼會有這篇的存在。

發生原因不明,查看 umask 的預設設定皆正常,後來乾脆將 htdocs 目錄刪除,再利用 ssh ftp 帳號登入後,用這個身份新增目錄(e.g. mkdir htdocs),這時在這個特定的 htdocs 目錄內所新增的權限就是預設給的權限。


相關參考:

2019年12月8日 星期日

Apache 頻寬限制

Apache2.4 版本已內建頻寬限制模組。將 mod_ratelimit.so 啟動即可。

範例:針對特定目錄限速

LoadModule ratelimit_module modules/mod_ratelimit.so

<Directory "C:/Apache2/htdocs/download">
    SetOutputFilter RATE_LIMIT
    #1000kb/s
    SetEnv rate-limit 1000
</Directory>

相關資料

2019年11月22日 星期五

Web 與 CLI 使用不同的 PHP.ini 設定

Apache 使用自已專用的 php.ini 設定檔,PHP CLI Version 可以另外採用自已專用的 php-cli.ini 設定檔。

PHP CLI Version 使用範例:程式執行時可自行指定要使用的 php-cli.ini 設定  ( php -c C:/PHP/php-cli.ini test.php ;  -c <path>|<file> Look for php.ini file in this directory )

或者輸入 php --ini 看看 Loaded Configuration Files 是不是 php-cli.ini ,是的話直接輸入 php test.php 也是與上方的範例的執行結果相同。

註:將 php.ini 複製並重新命名為 php-cli.ini,這個在 CLI Version 模式會自動的找到 php-cli.ini。但若改成其它名稱時就不會 (例如: php_cli.ini ),此時程式在自行指定要使用的 php 設定檔。這種做法也許是是更為安全的作法,如此在 CLI 模式其它使用者,在時用時原則上仍是採用與 Web 相同的設定的 php.ini 設定。有特殊需求時再自行指定特定的 php_cli.ini 設定檔。

相關參考:

2019年6月6日 星期四

Google analytics 使用gtag 加入 event 事件

新版本的 google analytics 追蹤碼不能使用 ga 的機制
e.g. ga('send', 'event', [eventCategory], [eventAction], [eventLabel], [eventValue], [fieldsObject]);

改寫網頁後,觀察了很久,一直很納悶為什麼在 google analytics 平台內沒有看到資料。後來才發現到這件事。基本上網路上所找到的範例基本上還是以 ga 的方法為主。

目前新版本的 google analytics 追蹤碼要導入事件,要採用的方法是要改用 gtag 的方法。撰寫方式參考相關資料內的連結。

為了方便使用,參考 google 的範例,稍微調整成下面的方式:

function trackEvent(eventCatalog,eventAction,eventValue) {
    gtag('event', 'click', {
        'event_category' : eventCatalog,
        'event_action' : eventAction,
        'event_label' : eventValue,
        'value' : 1
    });
}

這樣的方式前端頁面要使用時,只要在需要加入監控的連結內加入此 function 即可,範例如右 <a href = 'https://www.google.com' onclick="trackEvent(TEST, click,Google)">Google</a>

google analytics 內的報表 =>行為 =>事件內的資料需要等待一段時間才能看到數據。想要即時知道到底改寫正不正確,可以利用報表 =>即時 =>事件功能頁面,再同時打開測試頁面點選測試 URL。這個時候若有在該功能頁面看到數據就表示新加入的 google event tracking 的功能是沒有問題的。


相關資料: