2012年1月4日 星期三

centos 安裝ffmpeg 及 mplayer mencoder

Installing FFmpeg, MPlayer and MEncoder on CPanel and Centos 6 on Hyper-V
Posted in Linux Server, Virtual Machine Manager | 5 Comments | 1,108 views | 03/10/2011 13:52
You need FFmpeg, MPlayer and MEncoder for video processing. I’ll show you how to install and configure it on Hyper-V.
I’ve already posted couple of articles about CentOS 6 installation on Hyper-V, so I won’t mention about that again.
You can see CentOS 6 installation on Hyper-V at the following posts:
So I assume you have a CentOS 6 with Hyper-V LIS v3.1. So lets continue with our installation.
First, we need to install RPMforge repository on CentOS 6.
1. Install the DAG GPG key.
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt


2. Download RPMforge-release package.
cd /home
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm (if your server x86)
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

3. Verify the RPMforge-release package you have downloaded.
rpm -K rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

4. Install the RPMforge-release package.
rpm -i rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

5. Now we can install FFmpeg, MPlayer and MEncoder.
yum install ffmpeg ffmpeg-devel mplayer mencoder

6. You may get this error when you try to install components.
Requires: perl-SGMLSpm >= 1.03ii

7. Download perl-SGMLSpm package to CentOS.
wget http://ftp.twaren.net/Linux/Scientific/41/i386/SL/RPMS/perl-SGMLSpm-1.03ii-14.noarch.rpm

8. perl-SGMLSpm may require OpenJade.

9. Let’s install openjade on CentOS.
yum install openjade

10. Try re-install perl-SGMLSpm.
rpm -ivh perl-SGMLSpm-1.03ii-14.noarch.rpm

11. After perl-SGMLSpm installation, you can continue to install FFmpeg, MPlayer and MEncoder.
yum install ffmpeg ffmpeg-devel mplayer mencoder

12. Now, you can test your ffmpeg installation.
ffmpeg -v

If you see same results on your server, it means your ffmpeg is ready.

2012年1月3日 星期二

linux 開機執行層級之設定

打開這個檔案
/etc/inittab
將其中的
id:3:initdefault:
其中的3改為你要的層級即可

2011年11月19日 星期六

dreamweaver PHP mysql 可以批次更新資料的方法!

底下所提的批次更新資料的方法,是建立在你必須對於DREAMWEAVER的基本更新資料的方法已經有一定的了解之後,才易看懂筆者所寫的內容。若你對DREAMWEAVER更新單筆資料的方法尚且不懂,則不建議你繼續看下去!
這邊筆者僅針對批次更改與單筆更改資料之主要差異處作說明而已:
image
一、首先如上圖,你必須對所有要更新資料的表單欄位之名稱後面加入陣列符如上圖中的score[]
image
二、當然更新資料所必須的隱藏欄位所指向的索引欄也須需如上圖中的index[]一樣加入[]
三、接著在伺服器行為裡加入更新資料(這邊因為一般的圖資料都有提到,所以就跳過,不細述了!)
四、最後在程式碼模式下找到更新資料的語法部份,例如(注意你的語法決對不可能完全與我的一樣,所以你必須視自己的狀況調整)
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
  $updateSQL = sprintf("UPDATE all_data SET leader_study_1=%s, study_mark1=%s WHERE `index`=%s",
                       GetSQLValueString($_POST['score[]'], "int"),
                       GetSQLValueString($_POST['textfield[]'], "text"),
                       GetSQLValueString($_POST['index[]'], "int"));
  mysql_select_db($database_load, $load);
  $Result1 = mysql_query($updateSQL, $load) or die(mysql_error());
  $updateGoTo = "leader_study.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
改為
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
    $countNum=count($_POST['index']);
        for($i=0 ; $i<$countNum ; $i++){
  $updateSQL = sprintf("UPDATE all_data SET leader_study_1=%s, study_mark1=%s WHERE `index`=%s",
                       GetSQLValueString($_POST['score'][$i], "int"),
                       GetSQLValueString($_POST['textfield'][$i], "text"),
                       GetSQLValueString($_POST['index'][$i], "int"));
  mysql_select_db($database_load, $load);
  $Result1 = mysql_query($updateSQL, $load) or die(mysql_error());
        }
  $updateGoTo = "leader_study.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
    $updateGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $updateGoTo));
}
注意上述的更改中,還要將原來語法中的[]刪處掉!
這樣一來才可以批次更新資料。

