uploadify jQuery+php 多檔上傳套件

uploadify
http://www.uploadify.com
uploadify 是一個jQuery+php 多檔上傳套件

基本安裝

[html language=””]
<link href="/uploadify/uploadify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="/uploadify/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/uploadify/swfobject.js"></script>
<script type="text/javascript" src="/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(‘#file_upload’).uploadify({
‘uploader’ : ‘/uploadify/uploadify.swf’,
‘script’ : ‘/uploadify/uploadify.php’,
‘cancelImg’ : ‘/uploadify/cancel.png’,
‘folder’ : ‘/uploads’,
‘auto’ : true
});
});
</script>
[/html]

[html title=”body”]<input id=’file_upload’ name=’file_upload’ type=’file’ />[/html]

OPTION

(boolean) auto 啟用自動選項會自動開始上傳文件時添加到文件上傳隊列 'auto'        : true (string)
buttonImg
設定上傳按鈕圖片
'buttonImg'   : '/uploadify/button.jpg'

(string)
buttonText
顯示在按鈕上的文字

(string)
cancelImg
The path to an image you would like to use as the cancel button.

(string)
checkScript
檢查檔案是否已在伺服器上的腳本的路徑

(string)
displayData
顯示百分比或每秒幾k
'percentage' / 'speed' 

(string)
expressInstall
The path to the expressInstall.swf file.
提示安裝flashplayer的樣子 

(string)
fileDataName
指定上傳後要傳進哪個變數
'fileDataName' : 'myuploadify' 後會在php傳進 $_FILES['myuploadify']

(string)
fileDesc
顯示檔案類型的描述在"瀏覽"
'fileDesc'    : '網頁圖片 (.JPG, .GIF, .PNG)' 

(string) fileExt 限制上傳的附檔名或檔名 'fileExt'     : '*.jpg;*.gif;*.png'

(string) folder 上傳後存放的資料夾

(integer)
height
"瀏覽"按鈕的高度

(boolean)
hideButton
隱藏按鈕,主要是之後利用 DIV + css 符合你的顯示風格

(string)
method
傳值類型, 'POST' or 'GET' 預設是 'POST'

(boolean) multi 允許多檔上傳

(string)
queueID
設置顯示隊列的DIV之類的容器 ID ,未設置時會在瀏覽按鈕下方產生一個

(integer) queueSizeLimit 同時可以存在幾個任務(檔案)

(boolean)
removeCompleted
自動移動已上傳完的檔案列表,預設true
(boolean)
rollover
顯示按鈕的滑鼠事件,如於按鈕上'HOVER' 未於按鈕上'OFF' 按下'PRESSED'

(string)
script
後台處理程序的相對路徑。默認值:uploadify.php

(string)
scriptAccess
swf檔的連接方式 預設和正式時用'sameDomain' 最好只在測試時 'always' 或不設(和FLASH不熟…)

(JSON object with mixed types)
scriptData
夾帶JSON資料傳送…沒研究
An object containing name/value pairs with additional information that should be sent to the back-end script when processing a file upload.

(integer)
simUploadLimit
同時上傳的檔案數,超過可以排在隊列

(integer) sizeLimit 限制每一個上傳檔案的 bytes 數(string)
uploader
uploadify.swf 文件的路徑

(integer)
width
瀏覽按鈕的寬度

(string)
wmode
設'transparent'可使FLASH的背景變透明

EVENTS 事件
(function)
onAllComplete
隊列所有檔案完成上傳時
data.
[filesUploaded] - 總上傳檔案
[errors] - 錯誤數
[allBytesLoaded] - 總上傳Bytes
[speed] - 速度, KB/s
[html]$(#file_upload).uploadify({
  'uploader'      : '/uploadify/uploadify.swf',
  'script'        : '/uploadify/uploadify.php',
  'cancelImg'     : '/uploadify/cancel.png',
  'folder'        : '/uploads',
  'onAllComplete' : function(event,data) {
      alert(data.filesUploaded + ' 個檔案上傳完成!');
    }
});[/html]
(function)
onCancel
有檔案被取消時
'onCancel'    : function(event,ID,fileObj,data) {
    alert('The upload of ' + fileObj.name + ' has been canceled!');
}
(function)
onCheck
任務開始前確認檔案名是否存在,存在時會確認覆蓋
要搭配'checkScript' : '/uploadify/check.php'

