/********************************************************
* @function replace ข้อความในอีเมล์ template ที่ส่งมา
* $strMailTemplate : string ที่ส่งเข้ามา
* $arrFormValue : ค่าที่จะ replace เป็นค่า array
********************************************************/
function createEmailMessage( $strMailTemplate="", $arrFormValue="",$strJoinMsg="" )
{
$arrMessageEmailReplace = $arrFormValue ;
$m_strMessageEmail = $strMailTemplate ;
while( list( $key, $val ) = each( $arrMessageEmailReplace ) )
{
$m_strMessageEmail = str_replace( "%%$key%%", $val , $m_strMessageEmail ) ;
}
return $m_strMessageEmail ;
}
function createEmailMessageFile( $strFileTemplate="", $arrFormValue="",$strJoinMsg="" )
{
$m_arrMsg = file($strFileTemplate) ;
$m_strMessageEmail = join($strJoinMsg,$m_arrMsg) ;
return createEmailMessage( $m_strMessageEmail, $arrFormValue) ;
}
function createEmailHeaders( $strEmailFrom, $strEmailCc="", $strEmailBcc="", $strEmailReturn="", $strModeHtml=false)
{
# Start Build Headers Email
$m_strHeadersEmail .= "From: " . $strEmailFrom . "\n" ;
if ( !empty( $strEmailReturn ) )
{
$m_strHeadersEmail .= "Return-Path: <". $strEmailReturn . ">\n" ;
}
if ( !empty( $strEmailCc ) )
{
$m_strHeadersEmail .= "Cc: " . $strEmailCc . "\n" ;
}
if ( !empty( $strEmailBcc ) )
{
$m_strHeadersEmail .= "Bcc: ". $strEmailBcc ."\n" ;
}
$m_strHeadersEmail .= "Mime-Version: 1.0\n" ;
if($strModeHtml !== false)
{
$m_strHeadersEmail .= "Content-Type: text/html; charset=tis-620\n" ;
}
else
{
$m_strHeadersEmail .= "Content-Type: text/plain; charset=tis-620\n" ;
}
$m_strHeadersEmail .= "Content-Transfer-Encoding: 7bit\n\n" ;
# End Build Headers Email
return $m_strHeadersEmail ;
}
# function send mail
function sendMail( $strEmailTo, $strEmailSubject, $strEmailMessage, $strEmailHeaders )
{
$strEmailSubject = EncodeHeader($strEmailSubject) ;
if( mail( $strEmailTo, $strEmailSubject, $strEmailMessage, $strEmailHeaders ) )
{
return true ;
}
else
{
return false ;
}
}
function createEmailReadySend($arrTemplate,$arrFormValue)
{
global $cfg ;
### เช็คการส่ง email ที่ซ้ำ ให้ส่งแค่ครั้งเดียว กรณี ที่ reseller เป็น jotdomain ###
$strEmailResell =$arrFormValue["EmailReseller"] ;
$arrEmail["EmailReseller"] =$strEmailResell ;
$arrEmail["EmailBcc"]=$cfg["MailBcc"] ;
$arrEmailBccResell=array_unique($arrEmail) ;
$strEmailBcc=$arrEmailBccResell["EmailBcc"] ;
$strEmailReseller=$arrEmailBccResell["EmailReseller"] ;
if ( (!empty($strEmailBcc)) && (!empty($strEmailReseller)) )
{
$strEmailBccReseller=$strEmailBcc.",".$strEmailReseller ;
}
else
{
if($strEmailBcc !="")
{
$strEmailBccReseller=$strEmailBcc ;
}
else
{
$strEmailBccReseller=$strEmailReseller ;
}
}
###################################################
if(is_array($arrTemplate) && is_array($arrFormValue) )
{
$strMessageMail = $arrTemplate["mail_message"] ;
$strSubjectMail = $arrTemplate["mail_subject"] ;
$strSenderMail = $arrTemplate["mail_sender"] ;
$strMailTo = $arrTemplate["mail_to"] ;
$strMailCc = $arrTemplate["mail_cc"] ;
$strMailBcc = $strEmailBccReseller ;
$strEmailSubject = createEmailMessage( $strSubjectMail, $arrFormValue,"\n" );
$strEmailFrom = createEmailMessage( $strSenderMail, $arrFormValue,"\n" );
$strEmailCc = createEmailMessage( $strMailCc, $arrFormValue,"\n" );
//$strEmailBcc = createEmailMessage( $strMailBcc, $arrFormValue,"\n" );
$strEmailBcc = $strEmailBccReseller ;
//$strEmailReturn = $cfg["MailReturnPath"] ;
$strEmailReturn =$arrTemplate["mail_returnpath"] ; // edit by pui ให้ return email ไปหาเจ้าของ reseller แต่ละคน
$strEmailTo = createEmailMessage( $strMailTo, $arrFormValue,"\n" ) ;
$strEmailMessage = createEmailMessage( $strMessageMail, $arrFormValue,"\n" );
$strEmailHeaders = createEmailHeaders( $strEmailFrom, $strEmailCc, $strEmailBcc, $strEmailReturn);
// echo "To=>$strEmailTo
From=>$strEmailFrom
Cc=>$strEmailCc
Bcc=>$strEmailBcc
Return=>$strEmailReturn
$strEmailSubject
$strEmailMessage
" ;
//echo "$strEmailSubject
$strEmailMessage
$strEmailHeaders
" ;
sendMail( $strEmailTo, $strEmailSubject, $strEmailMessage, $strEmailHeaders ) ;
}
return false ;
}
/********************************************************
* @function getValueMailNewOrder : gen arrFormValue คืนค่าเป็น array รายละเอียดของโดเมน
* param : $arrOrderID : array order id
* return : $arrFormValue : array
********************************************************/
function getValueMailNewOrder($arrOrderID)
{
global $conn ,$cfg ,$objOrderManage,$_SESSION ;
//$strChildID=$_SESSION["sess_profile"]["UserID"] ;
$strChildID=$_SESSION["sess_profile"]["ChildID"] ;
if(!empty($arrOrderID))
{
for($i=0;$iExecute("$sql") ;
if($recordset)
{
if($recordset->RecordCount () >0)
{
$DomainID[$i] = $recordset->fields["DomainID"] ;
$parent_id = $recordset->fields["parent_id"] ;
### add by pui 28/07/2548
$user_id = $recordset->fields["user_id"] ;
$Status = $recordset->fields["Status"] ;
$VAT = $recordset->fields["VAT"] ;
$Type = $recordset->fields["Type"] ;
$Date = $recordset->fields["Date"] ;
$DomainName[$i] = $recordset->fields["DomainName"] ;
$DomainPeriod[$i] = $recordset->fields["DomainPeriod"] ;
$DateStart = $recordset->fields["DateStart"] ;
$DateExpire = $recordset->fields["DateExpire"] ;
$Password = $recordset->fields["Password"] ;
$RegistrantID = $recordset->fields["RegistrantID"] ;
$AdminID = $recordset->fields["AdminID"] ;
$TechID = $recordset->fields["TechID"] ;
$AuxBillingID = $recordset->fields["AuxBillingID"] ;
$DNSID = $recordset->fields["DNSID"] ;
$ProfileID = $recordset->fields["ProfileID"] ;
$ProfileEmailAddress = $recordset->fields["ProfileEmailAddress"] ;
$user_name = $recordset->fields["user_name"] ;
$pass_word = $recordset->fields["pass_word"] ;
}else
{
return false ;
}
}else
{
return false ;
}
}//end for
//======== add by pui 21/07/2004============//
if (($strChildID=="0") || ($strChildID==""))
{
$strChildID="1" ;
}
$sqlSelect="SELECT * FROM cp_parentchild pr
INNER JOIN cp_profile p ON pr.profile_id=p.ProfileID
WHERE pr.user_id='$strChildID' " ;
$arrPerApprove = getRow($sqlSelect) ;
// $arrFormValue["FirstNameApprove"]=$arrPerApprove["ProfileFirstName"] ;
$arrFormValue["FirstNameApprove"]="" ;
$arrFormValue["EmailReseller"]=$arrPerApprove["ProfileEmailAddress"] ;
//=======================================//
$strList = "";
$priceSum = 0 ;
for($j=0; $jSelectDataProfile($table,"ProfileID = '$ProfileID' AND profile_type='Profile' ") ;
$arrProfile = getRow($strSQLProfile) ;
$strSQLRegistrant = $objOrderManage->SelectDataProfile($table,"ProfileID = '$RegistrantID' AND profile_type='Registrant' ") ;
$arrRegistrant = getRow( $strSQLRegistrant) ;// function getrow in file inc.global.php
$strSQLAdmin = $objOrderManage->SelectDataProfile($table,"ProfileID = '$AdminID' AND profile_type='Admin' ") ;
$arrAdmin=getRow( $strSQLAdmin) ;
$strSQLTech = $objOrderManage->SelectDataProfile($table,"ProfileID = '$TechID' AND profile_type='Tech' ") ;
$arrTech=getRow( $strSQLTech) ;
$strSQLAuxBilling = $objOrderManage->SelectDataProfile($table," ProfileID = '$AuxBillingID' AND profile_type='AuxBilling' ") ;
$arrAuxBilling =getRow( $strSQLAuxBilling) ;
$arrFormValue["ListDetailOrder"] = "$strList" ;
$arrFormValue["PriceTotal"] = number_format($priceTotal,2) ;
$arrFormValue["ProfileEmail"] = $ProfileEmailAddress ;
$arrFormValue["domainname"] = $strDomainName ;
$arrFormValue["VAT"] = $strVAT ;
$arrFormValue["pwdDomain"] = $Password ;
$arrFormValue["yearDomain"] = $DomainPeriod[0] ;
$arrFormValue["username"] = $user_name ;
$arrFormValue["pwdAccount"] = $pass_word ;
######################################################################
$arrFormValue["ProfileOrganizationName"] = $arrProfile["ProfileOrganizationName"] ;
$arrFormValue["ProfileFirstName"] = $arrProfile["ProfileFirstName"] ;
$arrFormValue["ProfileLastName"] = $arrProfile["ProfileLastName"] ;
$arrFormValue["ProfileAddress1"] = $arrProfile["ProfileAddress1"] ;
$arrFormValue["ProfileAddress2"] = $arrProfile["ProfileAddress2"] ;
$arrFormValue["ProfileCity"] = $arrProfile["ProfileCity"] ;
$arrFormValue["ProfileStateProvince"] = $arrProfile["ProfileStateProvince"] ;
$arrFormValue["ProfilePostalCode"] = $arrProfile["ProfilePostalCode"] ;
$arrFormValue["ProfileCountry"] = $arrProfile["ProfileCountry"] ;
$arrFormValue["ProfilePhone"] = $arrProfile["ProfilePhone"] ;
$arrFormValue["ProfileFax"] = $arrProfile["ProfileFax"] ;
$arrFormValue["ProfileEmailAddress"] = $arrProfile["ProfileEmailAddress"] ;
######################################################################
$arrFormValue["RegisOrganizationName"] = $arrRegistrant["ProfileOrganizationName"] ;
$arrFormValue["RegisFirstName"] = $arrRegistrant["ProfileFirstName"] ;
$arrFormValue["RegisLastName"] = $arrRegistrant["ProfileLastName"] ;
$arrFormValue["RegisAddress1"] = $arrRegistrant["ProfileAddress1"] ;
$arrFormValue["RegisAddress2"] = $arrRegistrant["ProfileAddress2"] ;
$arrFormValue["RegisCity"] = $arrRegistrant["ProfileCity"] ;
$arrFormValue["RegisStateProvince"] = $arrRegistrant["ProfileStateProvince"] ;
$arrFormValue["RegisPostalCode"] = $arrRegistrant["ProfilePostalCode"] ;
$arrFormValue["RegisCountry"] = $arrRegistrant["ProfileCountry"] ;
$arrFormValue["RegisPhone"] = $arrRegistrant["ProfilePhone"] ;
$arrFormValue["RegisFax"] = $arrRegistrant["ProfileFax"] ;
$arrFormValue["RegisEmailAddress"] = $arrRegistrant["ProfileEmailAddress"] ;
######################################################################
$arrFormValue["AdminOrganizationName"] = $arrAdmin["ProfileOrganizationName"] ;
$arrFormValue["AdminFirstName"] = $arrAdmin["ProfileFirstName"] ;
$arrFormValue["AdminLastName"] = $arrAdmin["ProfileLastName"] ;
$arrFormValue["AdminAddress1"] = $arrAdmin["ProfileAddress1"] ;
$arrFormValue["AdminAddress2"] = $arrAdmin["ProfileAddress2"] ;
$arrFormValue["AdminCity"] = $arrAdmin["ProfileCity"] ;
$arrFormValue["AdminStateProvince"] = $arrAdmin["ProfileStateProvince"] ;
$arrFormValue["AdminPostalCode"] = $arrAdmin["ProfilePostalCode"] ;
$arrFormValue["AdminCountry"] = $arrAdmin["ProfileCountry"] ;
$arrFormValue["AdminPhone"] = $arrAdmin["ProfilePhone"] ;
$arrFormValue["AdminFax"] = $arrAdmin["ProfileFax"] ;
$arrFormValue["AdminEmailAddress"] = $arrAdmin["ProfileEmailAddress"] ;
######################################################################
$arrFormValue["TechOrganizationName"] = $arrTech["ProfileOrganizationName"] ;
$arrFormValue["TechFirstName"] = $arrTech["ProfileFirstName"] ;
$arrFormValue["TechLastName"] = $arrTech["ProfileLastName"] ;
$arrFormValue["TechAddress1"] = $arrTech["ProfileAddress1"] ;
$arrFormValue["TechAddress2"] = $arrTech["ProfileAddress2"] ;
$arrFormValue["TechCity"] = $arrTech["ProfileCity"] ;
$arrFormValue["TechStateProvince"] = $arrTech["ProfileStateProvince"] ;
$arrFormValue["TechPostalCode"] = $arrTech["ProfilePostalCode"] ;
$arrFormValue["TechCountry"] = $arrTech["ProfileCountry"] ;
$arrFormValue["TechPhone"] = $arrTech["ProfilePhone"] ;
$arrFormValue["TechFax"] = $arrTech["ProfileFax"] ;
$arrFormValue["TechEmailAddress"] = $arrTech["ProfileEmailAddress"] ;
######################################################################
$arrFormValue["AuxOrganizationName"] = $arrAuxBilling["ProfileOrganizationName"] ;
$arrFormValue["AuxFirstName"] = $arrAuxBilling["ProfileFirstName"] ;
$arrFormValue["AuxLastName"] = $arrAuxBilling["ProfileLastName"] ;
$arrFormValue["AuxAddress1"] = $arrAuxBilling["ProfileAddress1"] ;
$arrFormValue["AuxAddress2"] = $arrAuxBilling["ProfileAddress2"] ;
$arrFormValue["AuxCity"] = $arrAuxBilling["ProfileCity"] ;
$arrFormValue["AuxStateProvince"] = $arrAuxBilling["ProfileStateProvince"] ;
$arrFormValue["AuxPostalCode"] = $arrAuxBilling["ProfilePostalCode"] ;
$arrFormValue["AuxCountry"] = $arrAuxBilling["ProfileCountry"] ;
$arrFormValue["AuxPhone"] = $arrAuxBilling["ProfilePhone"] ;
$arrFormValue["AuxFax"] = $arrAuxBilling["ProfileFax"] ;
$arrFormValue["AuxEmailAddress"] = $arrAuxBilling["ProfileEmailAddress"] ;
return $arrFormValue;
}
return false ;
}//end function
/********************************************************
* @function getValueMailNewOrder : gen arrFormValue คืนค่าเป็น array รายละเอียดของโดเมน
* param : $arrOrderID : array order id
* return : $arrFormValue : array
********************************************************/
function genValueModifyMail($arrDNS, $domainID)
{
global $cfg ,$cfg_h ,$objOrderManage,$_SESSION ,$function ;
// $function = class.mydomain.php
$strChildID=$_SESSION["sess_profile"]["UserID"] ;
/*if($_SESSION["sess_profile"]["from_sysbase"]=="host2")
{
$conn = chooseConnectDB($cfg_h) ;
}
else
{
$conn = chooseConnectDB($cfg) ;
}
*/
// var_dump($_SESSION["sess_profile"]["from_sysbase"]) ;
//session_unregister("sess_profile") ;
if(!empty($_SESSION["sess_profile"]))
{
if($_SESSION["sess_profile"]["from_sysbase"]=="host2")
{
$conn = chooseConnectDB($cfg_h) ;
##----------- Data DB Host2 ----------------##
if(!empty($arrDNS) && !empty($domainID) )
{
$arrFormValue["DNS1"] = $arrDNS[1] ;
$arrFormValue["DNS2"] = $arrDNS[2] ;
$arrFormValue["DNS3"] = $arrDNS[3] ;
$arrFormValue["DNS4"] = $arrDNS[4] ;
$sql = "SELECT * FROM tbl_orders ord , tbl_order_detail ordT ,tbl_member mem
WHERE ord.order_ID=ordT.order_ID AND ord.member_ID=mem.member_ID
AND ordT.order_detail_ID ='$domainID' ";
$recordset = $conn->Execute("$sql") ;
if($recordset)
{
if($recordset->RecordCount () >0)
{
$DomainID = $recordset->fields["order_detail_ID"] ;
$Status = $recordset->fields["status_Order"] ;
$VAT = $recordset->fields["need_Vat"] ;
$Type = $recordset->fields["type_order"] ;
$Date = $recordset->fields["Date"] ;
$DomainName = $recordset->fields["product_detail"] ;
$DomainPeriod = $recordset->fields["term_payment"] ;
$DateStart = $recordset->fields["activate_Date"] ;
$DateExpire = $recordset->fields["expire_Date"] ;
$Password = $recordset->fields["panel_password"] ;
$ProfileID = $recordset->fields["member_ID"] ;
$ProfileEmailAddress = $recordset->fields["member_Email"] ;
//=======================================//
$arrFormValue["EmailReseller"] = "Jotdomain.com" ;
$arrFormValue["domainname"] = $DomainName;
$arrFormValue["ProfileEmail"] = $ProfileEmailAddress ;
$arrFormValue["DateChange"] = date("F j,Y, h:i a") ;//January 5, 2004, 4:44 pm
return $arrFormValue;
} // end $RecordCount ()
}// end $recordset
}//end $arrDNS
}
else
{
$conn = chooseConnectDB($cfg) ;
##----------- Data DB Jotdomain ----------------##
if(!empty($arrDNS) && !empty($domainID) )
{
$arrFormValue["DNS1"] = $arrDNS[1] ;
$arrFormValue["DNS2"] = $arrDNS[2] ;
$arrFormValue["DNS3"] = $arrDNS[3] ;
$arrFormValue["DNS4"] = $arrDNS[4] ;
$strTable = "cp_orders O , cp_domain D , cp_parentchild PC ,cp_profile P ";
$sql = "SELECT * FROM $strTable
WHERE (O.DomainID ='$domainID') AND (O.DomainID = D.DomainID)
AND (O.parent_id = PC.parent_id) AND (PC.profile_id = P.ProfileID)
GROUP BY OrderID ";
$recordset = $conn->Execute("$sql") ;
if($recordset)
{
if($recordset->RecordCount () >0)
{
$DomainID = $recordset->fields["DomainID"] ;
$parent_id = $recordset->fields["parent_id"] ;
$Status = $recordset->fields["Status"] ;
$VAT = $recordset->fields["VAT"] ;
$Type = $recordset->fields["Type"] ;
$Date = $recordset->fields["Date"] ;
$DomainName = $recordset->fields["DomainName"] ;
$DomainPeriod = $recordset->fields["DomainPeriod"] ;
$DateStart = $recordset->fields["DateStart"] ;
$DateExpire = $recordset->fields["DateExpire"] ;
$RegistrantID = $recordset->fields["RegistrantID"] ;
$AdminID = $recordset->fields["AdminID"] ;
$TechID = $recordset->fields["TechID"] ;
$AuxBillingID = $recordset->fields["AuxBillingID"] ;
$DNSID = $recordset->fields["DNSID"] ;
$Password = $recordset->fields["Password"] ;
$DomainPeriod = $recordset->fields["DomainPeriod"] ;
$ProfileID = $recordset->fields["ProfileID"] ;
$ProfileEmailAddress = $recordset->fields["ProfileEmailAddress"] ;
}
}
//======== add by pui 21/07/2004============//
if($strChildID=="0")
{
$strChildID="1" ;
}
$sqlSelect="SELECT * FROM cp_parentchild pr
INNER JOIN cp_profile p ON pr.profile_id=p.ProfileID
WHERE pr.user_id='$strChildID' " ;
$arrPerApprove = getRow($sqlSelect) ;
$arrFormValue["EmailReseller"]=$arrPerApprove["ProfileEmailAddress"] ;
//=======================================//
$arrFormValue["domainname"] = $DomainName;
$arrFormValue["ProfileEmail"] = $ProfileEmailAddress ;
$arrFormValue["DateChange"] = date("F j,Y, h:i a") ;//January 5, 2004, 4:44 pm
return $arrFormValue;
}
}
}
else
{
mail("pui@hostpacific.com","Empty session modify DNS" ,"empty session value==>$domainID
".$_SESSION["sess_profile"]["from_sysbase"],"From:JotDomain system") ;
return false ;
}
return false ;
}//end function
/********************************************************
* @function getValueMailNewOrder : gen arrFormValue คืนค่าเป็น array รายละเอียดของโดเมน
* param : $arrOrderID : array order id
* return : $arrFormValue : array
********************************************************/
function genValueRedirectMail($Address, $domainID)
{
global $conn ,$cfg ,$objOrderManage ;
if(!empty($Address) && !empty($domainID) )
{
$strTable = "cp_orders O , cp_domain D , cp_parentchild PC ,cp_profile P ";
$sql = "SELECT * FROM $strTable
WHERE (O.DomainID ='$domainID') AND (O.DomainID = D.DomainID)
AND (O.parent_id = PC.parent_id) AND (PC.profile_id = P.ProfileID)
GROUP BY OrderID ";
$recordset = $conn->Execute("$sql") ;
if($recordset)
{
if($recordset->RecordCount () >0)
{
$DomainID = $recordset->fields["DomainID"] ;
$parent_id = $recordset->fields["parent_id"] ;
$Status = $recordset->fields["Status"] ;
$VAT = $recordset->fields["VAT"] ;
$Type = $recordset->fields["Type"] ;
$Date = $recordset->fields["Date"] ;
$DomainName = $recordset->fields["DomainName"] ;
$DomainPeriod = $recordset->fields["DomainPeriod"] ;
$DateStart = $recordset->fields["DateStart"] ;
$DateExpire = $recordset->fields["DateExpire"] ;
$RegistrantID = $recordset->fields["RegistrantID"] ;
$AdminID = $recordset->fields["AdminID"] ;
$TechID = $recordset->fields["TechID"] ;
$AuxBillingID = $recordset->fields["AuxBillingID"] ;
$DNSID = $recordset->fields["DNSID"] ;
$Password = $recordset->fields["Password"] ;
$DomainPeriod = $recordset->fields["DomainPeriod"] ;
$ProfileID = $recordset->fields["ProfileID"] ;
$ProfileEmailAddress = $recordset->fields["ProfileEmailAddress"] ;
}
}
$arrFormValue["domainname"] = $DomainName;
$arrFormValue["ProfileEmail"] = $ProfileEmailAddress ;
$arrFormValue["redirectURL"] = $Address ;
$arrFormValue["DateChange"] = date("F j,Y, h:i a") ;//January 5, 2004, 4:44 pm
return $arrFormValue;
}
return false ;
}//end function
/********************************************************
* @function getValueForgetPwd : gen arrFormValue คืนค่าเป็น array รายละเอียดของโดเมน
* param : $userName : username เป็น domain หรือ accountname
* param : $typeUser : username เป็น domain หรือ user
* return : $arrFormValue : array
********************************************************/
function genValueForgetPwd($userName, $typeUser)
{
global $conn ,$cfg ,$objOrderManage ;
if(!empty($userName) && !empty($typeUser) )
{
if($typeUser == "domain")
{
$sql = "SELECT * FROM cp_domain dm , cp_orders od, cp_parentchild pr , cp_user u , cp_profile po
WHERE (dm.DomainName='$userName') AND
(dm.DomainID = od.DomainID) AND
(od.Status = 'success') AND
(od.parent_id = pr.parent_id) AND
(pr.user_id = u.user_id) AND
(pr.profile_id = po.ProfileID) GROUP BY pr.profile_id";
}
else
{
$sql = "SELECT * FROM cp_user u , cp_parentchild pr ,cp_profile po
WHERE (user_name='$userName') AND
(pr.user_id = u.user_id) AND
(pr.profile_id = po.ProfileID) GROUP BY pr.profile_id" ;
}
$recordset = $conn->Execute("$sql") ;
if($recordset)
{
if($recordset->RecordCount () >0)
{
if($typeUser == "domain")
{
$Password = $recordset->fields["Password"] ;
}
else
{
$Password = $recordset->fields["pass_word"] ;
}
$ProfileEmailAddress = $recordset->fields["ProfileEmailAddress"] ;
$UserID = $recordset->fields["user_id"] ;
$childID = $recordset->fields["child_id"] ;
}
else
{
return false ;
}
}
$arrFormValue["UserID"] = $UserID ;
$arrFormValue["childID"] = $childID ;
$arrFormValue["ProfileEmail"] = $ProfileEmailAddress ;
$arrFormValue["DateChange"] = date("F j,Y, h:i a") ;//January 5, 2004, 4:44 pm
if($typeUser == "domain")
{
$arrFormValue["domainname"] = $userName ;
$arrFormValue["pwdDomain"] = $Password ;
}
else
{
$arrFormValue["userName"] = $userName ;
$arrFormValue["pwdAccount"] = $Password ;
}
return $arrFormValue;
}
return false ;
}//end function
//==============================================================//
function sendMailTransfer($status, $orderID)
{
global $objMailTemplate ,$cfg ;
if($status =="success")
{
$intTemplateID = $cfg["template"]["transfer_success"];
}
elseif($status =="error")
{
$intTemplateID = $cfg["template"]["transfer_error"];
}
$arrTemplate = $objMailTemplate->getMailTemplate($intTemplateID,$ResellerID) ;
$arrOrder_id[] = $orderID ;
// set array value replace email //
$arrFormValue = getValueMailNewOrder($arrOrder_id) ;
// send email //
createEmailReadySend($arrTemplate,$arrFormValue) ;
}//end function
//=============================================================//
function getValueMailAlertDue($strOrderID)
{
global $conn ,$cfg ,$objOrderManage,$_SESSION ;
$strChildID=$_SESSION["sess_profile"]["UserID"] ;
if(!empty($strOrderID))
{
//$intOrderID = $arrOrderID[$i] ;
$strTable = "cp_orders O , cp_domain D , cp_parentchild PC ,cp_profile P , cp_user U ";
$sql = "SELECT * FROM $strTable
WHERE (O.OrderID='$strOrderID') AND (O.DomainID = D.DomainID)
AND (O.parent_id = PC.parent_id) AND (PC.profile_id = P.ProfileID)
AND (PC.user_id = U.user_id) GROUP BY OrderID " ;
//echo "$sql
" ;
$recordset = $conn->Execute("$sql") ;
if($recordset)
{
if($recordset->RecordCount () >0)
{
$DomainID[$i] = $recordset->fields["DomainID"] ;
$parent_id = $recordset->fields["parent_id"] ;
$child_id = $recordset->fields["child_id"] ;
$Status = $recordset->fields["Status"] ;
$VAT = $recordset->fields["VAT"] ;
$Type = $recordset->fields["Type"] ;
$Date = $recordset->fields["Date"] ;
$DomainName = $recordset->fields["DomainName"] ;
$DomainPeriod = "1" ;
$DateStart = $recordset->fields["DateStart"] ;
$DateExpire = $recordset->fields["DateExpire"] ;
$Password = $recordset->fields["Password"] ;
$RegistrantID = $recordset->fields["RegistrantID"] ;
$AdminID = $recordset->fields["AdminID"] ;
$TechID = $recordset->fields["TechID"] ;
$AuxBillingID = $recordset->fields["AuxBillingID"] ;
$DNSID = $recordset->fields["DNSID"] ;
$ProfileID = $recordset->fields["ProfileID"] ;
$ProfileEmailAddress = $recordset->fields["ProfileEmailAddress"] ;
$user_name = $recordset->fields["user_name"] ;
$pass_word = $recordset->fields["pass_word"] ;
// ============== check ว่า domain นี้คิด vat หรือไม่ =================//
## กรณีเป็น addsdomain.com คิด vat ทุกโดเมน ##
$priceSum = "495" ;
if($VAT == "yes")
{
$priceTotal = $priceSum * (($cfg["VAT"]/100)+1) ;
$strVAT = "รวม VAT ". $cfg["VAT"] ."% แล้ว" ;
}
else
{
if($child_id==6)
{
$priceTotal = $priceSum * (($cfg["VAT"]/100)+1) ;
$strVAT = "รวม VAT ". $cfg["VAT"] ."% แล้ว" ;
}
else
{
$priceTotal = $priceSum ;
$strVAT = "ไม่เอา VAT " ;
}
}
//============================================================//
//======== add by pui 21/07/2004============//
if (($strChildID=="0") || ($strChildID==""))
{
$strChildID="1" ;
}
//=======================================//
$sqlSelect="SELECT * FROM cp_parentchild pr
INNER JOIN cp_profile p ON pr.profile_id=p.ProfileID
WHERE pr.user_id='$strChildID' " ;
$arrPerApprove = getRow($sqlSelect) ;
$arrFormValue["FirstNameApprove"]=$arrPerApprove["ProfileFirstName"] ;
$arrFormValue["EmailReseller"]=$arrPerApprove["ProfileEmailAddress"] ;
//=======================================//
$arrFormValue["child_id"] = $child_id ;
$arrFormValue["PriceTotal"] = number_format($priceTotal,2) ;
$arrFormValue["ProfileEmail"] = $ProfileEmailAddress ;
$arrFormValue["domainname"] = $DomainName ;
$arrFormValue["VAT"] = $strVAT ;
//var_dump($arrFormValue) ;
return $arrFormValue;
}// end record count
}// end record
} // end empty($strOrderID)
return false ;
}//end function
//=======================================================//
/*function getValueMailAlertDue_OLD($arrOrderID)
{
global $conn ,$cfg ,$objOrderManage,$_SESSION ;
$strChildID=$_SESSION["sess_profile"]["UserID"] ;
if(!empty($arrOrderID))
{
for($i=0;$iExecute("$sql") ;
if($recordset)
{
if($recordset->RecordCount () >0)
{
$DomainID[$i] = $recordset->fields["DomainID"] ;
$parent_id = $recordset->fields["parent_id"] ;
$Status = $recordset->fields["Status"] ;
$VAT = $recordset->fields["VAT"] ;
$Type = $recordset->fields["Type"] ;
$Date = $recordset->fields["Date"] ;
$DomainName[$i] = $recordset->fields["DomainName"] ;
$DomainPeriod[$i] = "1" ;
$DateStart = $recordset->fields["DateStart"] ;
$DateExpire = $recordset->fields["DateExpire"] ;
$Password = $recordset->fields["Password"] ;
$RegistrantID = $recordset->fields["RegistrantID"] ;
$AdminID = $recordset->fields["AdminID"] ;
$TechID = $recordset->fields["TechID"] ;
$AuxBillingID = $recordset->fields["AuxBillingID"] ;
$DNSID = $recordset->fields["DNSID"] ;
$ProfileID = $recordset->fields["ProfileID"] ;
$ProfileEmailAddress = $recordset->fields["ProfileEmailAddress"] ;
$user_name = $recordset->fields["user_name"] ;
$pass_word = $recordset->fields["pass_word"] ;
}else
{
return false ;
}
}else
{
return false ;
}
}//end for
//======== add by pui 21/07/2004============//
if (($strChildID=="0") || ($strChildID==""))
{
$strChildID="1" ;
}
$sqlSelect="SELECT * FROM cp_parentchild pr
INNER JOIN cp_profile p ON pr.profile_id=p.ProfileID
WHERE pr.user_id='$strChildID' " ;
$arrPerApprove = getRow($sqlSelect) ;
$arrFormValue["FirstNameApprove"]=$arrPerApprove["ProfileFirstName"] ;
$arrFormValue["EmailReseller"]=$arrPerApprove["ProfileEmailAddress"] ;
//=======================================//
$strList = "";
//echo count($DomainName) ;
for($j=0; $jSelectDataProfile($table,"ProfileID = '$ProfileID' AND profile_type='Profile' ") ;
$arrProfile = getRow( $strSQLProfile) ;
$strSQLRegistrant = $objOrderManage->SelectDataProfile($table,"ProfileID = '$RegistrantID' AND profile_type='Registrant' ") ;
$arrRegistrant = getRow( $strSQLRegistrant) ;// function getrow in file inc.global.php
$strSQLAdmin = $objOrderManage->SelectDataProfile($table,"ProfileID = '$AdminID' AND profile_type='Admin' ") ;
$arrAdmin=getRow( $strSQLAdmin) ;
$strSQLTech = $objOrderManage->SelectDataProfile($table,"ProfileID = '$TechID' AND profile_type='Tech' ") ;
$arrTech=getRow( $strSQLTech) ;
$strSQLAuxBilling = $objOrderManage->SelectDataProfile($table," ProfileID = '$AuxBillingID' AND profile_type='AuxBilling' ") ;
$arrAuxBilling =getRow( $strSQLAuxBilling) ;
$arrFormValue["ListDetailOrder"] = "$strList" ;
$arrFormValue["PriceTotal"] = num_format($priceTotal) ;
$arrFormValue["ProfileEmail"] = $ProfileEmailAddress ;
$arrFormValue["domainname"] = $strDomainName ;
$arrFormValue["VAT"] = $strVAT ;
######################################################################
$arrFormValue["ProfileOrganizationName"] = $arrProfile["ProfileOrganizationName"] ;
$arrFormValue["ProfileFirstName"] = $arrProfile["ProfileFirstName"] ;
$arrFormValue["ProfileLastName"] = $arrProfile["ProfileLastName"] ;
$arrFormValue["ProfileAddress1"] = $arrProfile["ProfileAddress1"] ;
$arrFormValue["ProfileAddress2"] = $arrProfile["ProfileAddress2"] ;
$arrFormValue["ProfileCity"] = $arrProfile["ProfileCity"] ;
$arrFormValue["ProfileStateProvince"] = $arrProfile["ProfileStateProvince"] ;
$arrFormValue["ProfilePostalCode"] = $arrProfile["ProfilePostalCode"] ;
$arrFormValue["ProfileCountry"] = $arrProfile["ProfileCountry"] ;
$arrFormValue["ProfilePhone"] = $arrProfile["ProfilePhone"] ;
$arrFormValue["ProfileFax"] = $arrProfile["ProfileFax"] ;
$arrFormValue["ProfileEmailAddress"] = $arrProfile["ProfileEmailAddress"] ;
return $arrFormValue;
}
return false ;
}//end function
*/
//=============================================================//
function EncodeHeader ($str, $position = 'text') {
$x = 0;
switch (strtolower($position)) {
case 'phrase':
if (!preg_match('/[\200-\377]/', $str)) {
// Can't use addslashes as we don't know what value has magic_quotes_sybase.
$encoded = addcslashes($str, "\0..\37\177\\\"");
if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str))
return ($encoded);
else
return ("\"$encoded\"");
}
$x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches);
break;
case 'comment':
$x = preg_match_all('/[()"]/', $str, $matches);
// Fall-through
case 'text':
default:
$x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches);
break;
}
if ($x == 0)
return ($str);
$maxlen = 75 - 7 - strlen("TIS-620");
// Try to select the encoding which should produce the shortest output
if (strlen($str)/3 < $x) {
$encoding = 'B';
$encoded = base64_encode($str);
$maxlen -= $maxlen % 4;
$encoded = trim(chunk_split($encoded, $maxlen, "\n"));
} else {
$encoding = 'Q';
$encoded = EncodeQ($str, $position);
$encoded = WrapText($encoded, $maxlen, true);
$encoded = str_replace("="."\n", "\n", trim($encoded));
}
$encoded = preg_replace('/^(.*)$/m', " =?"."TIS-620"."?$encoding?\\1?=", $encoded);
$encoded = trim(str_replace("\n", "\n", $encoded));
return $encoded;
}
//=============================================================//
function EncodeQP ($str) {
$encoded = FixEOL($str);
if (substr($encoded, -(strlen("\n"))) != "\n")
$encoded .= "\n";
// Replace every high ascii, control and = characters
$encoded = preg_replace('/([\000-\010\013\014\016-\037\075\177-\377])/e',
"'='.sprintf('%02X', ord('\\1'))", $encoded);
// Replace every spaces and tabs when it's the last character on a line
$encoded = preg_replace("/([\011\040])"."\n"."/e",
"'='.sprintf('%02X', ord('\\1')).'"."\n"."'", $encoded);
// Maximum line length of 76 characters before CRLF (74 + space + '=')
$encoded = WrapText($encoded, 74, true);
return $encoded;
}
//=============================================================//
function FixEOL($str) {
$str = str_replace("\r\n", "\n", $str);
$str = str_replace("\r", "\n", $str);
$str = str_replace("\n", "\n", $str);
return $str;
}
//=============================================================//
function WrapText($message, $length, $qp_mode = false) {
$soft_break = ($qp_mode) ? sprintf(" =%s", "\n") : "\n";
$message = FixEOL($message);
if (substr($message, -1) == "\n")
$message = substr($message, 0, -1);
$line = explode("\n", $message);
$message = "";
for ($i=0 ;$i < count($line); $i++)
{
$line_part = explode(" ", $line[$i]);
$buf = "";
for ($e = 0; $e $length))
{
$space_left = $length - strlen($buf) - 1;
if ($e != 0)
{
if ($space_left > 20)
{
$len = $space_left;
if (substr($word, $len - 1, 1) == "=")
$len--;
elseif (substr($word, $len - 2, 1) == "=")
$len -= 2;
$part = substr($word, 0, $len);
$word = substr($word, $len);
$buf .= " " . $part;
$message .= $buf . sprintf("=%s", "\n");
}
else
{
$message .= $buf . $soft_break;
}
$buf = "";
}
while (strlen($word) > 0)
{
$len = $length;
if (substr($word, $len - 1, 1) == "=")
$len--;
elseif (substr($word, $len - 2, 1) == "=")
$len -= 2;
$part = substr($word, 0, $len);
$word = substr($word, $len);
if (strlen($word) > 0)
$message .= $part . sprintf("=%s", "\n");
else
$buf = $part;
}
}
else
{
$buf_o = $buf;
$buf .= ($e == 0) ? $word : (" " . $word);
if (strlen($buf) > $length and $buf_o != "")
{
$message .= $buf_o . $soft_break;
$buf = $word;
}
}
}
$message .= $buf . "\n";
}
return $message;
}
//=============================================================//
function EncodeQ ($str, $position = "text") {
// There should not be any EOL in the string
$encoded = preg_replace("[\r\n]", "", $str);
switch (strtolower($position)) {
case "phrase":
$encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
break;
case "comment":
$encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded);
case "text":
default:
// Replace every high ascii, control =, ? and _ characters
$encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e',
"'='.sprintf('%02X', ord('\\1'))", $encoded);
break;
}
// Replace every spaces to _ (more readable than =20)
$encoded = str_replace(" ", "_", $encoded);
return $encoded;
}
//============================================
?>