2011年10月16日 星期日

PHP頁面中-CKeditor網頁編輯器與CKfinder上傳整合應用

編輯器:CKeditor
支援語法:PHP、ASP、ASP.NET、CF
檔案大小:1.99MB
元件版本:3.5.1
官方展示:http://ckeditor.com/demo
官方下載:http://ckeditor.com/download

上傳元件:CKfinder
檔案大小:1.01MB
支援語法:PHP、ASP、ASP.NET、CF
元件版本:2.0.1
官方展示:http://ckfinder.com/demo
官方下載:http://ckfinder.com/download

step1

下載完畢後,將二個元件放在同一目錄,並新增upload資料夾,用來存放上傳檔案。

step2

開啟ckeditor / config.js,分別新增以下語法,控制編輯器選項與啟用上傳功能。

開啟上傳功能:將下面內容加入ckeditor / config.js

config.filebrowserBrowseUrl = 'ckfinder/ckfinder.html';
config.filebrowserImageBrowseUrl = 'ckfinder/ckfinder.html?Type=Images';
config.filebrowserFlashBrowseUrl = 'ckfinder/ckfinder.html?Type=Flash';
config.filebrowserUploadUrl = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files'; //可上傳一般檔案
config.filebrowserImageUploadUrl = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images';//可上傳圖檔
config.filebrowserFlashUploadUrl = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash';//可上傳Flash檔案

而成為:

/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/