(function)
onClearQueue
呼叫 uploadifyClearQueue() 清除任務時

(function)
onComplete
單個檔案完成時

(function)
onError
發生錯誤時

(function)
onInit
Uploadify 讀進來時

(function)
onOpen
檔案開始上傳前

(function)
onProgress
每次進度條變化時

(function)
onQueueFull
任務數量達到 queueSizeLimit 最大上傳數時

(function)
onSelect
檔案加入任務時(每個檔案觸發)

(function)
onSelectOnce
檔案加入任務時(加入一次觸發一次)

(function)
onSWFReady
swf物件讀入時

.uploadify()
實作一個 Uploadify uploader.
.uploadifyCancel()
取消移除上傳中檔案

.uploadifyClearQueue()
取消移除上傳中任務(所有檔案)

.uploadifySettings()
修改 目前Uploadify 設定

.uploadifyUpload()
開始上傳

Wordpress 函式

bloginfo(‘name’);
印出網誌名稱

bloginfo(‘url’);
印出網誌url

bloginfo(‘stylesheet_url’);
印出css檔的url

bloginfo(‘charset’);
印出字元編碼

bloginfo(‘rss_url’);
bloginfo(‘rss2_url’);

wp_get_archives(‘type=monthly&format=link’);
貼在head裡產生wordpress訂閱用的連結?

wp_head();
呼叫funtion.php的函式

bloginfo(“description”);
秀出簡介

_e(‘Categories’);
國際化詞

wp_list_cats(“sort_column=name&optioncount=1&hierarchical=1”);
印出分類
sort_column=name 以名稱排序 optioncount=1 秀出文章數 hierarchical=1 往下顯示一層

get_links_list();
印出鏈結

 

軟體清單

Google Chrome

Mozilla Firefox

多媒體類

Foobar2000
可以很單純也可以設定到很細的強大音樂播放軟體

格式工廠FormatFactory
萬用多媒體轉檔工具,從各種格式轉成各種格式,還可以選轉出的尺寸以用於PSP、MP4、手機上播放

Mp3tag
很方便的管理mp3的tag軟體

Picasa 相片檢視器
Google出品,風格我喜歡

網路類

eMule

µTorrent

JDownloader

ComicShelf

文書類

心智圖

XMind

FreeMind

Thinking Space (Android手機)

[php] 安全處理

  • 過瀘危險字元
    mysql_real_escape_string($_POST[Str])
    把SQL字元都加上
    檢查 get_magic_quotes_gpc 是否被開啟

    get_magic_quotes_gpc 如果被開啟的話會自動把特殊字元加上反斜線,這時候再mysql_real_escape_string的話會造成資料錯誤
    // 檢查 get_magic_quotes_gpc 功能是否開啟
    if (get_magic_quotes_gpc())

attribute_escape($text);
把html控制字元(如<>)轉成&&之類的型式

  • 檢查來源
    $_SERVER[HTTP_REFERER]
    可以取得使用者上一頁的url

  • 過瀘變數的長度、數值等等

  • 隱藏目錄
  • 不顯示錯誤訊息

整理流程

//將所有透過$_get/$_post的特殊文字加上反斜線
if(PHP_VERSION >= 6 || !get_magic_quotes_gpc()) {
$_REQUEST = array_map( ‘addslashes’, $_REQUEST);
}

接收表單文字時
function myStripslashes($value){
// 若 get_magic_quotes_gpc 功能已經開啟,就刪掉反斜線
if (get_magic_quotes_gpc())

        $value = stripslashes($value);

    return $value;
}

寫入資料庫時

mysql_real_escape_string($_POST[xxx]);

其它漏洞

action=$_SERVER[‘PHP_SELF’]

可能會被XSS攻擊
改用
htmlentities($_SERVER[‘PHP_SELF’])

