年紀大了有些事容易忘記... 所以.....

星期三, 12月 24, 2014

Facebook 廣告或貼文圖片建議尺寸

建議尺寸: 560x292
最佳尺寸: 1200x675

※如果圖片被 cache 住,可至下列網址清除並更新
https://developers.facebook.com/tools/debug/

星期二, 5月 20, 2014

2014 Facebook Application API & FB API 串接權限審核

這應該跟Facebook F8發表會所提到的有關,
所以現在只要你網站或APP使用到一些「特殊」功能(取得按讚數、取得生日資料、發佈照片資料等)

我大概測試了一下,只有新建的APP才需要做審核,
如果是舊有的APP,即使user至設定將該APP使用權限移除後再重新進入該APP授權
操作與權限都還是會與之前相同,別擔心

另外本次在 feed 這 method 看似也移除掉了分享預設文字的功能(所以以後分享不能設預設文字了?!!!)

如果你只需要用到下面三種權限的話則不需要審核
1.email
2.public_profile
3.user_friends

各權限的功能及範圍可以參考此篇
Permissions with Facebook Login
https://developers.facebook.com/docs/facebook-login/permissions/v2.0#permission-user_website

星期二, 5月 06, 2014

Instagram API 教學 (取得 User ID 及照片資訊)

這邊僅用來搜尋帳號資料及取得相片資訊

請先以 Instagram 帳號登入 http://instagram.com/developer/
點擊右上角「管理客戶」填一些基本資料後點選「註冊新客戶」
Website 及 OAuth redirect_url 都填 http://localhost 就可以(除非你有要取得token或上傳等功能才要另外填)

[PHP] FreeRADIUS + PPTPD + MySQL 分析並取得目前連線的資料


