2013年5月20日 星期一

00_ASP_使用CDO發信物件寄信


<%

 

 

DIM ToEmlAddress,FromEmlAddress,MailTitle,MailContext

ToEmlAddress="收信者"
FromEmlAddress="寄信者"

'主旨
MailTitle="發信"
'內文
MailContext="內容"

Set Mail1 = Server.CreateObject("  CDO.Message    ")

'一定要加上這一段,否則如果你的Web Server上有安裝 Outlook 2002 等版本更新了CDOEX.DLL
'ASP中會導致 senduse 的錯誤

Set iConf = CreateObject("CDO.Configuration") Set Flds = iConf.Fields With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "c:\inetpub\mailroot\pickup"
.Update
End With


Mail1.Configuration=iConf
'一定要指明 Encoding 7bits,否則送HTML格式的 email 時,因為編碼的原因,會導致 .jpg .不見
Mail1.BodyPart.ContentTransferEncoding = "7bit"
'如果使用多國語言時,才要設定 Charset
'Mail1.BodyPart.Charset = "big5"
 

Mail1.To = ToEmlAddress
Mail1.From = FromEmlAddress
Mail1.Subject = MailTitle
Mail1.HTMLBody = MailContext '可使育TextBody
Mail1.Send

Set Mail1=Nothing

Set iConf = Nothing

 




參考

Setting the Subject and Message Text Body
http://msdn.microsoft.com/en-us/library/ms526246(v=exchg.10).aspx

2013年5月1日 星期三

00_PHP 檢查日期 function

//===檢查日期 function===V
    function datecheck($ymd,$sep='/'){
    $parts = explode($sep,$ymd);
    $year = $parts[0];
    $month = $parts[1];
    $day = $parts[2];
    
    if(isint($year) && isint($month) && isint($day)){
    if(checkdate($month,$day,$year)) return true;
    else return false;
    }
    else return false;
    }
    
    // [ php/inc/isint.php ] cvs 1.2

    function isint($str){
    $str = (string)$str;
    
    $pos = 0;
    $len = strlen($str);
    for($i=0;$i<$len;$i++){
    if($str[$i]=='0') $pos++;
    else break;
    }
    $str = substr($str,$pos);
    
    $int = (int)$str;
    if($str==(string)$int) return true;
    else return false;
    }
//===檢查日期 function===^



$end_date_ben=trim($_POST["end_date_ben"]);
$end_date_end=trim($_POST["end_date_end"]);

if (strlen($end_date_ben)>0 OR strlen($end_date_end)>0 ){
    
     //開始日期
      if (strlen($end_date_ben)>0){

            if(datecheck($end_date_ben)){
                  //echo $end_date_ben.' 是合法日期';
             }else{
                   echo "開始日期".$end_date_ben.'不是合法日期';
                   exit;
             }

       }

     //結束日期
    if (strlen($end_date_end)>0){   

            if(datecheck($end_date_end)){
               //echo $end_date_ben.' 是合法日期';
             }else{
                 echo "結束日期".$end_date_ben.'不是合法日期';
                 exit;
             }
    }
   $Show_Query_Meg="到期日期『".$end_date_ben."~".$end_date_end."』相關資料";

 }

02_Javascript 語法備忘錄

Javascript 常用的陣列(Array)操作大全



//下拉選單帶入url參數

<SELECT size=1 name='event_type_co' onChange="onSelected_Form(this.value);">
<?php
   $result = mysql_query($SQL);
 while($row = mysql__fetch_array($result)){
    echo trim("<OPTION value=".$row['job_type_id'].">".trim($row['code_name']))."</OPTION>\n");
 }
?>
</SELECT>


<!------------//下拉選單帶入url參數//------------>
<script type="text/javascript" language="javascript">
<!--
function onSelected_Form(value){
 var ls_url="";
 ls_url="?from_type="+value;
 window.location=ls_url;
-->
}
</script>
<!------------//下拉選單帶入url參數//------------>