[WEB] CKEditor 3.x WYSIWYG Editor 所見即所得編輯器安裝及設定

CKEditor

官網:http://ckeditor.com/ 下載:http://ckeditor.com/download

安裝方式:

以Appserv為例,下載後解壓縮到x:appservwww 底下就行了
之後可以到 http://<你的網址>/ckeditor/_samples/index.html 看到各種官方案例就成功了

簡單實作:

以下例子都是做一個name為textarea01的有CKEditor 功能的文字區塊出來
環境於www根目錄,ckeditor資料夾也於根目錄上

基本版

[html title=”於head內加入”]<script type="text/javascript" src="ckeditor/ckeditor.js"></script> [/html]
[xml title=”於body內加入”]<script type="text/javascript"></span>
CKEDITOR.replace(‘textarea01’);
</script>[/xml]

php版

[html title=”於head內加入”]<?php require_once("ckeditor/ckeditor_php5.php")?>[/html]
[php title=”於body內加入”]$CKEditor = new CKEditor();
$CKEditor->editor("textarea01");[/php]

jQuery版

[html title=”於head內加入”]<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js"></script>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="ckeditor/adapters/jquery.js"></script>
<script type="text/javascript">
$(function()
{
$("textarea[name=’textarea01’]").ckeditor();
});
</script>[/html]
[html title=”於body內加入”]<textarea name="textarea01">HelloWorld</textarea>[/html]

設定CKEditor預設值:

打開ckeditor/config.js
更詳細的官方說明:官方config.js文件

