[PHP] magicQuote.php – 用PHP實作magic_quotes_gpc (適用於新環境舊架構)

Magic Quote新版PHP已不支援,但如果遇到舊架構放新環境,還是在Bootstrap就模擬Magic Quote即可治標。 PHP官方Magic Quote: Warning: This feature has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 5.4.0. 以下為遞迴對輸入做addslashes處理達到magic_quotes_gpc: function addslashesRecursively(&$data) { // print_r($data);exit; if (!is_array($data)) { $data = addslashes($data); } else { foreach ($data as $key […]

[Chrome] DPI自行設定 – Chrome layout High-DPI display in Windows

在Windows下兩種解決方式: 1. 停用高DPI顯示調整 Chrome捷徑設定內容,相容性標籤下取消=>’在高DPI設定時,停用顯示調整值’ 2. 捷徑目標參數 force-device-scale-factor Chrome捷徑設定內容,捷徑標籤下目標路徑後面新增 /force-device-scale-factor=1 # 目標設定Sample C:\Program Files (x86)\Google\Chrome\Application\chrome.exe” –profile-directory=”Profile 1″ /force-device-scale-factor=1.1

[AWS] 跨帳號S3鏡像對傳教學 – cross account S3 sync to S3 tips

Tips: 1. 開啟各別兩個帳號的S3 Bucket,皆賦予主帳號IAM權限 # Sample aws Bucket Policy json code { “Version”: “2012-10-17”, “Id”: “Policy1476346256284”, “Statement”: [ { “Sid”: “Stmt1476346255842”, “Effect”: “Allow”, “Principal”: { “AWS”: “arn:aws:iam::023227051571:user/nick” }, “Action”: “s3:*”, “Resource”: [ “arn:aws:s3:::account-a”, “arn:aws:s3:::account-a/*” ] } ] } 其中各別S3 Bucket範例分別為:account-a […]

[PHP] 註解規則表 – PHP Comment

以下為PHP註解規格,可用於宣告變數(Variable)、方法函數(Function)或類別(Class)中: /** * 函數名稱 * 函數描述(有些會含HTML代碼) * * @access 變數可存取的權限 (Example: Public or Private) * @api 爲第三方來源的變數 * @author 函數建立者名稱 (Example: @author Nick Tsai ) * @category 函數的分類別名,可能某些工具會利用這個來分類你的方法,使好幾個方法歸為某一類,方便做辨識使用 * @copyright 函數的版權宣告 (Example: @copyright Code.YIDAS code.yidas.com) * @deprecated 代表不建議使用的函數,未來可能會移除這個方法使用到的某個變數,或整個方法都被刪除 * @example […]

[PHP] 數學數字格式函數彙整 – Numeric Format Functions – (小數點.etc)

number_format() 千分位數值格式 數字格式化,千位分組,支援小數點。 echo number_format(1000.123, 2) = //1,000.12 echo number_format(1000.123, 2, ‘.’, ”); //1000.12 echo number_format(1000.123, 2, ‘,’, ”); //1000,12 sprintf 格式化數字 sprintf(“%05d”, 25); //Output: 00025 整數進位 round() //四捨五入,支援小數位數 ceil() //無條件進入 floor() //無條件捨去

[Nginx] 使用Proxy實作Load Balancer

Nginx設定: 直接給範例: # nginx conf http { upstream myapp1 { server srv1.example.com; server srv2.example.com; server srv3.example.com; } server { listen 80; location / { proxy_pass http://myapp1; } } } 簡而言之,在Http設定內註冊Upstream,在Server內使用Proxy Pass調用該Upstream Server Group。 分派演算法: round-robin — requests to the application […]