2011年12月30日 星期五

YAHOO! 的API網站認證

環境:智邦的虛擬主機
問題:把yahoo!APIs需要認證的 檔案放在domain的root,在經過yahoo!的認證網頁認證,但一直過不了,也把yahoo的環境用成US,也依然解決不了。
解決: 把下面的.htaccess放在www的root,就可以認證通過了。

在www底下加入.htaccess
內容:


SecFilterEngine Off
SecFilterScanPOST Off


這樣網站認證就會過了!!

我參考的網頁:

http://programer.pixnet.net/blog/post/53935479

2011年12月27日 星期二

引用google的jquery

聽說可以減少連結的時間。
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'></script> 

<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
參考如下:
網址:http://code.google.com/intl/zh-TW/apis/libraries/devguide.html
http://www.ezdiy.org/forum/viewtopic.php?id=362

jquery 丟值到textarea

$("textarea#showMerchandiseContent").html('654');
$("textarea#ExampleMessage").val(result.exampleMessage);

dom中有value属性的是Button ImageButton、 CheckBox、 File、 Hidden、Password、Radio、 Reset 、Submit、 Text、 Option、 textarea


textarea

属性:

    Common -- 一般属性
    cols -- 多行输入域的列数
    rows -- 多行输入域的行数
    accesskey -- 表单的快捷键访问方式
    disabled -- 输入域无法获得焦点,无法选择,以灰色显示,在表单中不起任何作用
    readonly -- 输入域可以选择,但是无法修改
    tabindex -- 输入域,使用"tab"键的遍历顺序

2011年12月26日 星期一

CKEDITOR 所見即所得

CKEditor is a text editor to be used inside web pages. It's a WYSIWYG editor, which means that the text being edited on it looks as similar as possible to the results users have when publishing it


圖片上傳 http://docs.cksource.com/CKEditor_3.x/Developers_Guide/File_Browser_%28Uploader%29

演示: http://ckeditor.com/demo


CKeditor網頁編輯器與CKfinder上傳整合應用
http://www.minwt.com/?p=2848

要實現ckfinder 線上預覽的功能,似乎要買完整版的才有辦法使用。
在編輯完成後,雖然前端可以看的到,但要編輯時會出現圖片叉燒包,
點它右鍵內容中的網址如下:http://localhost/%22/CKEdit/upload/images/Taiwan.jpg/%22
顯示有%22 真的是一件麻煩的事

參考 http://www.minwt.com/?p=2848裡面的迴響




改使用window.open(),發現ckeditor 的areatext可以抓到值了,只是ckeditor沒辦法show出圖來



可以在線上瀏覽圖片了。





呼叫頁面(php)範例







1.6 版才有的 .prop()


if($("#update_submit").prop("disabled")==false)
$("#update_submit").prop("disabled",true)

1.6以前的.attr可以使用。
但在1.6後使用會有問題。


延伸閱讀:http://blog.xuite.net/vexed/tech/44905647

SUBSTR 截取字串

SUBSTR(str,pos): 由中,選出所有從第位置開始的字元。請注意,這個語法不適用於SQL Server上。

SUBSTR(str,pos,len): 由中的第位置開始,選出接下去的個字元。
參考1
參考2
求平均值Average
語法:AVG([DISTINCT | ALL] n) ->數值
求群組內的n之平均值。

算出資料筆數
語法:count([DISTINCT |ALL] e)->數值
求群組內的資料筆數(列數)

抽出字串左邊部份
LEFT(s,n) ->字串
取出s字串左邊的部份字串 *中文為雙位元組所以有可能會被截斷



去掉開始和結束的空白
$str = trim($str);

2011年12月25日 星期日

禁止輸入非數字(副程式)

function KeyPress(objTR){
//只允許錄入數據字符 0-9 和小數點
// var objTR = document.document.password;               
var txtval= objTR.value;             
var key = event.keyCode;
//alert(key);

if((key < 48||key > 57) && (key < 96 || key >105)&&(key != 46 && key !=8  && key !=17 && key !=9)){
objTR.value = '';
alert('Pleas enter number digits');
}

}