//檢驗輸入文字

<textarea id="autobi" name="autobi" cols="60" rows="5" onKeyUp="fun_replace(this.value);" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/^\[+|\]+$|[\[\]\x22\x27]+/ig,'’'));">
</textarea>

<!------------//檢驗輸入文字//------------>
<script>
function fun_replace(value)
{
<!--
// alert(value);
var str_check;
str_check="電算";
var int_pos=0;
int_pos=value.indexOf(str_check);
if (int_pos>0){
 alert(int_pos);
 value=value.replace('電算','電子計算機中心');
 document.frm_1.autobi.value=value;
}
}
-->
</script>
<!------------//檢驗輸入文字//------------>
 


//Form 送出檢查

<form action='CheckUser.php' name='CheckUser' method='post' onSubmit="return Login_Check(this)">
帳號:<input id="UserID" name="UserID" size="5" type="text" value=""/>
密碼:<input id="UserPWD" name="UserPWD" size="10" type="password" value=""/>
<input type="submit" name="submit" id="submit" value="登入" />
</form>

<!------------//送出檢查//------------>
<SCRIPT language=JavaScript>
<!--
function Login_Check(theForm)
{
if (theForm.UserID.value == "")
{
alert("請在「ID」欄位輸入資料。");
theForm.UserID.focus();
return (false);
}
if (theForm.UserID.value.length > 8)
{
alert("在「ID」欄位,最多請輸入 8 的字元。");
theForm.UserID.focus();
return (false);
}
if (theForm.UserPWD.value == "")
{
alert("請在「密碼」欄位輸入資料。");
theForm.UserPWD.focus();
return (false);
}
return (true);
}
-->
</SCRIPT>
<!------------//送出檢查//------------>

00_php語法備忘

PHP語法備忘


//起動session
session_start();

//使用者
$user_no=$_SESSION["idno"];
$user_name=$_SESSION["ch_name"];
$user_dept=$_SESSION["dept"];

//資料庫主機-連結:DB Server
include("DBServer_Con.php");



//取得變數
$get_smye=trim($_GET["smye"]);
$post_smye=trim($_POST["smye"]);


//[文字類]

若資料庫碼為big5 網頁utf-8 則須轉碼

$str_cname=iconv("big5","Utf-8",trim($row['chinese_name']));
$str_cname=iconv("utf-8","big5",$str_count_result);

//substr字串if (substr($str_UserID,0,1)=="R" || substr($str_UserID,0,1)=="D" ){
}else{
echo "<meta http-equiv=REFRESH CONTENT=0;url='Fun_ShowError.php?meg_txt=限碩士。'>";
exit;
}




//傳資料編碼解碼
$str_idno=base64_encode($idno);
$url=thisprg.php?idno=$str_idno;

$get_idno=trim($_GET["idno"]);
$get_idno=base64_decode($get_idno);



//邏輯判斷

if ($exam_kind=="2"){
}


//[資料庫]

//方式一
$SQL_Check="select count(*) as tota
                           from sch_books
                         where smye=$get_smye";
$result = sybase_query($SQL_Check,$DBCon);

if (!$result) die ("無法查詢資料(sch_books)");
$total = sybase_num_rows($result);
if ($total == 0){
 echo "無資料<BR><BR>";
 exit;
}

$row = sybase_fetch_array($result);
$int_check=$row["tota"];


//方式二
$SQL_Check="select *
                           from sch_books
                        where smye=$get_smye";
$result = sybase_query($SQL_Check,$DBCon);
while($row = sybase_fetch_array($result)){
    $book_name=$row["book_name"];
}

//四捨五入

EX 除結果是 22.2336 ==>22.23
$tota_dyu_sco=number_format($sum_dept_sco/$tota_pri,2,'.','');

EX 除結果是 22.2336 ==>22
$tota_dyu_sco=number_format($sum_dept_sco/$tota_pri,0,'.','');

//加入檔案
include('page_footer.php')