[javascript]
CKEDITOR.editorConfig = function( config )
{
config.toolbar = ‘MyStyle’;
//toolbar按鈕的配置,細節設定在下面的config.toolbar_MyStyle 還可以自製 Full Basic等類型需要時直接換
config.language = ‘zh’;
//設定成中文
config.uiColor = ‘#AADC6E’;
//設定界面顏色
config.resize_enabled = false;
//設定成不能隨意拉大範圍
config.toolbar_MyStyle =
[
{ name: ‘document’, items : [ ‘Source’,’-‘,’NewPage’,’DocProps’ ] },
{ name: ‘clipboard’, items : [ ‘Cut’,’Copy’,’Paste’,’PasteText’,’PasteFromWord’,’-‘,’Undo’,’Redo’ ] },
{ name: ‘editing’, items : [ ‘Find’,’Replace’,’-‘,’SelectAll’] },
‘/‘,
{ name: ‘basicstyles’, items : [ ‘Bold’,’Italic’,’Underline’,’Strike’,’Subscript’,’Superscript’,’-‘,’RemoveFormat’ ] },
{ name: ‘paragraph’, items : [ ‘NumberedList’,’BulletedList’,’-‘,’Outdent’,’Indent’,’-‘,’Blockquote’,’CreateDiv’,’-‘,’JustifyLeft’,’JustifyCenter’,’JustifyRight’,’JustifyBlock’,’-‘,’BidiLtr’,’BidiRtl’ ] },
{ name: ‘links’, items : [ ‘Link’,’Unlink’,’Anchor’ ] },
{ name: ‘insert’, items : [ ‘Image’,’Flash’,’Table’,’HorizontalRule’,’SpecialChar’,’PageBreak’ ] },
‘/‘,
{ name: ‘styles’, items : [ ‘Styles’,’Format’,’Font’,’FontSize’ ] },
{ name: ‘colors’, items : [ ‘TextColor’,’BGColor’ ] },
{ name: ‘tools’, items : [ ‘Maximize’, ‘ShowBlocks’ ] }
];

config.toolbar_Full =
[
    { name: 'document', items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] },
    { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
    { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
    { name: 'forms', items : [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton','HiddenField' ] },'/',
    { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
    { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv','-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
    { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
    { name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
    '/',
    { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
    { name: 'colors', items : [ 'TextColor','BGColor' ] },
    { name: 'tools', items : [ 'Maximize', 'ShowBlocks','-','About' ] }
];

config.toolbar_Basic =
[
    ['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink']
];

};
[/javascript]

幫CKEditor減肥:

  • 如果你不是用php的話可以刪掉所有.php檔
  • 反之也可以刪所有.asp檔
  • _samples資料夾
  • _source資料夾
  • skins內用不到的外表
  • lang內用不到的語系
    還有刪掉ckeditor根目錄下的

  • CHANGES.html

  • ckeditor.pack
  • ckeditor_basic.js 、 ckeditor_basic_source.js和ckeditor_source.js (如果你不loading他們)
  • INSTALL.html

[Android] Google Map API 的前置工作

keytool -genkey - v -keystore 名稱.keystore

http://code.google.com/intl/zh-TW/android/maps-api-signup.html

  • Windows Vista: C:Users\.androiddebug.keystore
  • Windows XP: C:Documents and Settings\.androiddebug.keystore
  • OS X and Linux: ~/.android/debug.keystore

MapView要使用以下格式
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:apiKey=”xxxxxxxxxxxxxxxxxxxxxxxxx”
/>

[xml]
< xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ><manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot; package=&quot;edu.ntit.md.imwn.test&quot; android:versionCode=&quot;1&quot; android:versionName=&quot;1.0/>
<application android:icon=&quot;@drawable/icon&quot; android:label=&quot;@string/app_name/>
<activity android:name=&quot;.test&quot;
android:label=&quot;@string/app_name/>
<intent-filter>
<action android:name=&quot;android.intent.action.MAIN&quot; />
<category android:name=&quot;android.intent.category.LAUNCHER&quot; />
</intent-filter>
</activity>
<uses-library android:name=&quot;com.google.android.maps/></uses-library>
</application>
<uses-permission android:name=&quot;android.permission.INTERNET&quot; />
</manifest>
[/xml]

要多

[xml]
<pre><uses-library android:name=”com.google.android.maps”></uses-library> //java.lang.NoClassDefFoundError
<uses-permission android:name=”android.permission.INTERNET” /></pre>
</pre>[/xml]

結果會是白的。還有很多沒設定

device-e1307025707813.png

其它設定:

去掉TitleBar

[xml]<activity android:name=&quot;.HelloGoogleMaps&quot; android:label=&quot;@string/app_name&quot;</span>
<pre> <strong>android:theme=&quot;@android:style/Theme.NoTitleBar&quot;</strong>>[/xml]

[Android] 3D引擎整理

Bonzai Engine

http://www.bonzaiengine.com/

OpenGL/OpenGL Es

for Windows, Mac, Linux, Solaris and Android

Browsers
Chrome
Firefox
Safari
Opera
Internet Explorer

formats:

AC3D Inivis AC3D
3DS & ASE Autodesk 3ds Max model formats (write support for 3DS)
LWO Lightwave model formats
OBJ Alias/Wavefront model format (write support)
DAE Collada
FBX Autodesk FBX
BVH Biovision Hierarchy (skeleton hierarchy and motion)
MS3D Milkshape 3D model format
MD2,MD3,MD5 ID Software/Quake model formats
KMZ Google Earth KMZ models
X3D Web3D
Optimized format for the engine (JMF/JMA/JAF/JLF) with high compression and optional encryption (write support)

=============================================

jPCT

http://www.jpct.net/

free 3D engine for Java

免費,但不公開原始碼

loads 3DS, OBJ, MD2, ASC and XML files

支援Android

=============================================

Catcake

http://code.google.com/p/catcake/

Catcake is a cross-platform 3D graphics engine intended to be easy-to-use and high performance, which also supports the features for game development, such as animation, input device handling and sound playing.

Catcake runs on following platforms for now:

  • Windows
  • Linux
  • Android
  • iPhone
    Catcake provides:

  • Polygon and sprite rendering with scene graph

  • Transparent objects management
  • Lightweight task management for animation
  • Resource (includes VRAM) management
  • Memory management
  • Automatic frame-rate adjustment
  • Font rendering (TTF, TTC, OTF, and so on)
  • Screen splitting
  • Real-time debugging monitor
  • Programmable shaders (GLSL)
  • Lighting (parallel and point lights)
  • Input device (mouse and keyboard) management
  • Sound playing with 4-channel mixer
  • Collision detection (sphere, box, triangle and ray)
  • Configuration file parser
  • 3D model drawing (3DS)
  • Motion playing
  • 3D model auto-generation from 2D images

alien3d

http://code.google.com/p/alien3d/

A OpenGL ES based game engine for Android OS

難產…停擺

=============================================

AndEngine

Free Android 2D OpenGL Game Engine

http://www.andengine.org/blog/

=============================================

Rokon

停止更新

=============================================

libgdx

Android/desktop game development framework

處理聲音、輸入等等

=============================================

ShiVa

要錢

=============================================

ardor3d

Welcome to the community home of Ardor3D, a professionally oriented, open source, Java based 3D engine. We’ve built this site to give you the information, contacts and tools to create better real-time 3D games and simulations.

=============================================

NyARToolkit

http://sourceforge.jp/projects/nyartoolkit-and/

五人拼接

想呈現出樂團的感覺
左一:貝斯手
左二:吉它手
中:鍵盤
右二:歌手
最右:鼓手

可惜鼓手的位置好像偏了







4/6 漂流



今天到大甲的海邊去尋找合意的漂流木做擺飾/種花,順路去參觀了山腳國小和趙老師新落成的工作室。

今天天氣非常好,很適合出遊拍照


大甲海邊的名產:風力發電
第一次看到的時候很懷疑那麼細又那麼重是怎麼讓風吹動的
總覺得風車應該長的像這樣↓



排排隊出發尋寶!





菇類不知道是被沖來之前就長的還是在海邊長…應該是在森林中陰涼出長的吧



相框



大甲的另個特點…到處都看的到廟

離開海邊後去了小7吃個點心…有阿伯在做不良示範




到了山腳國小後發現光線非常的好,拍出來的顏色都很漂亮,而且國小內的日式建築十分合我胃口




貓咪的角度看緣廊





被拍的感覺…十分有緊迫盯人的感覺

拍照重點,背景的線條為水平/垂直時比較能讓人覺得那是當作背景用的,不會把主角的目光搶走






「媽!我也想要一間這種別墅」
離開了山腳國小後我們去參觀了老師的工作室,有獨棟透天有池糖有樹有花有雞沒有魚
魚被白鷺絲攻擊完了!!


是沒看過雞嗎

好童心純僕的畫
我:老師!為什麼年輪有那麼多圈
老師:因為這是樹根的部份


很適合當web page的背景圖

兩邊的感覺…對比啊
  

最後來玩個小宇宙

3/30 光與影的魔術

今天老師讓我們每個人試著用LIGHTROOM去調RAW檔
而且準備了20多張不同風格的相片去讓我們調
有舞蹈的、室內的、過亮過暗、風景等等不同感覺的相片
還搭配了色階分佈圖(Level?)來說明過亮或過暗的部份




處理前的相片,看右上角的色階圖可以知道畫面過亮,而且畫面的色彩明顯的過淡
處理後:色階分佈的很平均,且色彩變鮮豔了,使主題較為明確


老師正在說明處理中的照片的色階



這次老師還提到了安瑟亞當斯(Ansel Easton Adams)
他以拍攝黑白風光作品見長,其中最著名的是優勝美地國家公園系列。
他提出「區域系統」的技術概念,認為攝影師應借光線的變化,控制底片和相紙上的密度觀感。亞當斯也倡導「可視化」的概念(他亦常稱之為「前可視化」,但這個詞並未為後世所接受),指照片給予人的觀感,取決於光線的測量值,即在景物攝入鏡頭那一刻已經決定。(摘自wikipedia)

亞當斯生於1902年,逝於1982. 當時的攝影都是黑白相片
他的照片在光線的呈現上非常的舒服,不知道當時照了照片後能不能再經由沖洗的動作調整亮度
我覺得我現在在同個位置照了一樣角度的照片後,再拿到電腦上調都不見得調的出這種感覺了
再當時不能馬上看到結果的底片時代…那時代的攝影師是掌握著光與影的神啊!

亞當斯網站上的照片