第二個方法:

window.open() 另開小視窗

另開小視窗

按一下這裡開小視窗


置中:

資料來源:http://www.cnblogs.com/shiyu007/archive/2006/12/05/582801.html 


UEM範例




使用navicat連接MYSQL

安裝完navicat,在它的安裝目錄下有個ntunnel_mysql.php
把ntunnel_mysql.php上傳到FTP空間(mysql跟PHP是放在一起的狀況下)。

在 一般(連線內容)底下的
主機名稱或IP位址 填入localhost
PORT:3306
使用者名稱和密碼也需填入

在HTTP(連線內容)底下的
勾選使用HTTP通道
通道位址填入可以連接到ntunnel_mysql.php的網址
並在驗證區填入密碼



2011年12月23日 星期五

爾必達


爾必達(英語:Elpida Memory, Inc.),日本記憶體公司

2011年2月25日,爾必達在台灣證券交易所掛牌發行台灣存託憑證(TDR,臺證所:916665),為該交易所第一個日商公司TDR。
金士頓所使用的 爾必達(Elpida)顆粒

相關新聞:

南科 否認與爾必達合併2011.12.23 03:36 am

2011年12月22日 星期四

SWFUpload 套件

SWFUpload consists of 4 pieces:

  1. Initialization and Settings (JavaScript)

  2. JavaScript library: SWFUpload.js

  3. Flash Control: swfupload.swf

  4. The Event Handlers (JavaScript)



Initialization and Settings

var swfu;
window.onload = function () {
var settings_object = {
upload_url : "http://www.swfupload.org/upload.php",
flash_url : "http://www.swfupload.org/swfupload.swf",
file_size_limit : "20 MB",
button_placeholder_id : "spanSWFUploadButton"
};
swfu = new SWFUpload(settings_object);
};

JavaScript library

Example: Adding SWFUpload.js to a page



The Event Handlers
Example: SWFUpload event handlers and initialization.


// The uploadStart event handler. This function variable is assigned to upload_start_handler in the settings object
var myCustomUploadStartEventHandler = function (file) {
var continue_with_upload;
if (file.name === "the sky is blue") {
continue_with_upload = true;
} else {
continue_with_upload = false;
}
return continue_with_upload;
};

// The uploadSuccess event handler. This function variable is assigned to upload_success_handler in the settings object
var myCustomUploadSuccessEventHandler = function (file, server_data, receivedResponse) {
alert("The file " + file.name + " has been delivered to the server. The server responded with " + server_data); }; // Create the SWFUpload Object
var swfu = new SWFUpload({
upload_url : "http://www.swfupload.org/upload.php",
flash_url : "http://www.swfupload.org/swfupload.swf",
file_size_limit : "200 MB",
upload_start_handler : myCustomUploadStartEventHandler,
upload_success_handler : myCustomUploadSuccessEventHandler }
);


DEMO:
http://demo.swfupload.org/v220/index.htm

switch 接投影機接筆電

Mysql日期時間和時間函數

所有記錄,其date_col的值是在最30天以內:
mysql> SELECT * FROM table 
WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) <= 30; 

TO_DAYS(date)
mysql> SELECT TO_DAYS(950501);
-> 728779

mysql> SELECT TO_DAYS('1997-10-07');
-> 729669

DAYOFWEEK(date)
返回日期date的星期索引(1=星期天,2=星期一, ……7=星期六)。這些索引值對應ODBC標準。
mysql> select DAYOFWEEK('1998-02-03'); 
-> 3 

DAYOFYEAR(date)
返回date在一年中的日數, 在1到366范圍內。
mysql> select DAYOFYEAR('1998-02-03'); 
-> 34

限制在 24小時內:秒數相減小於24小時(86400秒)
((unix_timestamp(NOW())- unix_timestamp(`startTime`)) <'86400')
select unix_timestamp('2008-08-08');           -- 1218124800