CKEDITOR.editorConfig = function( config )
{
    // Define changes to default configuration here. For example:
    // config.language = 'fr';
    // config.uiColor = '#AADC6E';
[
    ['Source','-','Templates','-','Cut','Copy','Paste'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
'/', ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['Format','FontSize','-','TextColor','BGColor']
];
config.filebrowserBrowseUrl = 'ckfinder/ckfinder.html';
config.filebrowserImageBrowseUrl = 'ckfinder/ckfinder.html?Type=Images';
config.filebrowserFlashBrowseUrl = 'ckfinder/ckfinder.html?Type=Flash';
config.filebrowserUploadUrl = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files'; //可上傳一般檔案
config.filebrowserImageUploadUrl = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images';//可上傳圖檔
config.filebrowserFlashUploadUrl = 'ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash';//可上傳Flash檔案

};

Step3
開啟ckfinder / config.php,找到33行將return false改成return true

{
    // WARNING : DO NOT simply return "true". By doing so, you are allowing
    // "anyone" to upload and list the files in your server. You must implement
    // some kind of session validation here. Even something very simple as...

    // return isset($_SESSION['IsAuthorized']) && $_SESSION['IsAuthorized'];

    // ... where $_SESSION['IsAuthorized'] is set to "true" as soon as the
    // user logs in your system. To be able to use session variables don't
    // forget to add session_start() at the top of this file.
return true;
//    return false; <----註解掉改為上一行的
return true

}

// LicenseKey : Paste your license key here. If left blank, CKFinder will be
// fully functional, in demo mode.
$config['LicenseName'] = '';
$config['LicenseKey'] = '';

/*
Uncomment lines below to enable PHP error reporting and displaying PHP errors.
Do not do this on a production server. Might be helpful when debugging why CKFinder does not work as expected.
*/
// error_reporting(E_ALL);
// ini_set('display_errors', 1);

/*
To make it easy to configure CKFinder, the $baseUrl and $baseDir can be used.
Those are helper variables used later in this config file.
*/

Step4
接著到63行處,設定上傳的目錄位置。

Examples:
    $baseUrl = 'http://example.com/ckfinder/files/';
    $baseUrl = '/userfiles/';

ATTENTION: The trailing slash is required.
*/
// $baseUrl = '/ckfinder/userfiles/';註解掉改為下一行的$baseUrl = '/ckfinder/upload/';

$baseUrl = '/ckfinder/upload/';
/*
$baseDir : the path to the local directory (in the server) which points to the
above $baseUrl URL. This is the path used by CKFinder to handle the files in
the server. Full write permissions must be granted to this directory.

step5

接著在你要使用文字區域的頁面裡加入導入CKEDITOR的核心。找到其<body>下插入下面一段文字串

<script src="ckeditor/ckeditor.js" type="text/javascript"><!--mce:2--></script>

body {
    background-color: #FFFBF0;
}
-->
</style></head>

<body>
<script src="ckeditor/ckeditor.js" type="text/javascript"><!--mce:2--></script>
<div align="center">
<h2><strong>寄信系統</strong>
</h2>
<form id="form1" name="form1" method="post" action="mail_message.php">

step6

找到你要使用CKEDITOR的文字區域的語法,加入class="ckeditor"

  <td bgcolor="#D4DFFF"><div align="right"><strong>內容:</strong></div></td>
  <td bgcolor="#D4DFFF"><div align="left">
      <textarea name="content" class="ckeditor" id="content" cols="50" rows="20"></textarea>
  </div></td>
</tr>
<tr>
  <td bgcolor="#D4DFFF"></td>
  <td bgcolor="#D4DFFF">

最後確認一下可否導入ckeditor?

image

再看可否上傳檔案?

image

一切測試正常!

2011年8月25日 星期四

dreamweaver的怪現象

用dreamweaver改寫php迴圈以達到一次更新多個資料,結果依書上的說明,直接將伺服器行為的更新記錄稍作改

主要加上:

$countNum=count($_POST['index']);
        for($i=0 ; $i<$countNum ; $i++){

$updateSQL = sprintf("UPDATE ``211`` SET sn=%s, `number`=%s, name_student=%s WHERE `index`=%s",
                       GetSQLValueString($_POST['test'][$i], "int"),
                       GetSQLValueString($_POST['test3'][$i], "int"),
                       GetSQLValueString($_POST['test2'][$i], "text"),
                       GetSQLValueString($_POST['Index'][$i], "int"));

  mysql_select_db($database_load, $load);
  $Result1 = mysql_query($updateSQL, $load) or die(mysql_error());

}

結果依書上的邏輯更改後,在更新時卻會出現

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '211`` SET sn=980801, `number`=1, name_student='方發' WHERE `index`=1' at line 1

後來發現問題在如下圖所指的,多了兩個單引號

image

將其刪除後,就可以了!

image

2011年8月24日 星期三

Dreamweaver欄位驗證之中文化

在你有要證證欄位的檔案找到如下程式碼,並將其中之相關文字內容中文化即可!

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' 必須是Email位址.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' 必須包含一個數字\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' 必須要為數字介於 '+min+' 到 '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' 是必須有資料的.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }

 

之檔案裡,找到以下字串

2011年8月14日 星期日

連羽毛球拍(鈦10),都有假的!不可不慎!

YY的球拍,我用的最順的是鈦10,這支拍子在一般有用過的球友口中評價都很高,由於已停產,所以想說能否上網買得庫存貨,果然在雅虎拍裡,打入關鍵字後,有找到幾支,其中有一個賣家標榜是全新,且價格是1050起標,於是我就大概問一問狀況之後,出價下標,結果沒想到兩天後就收到結標通知,得標價為1050,於是我看了看該賣家的評語,看起來也都還好,雖然評語只有3,於是也就不疑有他的付款取貨,沒想到貨到時,打開,還真令人失望,竟然是一支山寨拍,話說山寨也不太對,應說是仿冒拍!因為它廠牌型號與用原廠的,而唯一與原廠不同的是它的材質,一看就是差很大,即沒有鈦合金的金屬段,其它部分的材質也是看起來沒有原廠堅固耐用,加上其表面拷漆之脆弱,拍子一端原本在地面,另一端不小心輕輕掉落地面,結果拷漆就掉了!

這次只能說一分錢一分貨!價差過大的就要小心,再者這個賣家還算有良心的是,他沒有標價3、4仟元,因為同樣的東西,網路上我還真看到有人標價3、4仟元!

這次網購的經驗特地寫出供參考,只能說自己下標前沒先與賣家多做溝通,然而賣家似乎也有意要欺騙買家,因為有其他買家就提出相關的問題問賣家,而賣家的回覆是庫存貨、直接與日本工廠拿,所以價錢才這麼底!網購最好是選擇賣家有實體店面,可以現場看貨再決定要不要買!

2011年7月26日 星期二

如何將excel資料匯入成為mysql的資料的方法!

如何將excel資料匯入成為mysql的資料,底下是一段示範影片!

vosonic vp2160 升級解決2g限制的問題,真高興!

在相機記憶卡還算貴的年代裡,喜歡拍照的人都會因為動不動記憶卡就裝滿而不能拍照。所以若到出國時常會向親友借記憶卡(同格式的)或帶notebook(可以將裝滿照片的記憶卡資料,拷備到notebook,以便清空記憶卡後繼續拍),然而當時的notebook整體而言,也都滿重的(約3公斤上下),所以出國若要拍照拍的過隱,就必須要有負重的心理準備,後來有一種2.5吋的隨身碟(專有名詞已忘了),他除了同一般隨身碟一樣,可以usb介面外接之外,他本身附有各種記憶卡的讀記插槽,可以將你記憶卡上的資料,在插上該插槽之後,按一個鍵就可以把其中的資料全部拷備到該隨身碟裡了,

P1190496

而當時的2.5吋隨身碟最大容量還約40g左石,有這樣的容量大小,一次夠一個喜好攝影的人拍攝約半個月,是綽綽有餘的!所以我也買了一個,然而過一段時間之後,隨著數位像機的解析度越來越高,加上記憶卡、2.5吋硬碟容量也都越來越大,慢慢的記憶卡不僅會用來拍照,也用做錄影的儲存工具(因為4g的記憶卡,就可以錄一段頗長時間的影片了),而只要2.5吋的硬碟容量換大一點的,這樣出國不僅拍照或錄影,只要有一台數位相機(具錄影功能的),有一個大容量的記憶卡(>4g的),配合我的具讀卡功能的隨身碟就可以非常痛快的拍照與錄影了,不用擔心記憶卡容量不足的問題!

然而這一切看似美好的事情,就是這麼不如人意,該機器的讀卡功能竟也受到2g的限制,也就是你帶著大容量的記憶卡拍照或錄影,容量滿了之後,插在該機子的讀卡槽裡,它是讀不到的,當時我曾想過,會不會網路上可以找到升級的韌體來解決此一問題?可是令我感到遺憾的是,當時我並沒法找到相關的資料或檔案,於是該機子,慢慢的也就被我冷落在一旁,而我也就把它拿來做為一般的2.5吋隨身碟使用了(為此我還將其格式化為ntfs,因為原機要能做到可讀卡拷備的功能必須是fat32的格式,但因為我已不再使用2g以下的記憶卡了,所以該機的讀卡功能幾乎無用武之地,加上fat32有單一檔案4g的限制,所以我在決定將它變純粹的隨身碟使用後,就斷然將其格式化成NTFS格式了)。

直到今日,我心血來潮,心想;「會不會已可以升級解決2g限制的問題了?」,於是我在瀏覽器打入vosonic vp2160,結果我在網路上看到這樣的資料

2011年7月22日 星期五

ostube開放註冊,在中文化介面裡收到註冊信的問題!

ostube開放註冊,在中文化介面裡註冊,按下註冊鈕之後

image

接著會跳出這個畫面

image

到自己註冊的信箱裡收信,很高興的看到寄來了一封信

image

滑鼠點了一下看啟動連結,發現如下圖,空空如也!

image

造成這樣的原因是目的流傳在坊間的中文化版本在所有相關的語言檔都己中文化,然而卻少了一個部份的中文化,那就是在/ostube/templates/default/mail/裡面,打開資料夾來看,發現只有兩個子資料夾,分別是english與german。

這時只要我們將english資料夾拷備一份並更名為tw,然後將其內的所有檔案(如下圖)中文化即可(務必要將每個中文化的檔案之編號改為utf8,否則會是亂碼!)

image

當然這邊若你只想要解決註冊信的問題,你也可以只中文化signup.tpl這個檔案即可(甚至不中文化也可,只是寄出去的註冊信內容會是英文而已!)

image

接著再做一次註冊動作,然後再到信箱裡收信,這次果然看到有內容的信了!

image

點選該連結,果然如下圖可以完成註冊登入的動作。

image