FreeRADIUS 雖然可以使用 MySQL 及帳號管理來記錄每個連線帳號的資料,
不過我沒去啟用那個功能(也不會用~~") 所以就另外寫了排程來處理這個工作

※開啟 FreeRADIUS 的 authlog 功能
/etc/radius/etc/raddb/sites-available/default 94行
auth_log 取消註解

/etc/radius/etc/radiusd.conf 443行
auth = yes

重新啟動 radiusd 服務
/sbin/service radiusd restart

Crontab -e
*/3 * * * * /usr/bin/php -q /home/shell/radius_log.php > /dev/null 2>&1

iOS 上架送審 退件原因

iOS Application Reject Information

1. Terms and conditions(法律與條款)

1.1
 As a developer of applications for the App Store you are bound by the terms of the Program License Agreement (PLA), Human Interface Guidelines (HIG), and any other licenses or contracts between you and Apple. The following rules and examples are intended to assist you in gaining acceptance for your App in the App Store, not to amend or remove provisions from any other agreement.(作為App Store的應用開發者,你必須接受如下條款:Program License Agreement (PLA),Human Interface Guidelines (HIG),以及任何你與apple簽訂的許可和合同。以下規則和示例是為了協助你的應用更快通過審核上架,而不是修正或取代之前的條款。)

星期日, 4月 27, 2014

紅米機 小米機 大陸版 如何使用 Google Play 商店

買了大陸版的小米機 紅米機 確無法使用 Google Play 商店時該怎麼辦?!

免ROOT 免刷機

先在小米市集下載谷歌應用下載器並安裝新版 Play 商店
http://app.xiaomi.com/detail/36925


下載此apk並安裝即可使用 Google Play 商店
https://dl.dropboxusercontent.com/u/24181563/apk/com.android.vending-4.2.9.apk

星期三, 4月 23, 2014

[Android] 打包簽署 APK 時出現 Export aborted because fatal lint errors were found 錯誤

打包簽署 APK 時出現下面錯誤
「Export aborted because fatal lint errors were found. These area listed in the Lint View. Either fix these before running Export again, or turn off "Run full error check when exporting app" in the Android > Lint Error Checking preference page.」





星期四, 4月 17, 2014

PHP 自動等比縮放圖片函式

//取圖片寬高並回傳適合寬高
 /*
  $org_height 原圖高
  $org_width 原圖寬
  $height 限制的高
  $width 限制的寬
  $autoResize 是否強制縮到寬高都在範圍內
  2014/4/17 @C Fixed
 */
 function getImageSize_resize($org_height='',$org_width='',$height='',$width='',$autoResize='N'){
  if(!$org_height || !$org_width){
   return FALSE;
  }
  
  $new_height = '';
  $new_width = '';

  $tmp_width = $org_width;//圖片寬度
  $tmp_height = $org_height;//圖片高度
  
  $ratio = 1;
  
  if(($width && $tmp_width > $width) || ($height && $tmp_height > $height))
  {
   if($width && $tmp_width > $width)
   {
    $width_ratio = $width/$tmp_width;
    $resize_width_tag = true;
   }
   
   if($height && $tmp_height > $height)
   {
    $height_ratio = $height/$tmp_height;
    $resize_height_tag = true;
   }
      
   if($resize_width_tag || $resize_height_tag)
   {
    if($width_ratio > $height_ratio)
    {
     $ratio = $width_ratio;
    }
    else
    {
     $ratio = $height_ratio;
    }
    
    if($resize_width_tag && !$resize_height_tag)
    {
     $ratio = $width_ratio;
    }
    
    if($resize_height_tag && !$resize_width_tag)
    {
     $ratio = $height_ratio;
    }

    $new_width = round($tmp_width*$ratio);
    $new_height = round($tmp_height*$ratio);

    if($autoResize=="Y")
    {
     if(($width && $new_width > $width) || ($height && $new_height > $height))
     {
      return $this->getImageSize_resize($new_height,$new_width,$height,$width,"Y");
     }
    }
    
    return array($tmp_width,$tmp_height,$new_width,$new_height);
   }
  }
  return array($tmp_width,$tmp_height,$new_width,$new_height);
 }

PHP 變更 Session 存放路徑

<?php
session_save_path('tmp');
?>

上述是將 session 存放於 tmp 資料夾的意思

星期二, 4月 08, 2014

iOS Xcode 常用相關資料記錄

記錄與 iOS 開發有關的常用工具或指令 

Apple Developer
https://developer.apple.com/
管理憑證用

iTunes Connect
https://itunesconnect.apple.com/
管理應用程式及報表

Application Loader
https://itunesconnect.apple.com/apploader/ApplicationLoader_2.9.dmg
發佈 ipa 檔用

Android SDK 常用相關資料記錄

記錄與 Android 開發有關的常用工具或指令

Android SDK
http://developer.android.com/sdk/index.html?hl=sk

Eclipse
https://www.eclipse.org/downloads/


Titanium 常用相關資料記錄

記錄 Titanium 相關指令或是注意事項

Titanium
http://www.appcelerator.com/titanium/

修正 jQuery Validation 日期檢查在 ie8 不支援 yyyy-mm-dd 的小問題

我習慣用 2014-01-30 這樣的日期格式,很奇怪在其它瀏覽器都正常,就 ie8 有問題......orz

開啟 jquery.validate.js
#1025 行
date: function( value, element ) {
            return this.optional(element) || !/Invalid|NaN/.test(new Date(value).toString()) || value.match(/^\d{4}-((0\d)|(1[012]))-(([012]\d)|3[01])$/);
        },


改成這樣就可以了,不過有點不防呆就是了XD
版本是 jQuery Validation Plugin 1.11.1

延伸閱讀
jQuery plugin: Validation
http://bassistance.de/jquery-plugins/jquery-plugin-validation/

星期二, 4月 01, 2014

開啟及使用 Codeigniter 的 CSRF 保護

開啟及使用 Codeigniter 的 CSRF 保護

1.開啟 /application/config/config.php
$config['csrf_protection'] = true; //將此項設為 true
$config['csrf_token_name'] = 'csrf_test_name'; //此為csrf的token名稱,可自訂
$config['csrf_cookie_name'] = 'csrf_cookie_name'; //此為csrf的cookie名稱,可自訂
$config['csrf_expire'] = 7200; //cookie失效時間

2.將 CSRF 語法加入於表單內
如果你是使用 form_open() 去建立表單的話,CI會自己產生 csrf 的語法,如果你跟我一樣都喜歡自己寫表單,那就照下面的方式就可以了

在表單中插入下列字串
<input type="hidden" name="<?php echo $this->security->get_csrf_token_name()?>" value="<?php echo $this->security->get_csrf_hash()?>" />

3.測試方法
表單送出後,如果表單內沒有csrf的token或是token不同的話,頁面會顯示 The action you have requested is not allowed. 訊息,拒絕操作

若僅前台要使用csrf,則修改config.php檔案,依實際情況調整下列語法即可
if(stripos($_SERVER["REQUEST_URI"],'/admin') === FALSE)
{
    $config['csrf_protection'] = TRUE;
}
else
{
    $config['csrf_protection'] = FALSE;
}  


※延伸閱讀
CodeIgniter User Guide Version - Security Class
http://ellislab.com/codeigniter/user-guide/libraries/security.html

CSRF (Cross Site Request Forgery) 跨網站請求偽造攻擊
http://en.wikipedia.org/wiki/Cross-site_request_forgery

星期五, 3月 28, 2014

星期四, 3月 27, 2014

jQuery 與 DataTables Ajax 實作記錄

※目前已實現的功能
1.根據 url 頁數直接跳至該頁資料
2.排序功能
3.Ajax 取得資料
4.jQuery UI 分頁顯示
5.關鍵字查詢 Ajax 處理

※未實現的部份
1.多欄位排序

因為這邊只是記錄,所以寫的有點草...(汗

Blogger 外掛及調整安裝備忘錄

怕自己忘記所以做個記錄

1.Blogger 崁入 SyntaxHighlighter
2.Blogger 崁入 標籤雲 Tag Cloud

星期三, 3月 26, 2014

Synology DSM 5 自訂 MySQL 資料夾

請先以 root 登入 SSH

設定檔
/volume1/@appstore/MariaDB/etc/mysql/my.cnf

自訂 datadir
vi /usr/share/mysql/mysql.server
將datadir填上

#cd /var/services
#mv mysql mysql_bak
#ln -s /volume1/MySQL/mysql/ mysql
#cp -a /var/services/mysql_bak/* ./mysql (此動作視情況做,若有innodb則logfile被取代後會造成DB資料遺失)

重啟MySQL服務
# /usr/share/mysql/mysql.server restart

匯出
#/usr/bin/mysqldump -u 帳號 -p密碼 --lock-all-tables --default-character-set=utf8 DB名稱 > 匯出路徑