限制:一個ip一天只記錄一次點擊物品
$sql="select count(*) as c from web_log where DATE(now())=DATE(time)  and commodity_sn='$sn' and ip='$address'";
 
 $serachWebLogData=lazy_get_line($sql);
 if(! $serachWebLogData['c']>=1){
              //如果沒有資料就可以做插入
              $sql="insert....";

客戶端的IP及瀏覽器

if (!empty($_SERVER['HTTP_CLIENT_IP']))
  $ip=$_SERVER['HTTP_CLIENT_IP'];
 else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
  $ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
 else
    $ip=$_SERVER['REMOTE_ADDR'];


browser()

function browser(){
 $browsers = array("firefox", "msie", "opera", "chrome", "safari",
                            "mozilla", "seamonkey","konqueror", "netscape",
                            "gecko", "navigator", "mosaic", "lynx", "amaya",
                            "omniweb", "avant", "camino", "flock", "aol"); 
   $agent=strtolower($_SERVER["HTTP_USER_AGENT"]);
 
 //echo $browser;
 foreach($browsers as $browser){
  if (preg_match("#($browser)[/ ]?([0-9.]*)#", $agent, $match)){
                $browser_version=$match[1].$match[2];
                break ;
        } 
 }
 
 
 $mobileAgents = array( 
        "iphone", 
        "ipad", 
        "android", 
        "mini", 
        "mobi", 
        "portable", 
        "playstation", 
        "palm", 
        "hiptop", 
        "avantgo", 
        "plucker", 
        "xiino", 
        "blazer", 
        "eclair", 
        "froyo"); 
 $OSName=array('nt 5.1'=>"XP",'nt 5.0'=>'2000','nt 5.1'=>'XP','nt 5.2'=>"Windows Server 2003",'nt 6.0'=>'vista、2008','nt 6.1'=>'Win7,Server 2008 R2','nt 6.2'=>'Windows8');
 if(eregi('nt 5.1',$agent)){
  $browser_os=$OSName['nt 5.1'];
 }else if(eregi('nt 5.0',$agent)){
  $browser_os=$OSName['nt 5.0'];
 }else if(eregi('nt 5.1',$agent)){
  $browser_os=$OSName['nt 5.1'];
 }else if(eregi('nt 5.2',$agent)){
  $browser_os=$OSName['nt 5.2'];
 }else if(eregi('nt 6.0',$browser)){
  $browser_os=$OSName['nt 6.0'];
 }else if(eregi('nt 6.1',$agent)){
  $browser_os=$OSName['nt 6.1'];
 }else if(eregi('nt 6.2',$agent)){
  $browser_os=$OSName['nt 6.2'];
 }else{
  foreach($mobileAgents as $check) {
   if(stripos($agent, $check)) {
    $browser_os=$check;
    break;
   }
  } 
 }
 
 return $browser_version."[{$browser_os}]";
 
 
}

PHPMailer - PHP email class

Software: PHPMailer - PHP email class |
| Version: 2.0.4 |
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
| Info: http://phpmailer.sourceforge.net |
| Support: http://sourceforge.net/projects/phpmailer/ |
| ------------------------------------------------------------------------- |
| Author: Andy Prevost (project admininistrator) |
| Author: Brent R. Matzelle (original founder) |
| Copyright (c) 2004-2007, Andy Prevost. All Rights Reserved. |
| Copyright (c) 2001-2003, Brent R. Matzelle |
| ------------------------------------------------------------------------- |
| License: Distributed under the Lesser General Public License (LGPL) |
| http://www.gnu.org/copyleft/lesser.html |
| This program is distributed in the hope that it will be useful - WITHOUT |
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| FITNESS FOR A PARTICULAR PURPOSE. |
| ------------------------------------------------------------------------- |
| We offer a number of paid services (www.codeworxtech.com): |
| - Web Hosting on highly optimized fast and secure servers |
| - Technology Consulting |
| - Oursourcing (highly qualified programmers and graphic designers)
----------------------------------------------------------------------------|
// 建立 PHPMailer 物件及設定 SMTP 登入資訊
require("../phpMailer/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = "remote.smtp.server"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "me@localhost"; // SMTP username
$mail->Password = "123456"; // SMTP password

$mail->From = "myemail@localhost";
$mail->FromName = "My Name";

// 執行 $mail->AddAddress() 加入收件者,可以多個收件者
$mail->AddAddress("to@email.com","Josh Adams");
$mail->AddAddress("to2@email.com"); // optional name

$mail->AddReplyTo("jyu@aemtechnology.com","AEM");

$mail->WordWrap = 50; // set word wrap

// 執行 $mail->AddAttachment() 加入附件,可以多個附件
$mail->AddAttachment("path_to/file"); // attachment
$mail->AddAttachment("path_to_file2", "INF");

// 電郵內容,以下為發送 HTML 格式的郵件
$mail->IsHTML(true); // send as HTML
$mail->Subject = "testing email";
$mail->Body = "This is the HTML body";
$mail->AltBody = "This is the text-only body";

if(!$mail->Send())
{
echo "Message was not sent 

"; echo "Mailer Error: " . $mail->ErrorInfo; exit; } echo "Message has been sent";



CASE 2 aXXl
$mail             = new PHPMailer(); // defaults to using php "mail()"
$mail->CharSet    = "utf-8";
$mail->From       = 'admin@XX.XX.X.X';
$mail->FromName   = 'AXX';
$subject          = " system email test";
$mail->Subject    = $subject;

$data_user[0]['id']='xx@xx.xxxx';
$data_user[0]['name']='Bau';
$sql="";

$body = "Dear,
please reply to  testing email.";
$data=lazy_get_data($sql);
foreach($data as $value){
$body.=$value['empID'].'gg'.$value['empEmail']."
";
}

//$mail->SingleTo=TRUE; #個人理解,如果cc有多個接收mail只會顯示一個人的
$mail->ClearAddresses(); #由於內文不一樣,$mail->AddAddress 的陣列讓寄信人只寄一個,避免寄給很多人。

// optional, comment out and test
$body = eregi_replace("[\]",'',$body);
$mail->MsgHTML($body);
$mail->Encoding = "base64";

foreach($data_user as $value){

$mail->AddAddress($value['id'], $value['name']);
$mail->IsSMTP();
$mail->SMTPAuth   = false;  
//$mail->Port       = 25;  
//需使用SMTP驗證
//ou$mail->SMTPSecure = "ssl";       
// 利用SSL連線到伺服器

$mail->Host = "mail.global.frontbridge.com";      
//當然啦,信件寄送主機就是GMAIL

//$mail->Port = 465;                   
//指定SMTP port
//$mail->Username = "";  
//MAIL帳號

//$mail->Password = "";
if($debug=='1'){
echo "";
echo $mail->Subject."";
echo $to."[{$to_name}]";
echo $body;

}elseif($debug=='0'){
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
echo $to;
exit;
} else {
//echo "Message sent!";     
sleep(3);     
}

}
}

要注意Gmail 的 SMTP主機固定位址是 smtp.gmail.com,必須使用 465 埠以 SSL 的方式來連線
所以apache需要灌ssl才行。

2011年12月21日 星期三

mail template

有關於 mail裡面放css 需要 下註解,免得收件人看不到正確內容。
範例:

$body=""


參考:

http://www.freegroup.org/2010/11/100-free-html-email-templates-with-psd-sources/

unset( ) 刪除變數

語法 : int unset(mixed var);

說明 :參數 可放入多個參數。

unset()刪除指定的變數,且傳回true。

範例:

$array=array("a"=>"卡卡","b"=>"黃金");
unset($array);
if(isset($array)){
print_r($array);
}else{
echo '沒有變數';
}


unset($a);
unset($b);
等於
unset($a,$b);

COUNT( ) 回傳筆數

SQL COUNT(column_name) Syntax

returns the number of values (NULL values will not be counted) of the specified column

SELECT COUNT(column_name) FROM table_name



The COUNT(*) function returns the number of records in a table:

SELECT COUNT(*) FROM table_name










O_IdOrderDatePrice顧客
120011/11/12100ans
220011/11/12100dce
320011/11/14100abc
420011/11/15100ans


尋找顧客ans購買次數:

SELECT COUNT(顧客) AS CustomerNilsen FROM Orders
WHERE 顧客='ans'