if (preg_match("/function_component.php/i", $_SERVER['PHP_SELF'])) { Header("Location: ../index.php"); die(); }
//ตัดอัขระพิเศษใน URL
function spacial_name($raw){
$raw = preg_replace('#[^-ก-๙a-zA-Z0-9]#u', '', $raw);
$raw = ereg_replace("-+","-",$raw);
if(substr($raw,0,1) == '-')
$raw = substr($raw,1);
if(substr($game_url,-1) == '-')
$raw = substr($raw,0,-1);
return urlencode($raw);
}
function project_name($project_id){
$val = db_quick("SELECT project_name FROM project WHERE project_id = $project_id");
return $val[project_name];
}
// Nook
function project_name_en($project_id){
$val = db_quick("SELECT project_name_en FROM project WHERE project_id = $project_id");
return $val[project_name_en];
}
function p_name($val){
$val = str_replace(" ","",$val);
$val = str_replace("-","",$val);
$val = str_replace("/","|",$val);
$val = str_replace("#","|",$val);
return $val;
}
function checkpic($url){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
// don't download content
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(curl_exec($ch)!==FALSE)
{
return true;
}
else
{
return false;
}
}
function shorturl($longUrl){
$smsurl = "http://s-r.link/api.php";
$longUrl = str_replace("&","#1#",$longUrl);
$longUrl = str_replace("=","#2#",$longUrl);
$longUrl = str_replace("?","#3#",$longUrl);
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$smsurl); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, "url=$longUrl"); // add POST fields //
$result = curl_exec($ch); // run the whole process
curl_close($ch);
return $result;
}
function api_member($business_id){
$smsurl = "http://admin.nao.co.th/api_member.php";
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$smsurl); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, "member_business_id=$business_id"); // add POST fields //
$result = curl_exec($ch); // run the whole process
curl_close($ch);
return $result;
}
function shorturl_google($longUrl){
//$longUrl = 'http://www.serverich.com';
$apiKey = 'AIzaSyCC-vQgEj_ZbPmq8_xV6wrQqUqmkJl3JSk';
$postData = array('longUrl' => $longUrl, 'key' => $apiKey);
$jsonData = json_encode($postData);
$curlObj = curl_init();
curl_setopt($curlObj, CURLOPT_URL, 'https://www.googleapis.com/urlshortener/v1/url?key='.$apiKey);
curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curlObj, CURLOPT_HEADER, 0);
curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json'));
curl_setopt($curlObj, CURLOPT_POST, 1);
curl_setopt($curlObj, CURLOPT_POSTFIELDS, $jsonData);
$response = curl_exec($curlObj);
$json = json_decode($response);
curl_close($curlObj);
//echo 'Shortened URL ->'.$json->id;
return $json->id;
}
function member_com($sid){
$qs ="SELECT *,(SELECT product_name from product WHERE product_id = cus_cart_detail.product_id) as product_name FROM `cus_cart_detail` WHERE `sid` LIKE '$sid' ";
$qrs =mysql_query($qs);
while($rs =mysql_fetch_array($qrs)){
$product = db_quick("SELECT product_point1 FROM product WHERE product_id = '$rs[product_id]' ");
$price = $rs[product_num] * $product[product_point1];
$res .= "$rs[product_name] $rs[price] x $rs[product_num] = $price
";
$total = $total + $price;
}
$res .= "Total : $total ";
return $total;
}
function spon_com($sid){
$qs ="SELECT *,(SELECT product_name from product WHERE product_id = cus_cart_detail.product_id) as product_name FROM `cus_cart_detail` WHERE `sid` LIKE '$sid' ";
$qrs =mysql_query($qs);
while($rs =mysql_fetch_array($qrs)){
$product = db_quick("SELECT product_point2 FROM product WHERE product_id = '$rs[product_id]' ");
$price = $rs[product_num] * $product[product_point2];
$res .= "$rs[product_name] $rs[price] x $rs[product_num] = $price
";
$total = $total + $price;
}
$res .= "Total : $total ";
return $total;
}
function set_com_aff($sid,$order_id){
$qs ="SELECT * FROM `cus_cart_detail` WHERE `sid` LIKE '$sid' ";
$qrs =mysql_query($qs);
while($rs =mysql_fetch_array($qrs)){
$cus_arr = db_quick("SELECT `aff_id`,`cus_id` FROM `cus_order` WHERE `order_sid` = '$sid' ");
$cus_id = $cus_arr[cus_id];
$aff_id = $cus_arr[aff_id];
$spon = db_quick("SELECT `sponsor_id` FROM `af_member` WHERE `id` = '$aff_id' ");
$spon_id = $spon[sponsor_id];
$date_comm = date("Y-m");
$today =date("Y-m-d");
$comm =member_com($sid);
$comm_spon =spon_com($sid);
if($aff_id){
$num_comm_month_m = db_num("SELECT * FROM `commission_pay` WHERE `member_id` = '$aff_id' AND `date` LIKE '%$date_comm%' AND `status` = 'ยังไม่จ่าย' ");
if($num_comm_month_m == 0){
$qm = "INSERT INTO `commission_pay` (`id`,`order_id`, `member_id`, `date`, `comm`, `comm_spon`, `status`) VALUES (NULL, '$order_id', '$aff_id', '$today', '$comm', '', 'ยังไม่จ่าย');";
}else{
$qm ="UPDATE `commission_pay` SET `date`='$today',`comm`=`comm`+$comm WHERE `member_id` = '$aff_id' AND `date` LIKE '%$date_comm%' AND `status` = 'ยังไม่จ่าย';";
}
if(db_query($qm)){
}else{
}
}
if($spon_id){
$num_comm_month_s = db_num("SELECT * FROM `commission_pay` WHERE `member_id` = '$spon_id' AND `date` LIKE '%$date_comm%' ");
if($num_comm_month_s == 0){
$qs = "INSERT INTO `commission_pay` (`id`,`order_id`, `member_id`, `date`, `comm`, `comm_spon`, `status`) VALUES (NULL, '$order_id', '$spon_id', '$today', '', '$comm_spon', 'ยังไม่จ่าย');";
}else{
$qs ="UPDATE `commission_pay` SET `date`='$today',`comm_spon`=`comm_spon`+$comm_spon WHERE `member_id` = '$spon_id' AND `date` LIKE '%$date_comm%' ;";
}
if(db_query($qs)){
}else{
}
}
$num_permission_com = "";
$num_comm_month_m = "";
$num_permission_spon_com = "";
$num_comm_month_s = "";
$pro_id = "";
}
}
function set_com_aff_detail($sid,$order_id){
$qs ="SELECT * FROM `cus_cart_detail` WHERE `sid` LIKE '$sid' ";
$qrs =mysql_query($qs);
while($rs =mysql_fetch_array($qrs)){
$cus_arr = db_quick("SELECT `aff_id`,`cus_id` FROM `cus_order` WHERE `order_sid` = '$sid' ");
$cus_id = $cus_arr[cus_id];
$aff_id = $cus_arr[aff_id];
$spon = db_quick("SELECT `sponsor_id` FROM `af_member` WHERE `id` = '$aff_id' ");
$spon_id = $spon[sponsor_id];
$date_comm = date("Y-m");
$today =date("Y-m-d");
$comm =member_com($sid);
$comm_spon =spon_com($sid);
if($aff_id){
$qm = "INSERT INTO `commission_detail` (`id`,`order_id`, `member_id`, `date`, `comm`, `comm_spon`, `status`) VALUES (NULL, '$order_id', '$aff_id', '$today', '$comm', '', 'ยังไม่จ่าย');";
if(db_query($qm)){
}else{
}
}
if($spon_id){
$qs = "INSERT INTO `commission_detail` (`id`,`order_id`, `member_id`, `date`, `comm`, `comm_spon`, `status`) VALUES (NULL, '$order_id', '$spon_id', '$today', '', '$comm_spon', 'ยังไม่จ่าย');";
if(db_query($qs)){
}else{
}
}
$num_permission_com = "";
$num_comm_month_m = "";
$num_permission_spon_com = "";
$num_comm_month_s = "";
$pro_id = "";
}
}
function get_comm_by_member_id($member_id,$date){
$member_com = db_quick("SELECT * FROM `commission_pay` WHERE member_id = '$member_id' AND `date` LIKE '$date%' ");
$sum_comm = $member_com[comm]+$member_com[comm_spon];
return "$sum_comm";
}
function get_bank_id_by_member_id($member_id){
$member_bank = db_quick("SELECT * FROM `af_member_bank` WHERE member_id = '$member_id' ");
$bank_id_for_member = $member_bank[bank_id];
return "$bank_id_for_member";
}
function get_account_name_by_member_id($member_id){
$member_bank = db_quick("SELECT * FROM `af_member_bank` WHERE member_id = '$member_id' ");
$bank_id_for_member = $member_bank[account_name];
return "$bank_id_for_member";
}
function get_bank_name_by_member_id($member_id){
$member_bank = db_quick("SELECT * FROM `af_member_bank` WHERE member_id = '$member_id' ");
$bank_id_for_member = $member_bank[bank_name];
return "$bank_id_for_member";
}
function get_brand_name($brand_id){
$brand = db_quick("SELECT name FROM `brand` WHERE brand_id = '$brand_id' ");
$brand_name = $brand[name];
return "$brand_name";
}
function order_status($q){
switch($q){
case "":
$q_word = "";
break;
case "1":
$q_word = "ยืนยันการสั่งซื้อ-รอชำระเงิน";
break;
case "2":
$q_word = "แจ้งชำระเงิน";
break;
case "3":
$q_word = "ยืนยันการชำระ-รอจัดส่ง";
break;
case "4":
$q_word = "กำลังจัดส่ง";
break;
case "5":
$q_word = "จัดส่งสินค้าแล้ว";
break;
case "6":
$q_word = "ยกเลิกการสั่งซื้อ";
break;
}
return " ($q_word) ";
}
function aff_class($aff_id){
$c = db_quick("SELECT `class_level` FROM `af_member` WHERE `id` ='$aff_id'");
return $c['class_level'];
}
function q_val($field,$table,$field2,$id){
$q = db_quick("SELECT $field FROM $table WHERE $field2 = '$id' ");
return $q[$field];
}
function searchtext($target,$search) {
if(strstr($target,$search))
{
return true;
}else {
return false;
}
}
function content_detail($id){
$content = db_quick("SELECT content_name,content_des FROM content WHERE content_id = '$id' ");
$content['name'] = $content[content_name];
$content['des'] = htmlspecialchars_decode($content[content_des]);
return $content;
}
function content_pic($bis_id,$module,$id,$size){
$content_pic = db_quick("SELECT filename,des,store FROM picture WHERE module = '$module' AND module_id = '$id' ORDER BY `picture`.`store` DESC LIMIT 1 ");
if($content_pic[filename]){
$pic = " ";
}else{
$pic = " Picture";
}
return $pic;
}
function content_pic_admin($bis_id,$module,$id,$size){
$content_pic = db_quick("SELECT filename,des,store FROM picture WHERE module = '$module' AND module_id = '$id' ORDER BY `picture`.`store` DESC LIMIT 1 ");
if($content_pic[filename]){
$pic = " ";
}else{
$pic = " Picture";
}
return $pic;
}
function getUserIpAddr()
{
if (!empty($_SERVER['HTTP_CLIENT_IP'])) //if from shared
{
return $_SERVER['HTTP_CLIENT_IP'];
}
else if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) //if from a proxy
{
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
return $_SERVER['REMOTE_ADDR'];
}
}
$referer = $_SERVER["HTTP_REFERER"];
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$ip = getUserIpAddr();
function change_date_format($dt){
$dt = explode(" ",$dt);
$d = $dt[0];
$d = explode("-",$dt[0]);
$date = "$d[2]/$d[1]/$d[0]";
$time = $dt[1];
return "$date $time";
}
function get_product_name($id){
$name = db_quick("SELECT product_name,product_code FROM product WHERE product_id = '$id' ");
return "$name[product_code] ";
}
function get_sales_name($id){
$name = db_quick("SELECT name FROM user WHERE user_id = '$id' ");
if($name[name] == ""){
$name = db_quick("SELECT name as first_name FROM user WHERE user_id = '$id' ");
}
return "$name[name] ($id)";
}
function get_cus_name($id){
$name = db_quick("SELECT first_name,family_name FROM my_member_profile WHERE member_id = '$id' ");
return "$name[first_name] ($id)";
}
function get_aff_name($id){
$name = db_quick("SELECT CONCAT_WS(' ',first_name,' ',family_name) as name FROM af_member_profile WHERE member_id = '$id' ");
return "$name[name] ($id)";
}
function get_aff_address($id){
$q = db_quick("SELECT mobile FROM `af_member_address` WHERE member_id = '$id'");
return "$q[mobile]";
}
function get_aff_line($id){
$q = db_quick("SELECT line FROM `af_member_address` WHERE member_id = '$id'");
return "$q[line]";
}
function get_sales_name_by_sub_domain($sub_domain){
$aff_id = db_quick("SELECT member_id FROM member_web WHERE sub_domain = '$sub_domain' ");
$aff_id = $aff_id[member_id];
$aff_name = db_quick("SELECT first_name FROM user_profile WHERE user_id = '$aff_id[member_id]' ");
if($aff_name[first_name] == ""){
$aff_name = db_quick("SELECT name as first_name FROM user WHERE user_id = '$aff_id' ");
}
return "$aff_name[first_name] ($aff_id)";
}
function get_sales_id_by_sub_domain($sub_domain){
$aff_id = db_quick("SELECT member_id FROM member_web WHERE sub_domain = '$sub_domain' ");
$aff_id = $aff_id[member_id];
$aff_name = db_quick("SELECT first_name FROM user_profile WHERE user_id = '$aff_id[member_id]' ");
if($aff_name[first_name] == ""){
$aff_name = db_quick("SELECT name as first_name FROM user WHERE user_id = '$aff_id' ");
}
return "$aff_id";
}
function get_aff_name_by_sub_domain($sub_domain){
$aff_id = db_quick("SELECT member_id FROM af_web WHERE sub_domain = '$sub_domain' ");
$aff_id = $aff_id[member_id];
$aff_name = db_quick("SELECT first_name FROM af_member_profile WHERE member_id = '$aff_id[member_id]' ");
return "$aff_name[first_name] ($aff_id)";
}
function cus_name($id){
$name = db_quick("SELECT first_name,family_name FROM cus_profile WHERE cus_id = '$id' ");
$address = db_quick("SELECT mobile FROM cus_address WHERE cus_id = '$id' ");
return "$name[first_name] $name[family_name] T.$address[mobile] ($id)";
}
function aff_name($id){
$name = db_quick("SELECT first_name FROM af_member_profile WHERE member_id = '$id' ");
return "$name[first_name] ($id)";
}
function get_member_name($id){
$name = db_quick("SELECT first_name FROM my_member_profile WHERE member_id = '$id' ");
return "$name[first_name] ($id)";
}
function logistic_name($id){
$name = db_quick("select logistic_name from logistic WHERE logistic_id = '$id' ");
return $name[logistic_name];
}
//แปลงค่า id เป็น ชื่อ จ. อ. ต.
function get_province_name($val){
$q = db_quick("SELECT PROVINCE_NAME FROM `province` WHERE `PROVINCE_ID` = '$val' ");
return $q[PROVINCE_NAME];
}
function get_amphur_name($val){
$q = db_quick("SELECT AMPHUR_NAME FROM `amphur` WHERE `AMPHUR_ID` = '$val' ");
return $q[AMPHUR_NAME];
}
function get_district_name($val){
$q = db_quick("SELECT DISTRICT_NAME FROM `district` WHERE `DISTRICT_ID` = '$val' ");
return $q[DISTRICT_NAME];
}
function grand_total($order_id){
global $sub_domain,$domain_name,$memo;
$order_des = db_quick("SELECT * FROM `cus_order` WHERE `order_id` = '$order_id' ");
$qs_cart ="SELECT * FROM `cus_cart_detail` WHERE `sid` LIKE '$order_des[order_sid]' AND `status` NOT LIKE '' ";
$qrs_cart =mysql_query($qs_cart);
while($rs_cart = mysql_fetch_array($qrs_cart)){
$price = $rs_cart[price];
$total = $rs_cart[product_num]*$price;
$grand = $grand + $total;
$trans = $trans+($rs_cart[logistic_price]*$rs_cart[product_num]);
$n_price = number_format($price);
$n_total = number_format($total);
}
$logistic_price = $order_des[order_logistic_price];
$grand_total = $grand + $trans - $dc;
return $grand_total;
}
function grand_total2($order_id){
$order_des = db_quick("SELECT * FROM `order` WHERE `order_id` = '$order_id' ");
$cus_id = $order_des[member_id];
$session_id = $order_des[order_sid];
$order_status = $order_des[order_status];
if($cus_id){
$order_by_sid = db_quick("SELECT * FROM `order` WHERE `member_id` = '$cus_id' AND `member_id` NOT LIKE '' AND `order_sid` LIKE '$session_id' LIMIT 1 ");
$logistic = db_quick("SELECT * FROM `logistic` WHERE `logistic_id` = '$order_by_sid[order_logistic]' ");
$coupons = db_quick("SELECT * FROM `coupons` WHERE `coupons_id` = '$order_by_sid[order_coupons]' ");
}
$qs_cart ="SELECT * FROM `cart_detail` WHERE `sid` LIKE '$session_id' AND `status` LIKE '1' ";
$qrs_cart =mysql_query($qs_cart);
while($rs_cart = mysql_fetch_array($qrs_cart)){
$q_product = db_quick("SELECT * FROM `product` WHERE `product_id` = '$rs_cart[product_id]' ");
$product_pic = db_quick("SELECT filename,des,store,freedom_id FROM picture WHERE module = 'product' AND module_id = '$rs_cart[product_id]' ORDER BY `picture`.`store` DESC ");
if(($q_product[product_price_dc] == 0) or ($q_product[product_price_dc] == "")){
$price = $q_product[product_price];
}else{
$price = $q_product[product_price_dc];
}
$total = $rs_cart[product_num]*$price;
$grand = $grand + $total;
}
return $grand_total = $grand;
}
function grand_total_and_dc_no_logistic($order_id){
$order_des = db_quick("SELECT * FROM `order` WHERE `order_id` = '$order_id' ");
$cus_id = $order_des[member_id];
$session_id = $order_des[order_sid];
$order_status = $order_des[order_status];
if($cus_id){
$order_by_sid = db_quick("SELECT * FROM `order` WHERE `member_id` = '$cus_id' AND `member_id` NOT LIKE '' AND `order_sid` LIKE '$session_id' LIMIT 1 ");
$logistic = db_quick("SELECT * FROM `logistic` WHERE `logistic_id` = '$order_by_sid[order_logistic]' ");
$coupons = db_quick("SELECT * FROM `coupons` WHERE `coupons_id` = '$order_by_sid[order_coupons]' ");
}
$qs_cart ="SELECT * FROM `cart_detail` WHERE `sid` LIKE '$session_id' AND `status` LIKE '1' ";
$qrs_cart =mysql_query($qs_cart);
while($rs_cart = mysql_fetch_array($qrs_cart)){
$q_product = db_quick("SELECT * FROM `product` WHERE `product_id` = '$rs_cart[product_id]' ");
$product_pic = db_quick("SELECT filename,des,store,freedom_id FROM picture WHERE module = 'product' AND module_id = '$rs_cart[product_id]' ORDER BY `picture`.`store` DESC ");
if(($q_product[product_price_dc] == 0) or ($q_product[product_price_dc] == "")){
$price = $q_product[product_price];
}else{
$price = $q_product[product_price_dc];
}
$total = $rs_cart[product_num]*$price;
$grand = $grand + $total;
}
$logistic_price = $order_des[order_logistic_price];
switch($coupons[coupons_type]){
case "dc_logistic":
$logistic_price = 0;
$coupons_des = " $coupons[coupons_name] ฟรีค่าจัดส่ง";
break;
case "dc_percent":
$dc = ($coupons[coupons_command]*$grand)/100;
$coupons_des = " $coupons[coupons_name] ลด $coupons[coupons_command] % จากราคาสินค้า";
break;
case "dc_price":
$dc = $coupons[coupons_command];
$coupons_des = " $coupons[coupons_name] ลด $coupons[coupons_command] จากราคาสินค้า";
break; }
return $grand_total = $grand - $dc;
}
// แปลงค่าตัวแปร เป็น ค่า
function trans_to_val($val){
global $cus_id,$cus_name,$cus_mobile,$cus_password,$aff_id,$aff_name,$aff_mobile,$total_price,$order_id,$order_table,$url,$domain_name,$sub_domain;
$url = "$sub_domain.$domain_name";
if($order_id){ // ถ้ามี Order ID ให้ get amt
$amt = grand_total($order_id);
}
if($cus_id != ""){ $val = str_replace("{cus_id}",$cus_id,$val); }
if($cus_name != ""){ $val = str_replace("{cus_name}",$cus_name,$val); }
if($cus_email != ""){ $val = str_replace("{cus_email}",$cus_email,$val); }
if($cus_mobile != ""){ $val = str_replace("{cus_mobile}",$cus_mobile,$val); }
if($cus_password != ""){ $val = str_replace("{customer_password}",$cus_password,$val); }
if($aff_name != ""){ $val = str_replace("{aff_name}",$aff_name,$val); }
if($aff_email != ""){ $val = str_replace("{aff_email}",$aff_email,$val); }
if($aff_mobile != ""){ $val = str_replace("{aff_mobile}",$aff_mobile,$val); }
if($total_price != ""){ $val = str_replace("{total_price}",$total_price,$val); }
if($order_id != ""){ $val = str_replace("{order_id}",$order_id,$val); }
if($order_table != ""){ $val = str_replace("{order_table}",$order_table,$val); }
if($url != ""){ $val = str_replace("{url}",$url,$val); }
if($domain_name != ""){ $val = str_replace("{domain_name}",$domain_name,$val); }
if($sub_domain != ""){ $val = str_replace("{sub_domain}",$sub_domain,$val); }
if($amt != ""){ $val = str_replace("{amt}",$amt,$val); }
return $val;
}
function freedom_sms($s_number,$r_number,$msg){
$s_number = mobile_num($s_number);
$r_number = mobile_num($r_number);
$smsurl = "http://www.thaiwebsms.com/vip/api_rics.php";
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$smsurl); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, "username=richinter&password=iloverich&secret=hy9213g8&sender=$s_number&dest=$r_number&msg=$msg"); // add POST fields //
$result = curl_exec($ch); // run the whole process
curl_close($ch);
return $result;
}
// สำหรับคำนวนวันหมดอายุ
function dateEstimate($date) { // format 2012-12-30
$newdate = explode("-",$date);
$theMonth = $newdate[1];
$theDay = $newdate[2];
$theYear = $newdate[0];
return mktime(0,0,0,$theMonth,$theDay,$theYear);
}
function add_to_date($givendate,$day=0,$mth=0,$yr=0) { // สุดยอดฟังก์ชั่น บวกเวลา
$cd = strtotime($givendate);
$newdate = date('Y-m-d', mktime(date('h',$cd),
date('i',$cd), date('s',$cd), date('m',$cd)+$mth,
date('d',$cd)+$day, date('Y',$cd)+$yr));
return $newdate;
}
function trans_to_day($date){
//$d1=dateEStime($dd[2], $dd[1], $dd[0]); //1 มกราคม คศ.2000 (ต้องเป็น คศ เท่านั้น)
$dexp=dateEstimate($date); //2 มกราคม คศ.2000
$now_date = date("Y-m-d");
$dnow=dateEstimate($now_date); //2 มกราคม คศ.2000
$offset=$dexp-$dnow;
return $days=floor($offset/60/60/24); //แปลงเป็นจำนวนวัน
}
function permis_module() {}
function getIpAddress() {
return (empty($_SERVER['HTTP_CLIENT_IP'])?(empty($_SERVER['HTTP_X_FORWARDED_FOR'])?
$_SERVER['REMOTE_ADDR']:$_SERVER['HTTP_X_FORWARDED_FOR']):$_SERVER['HTTP_CLIENT_IP']);
}
function mobile_num($number){
$number = trim($number);
$number = str_replace("-","",$number);
$number = str_replace(" ","",$number);
if(strlen($number) >= 10){
return $number;
}else{
return false;
}
}
function aletbox($result,$message,$reflashtime,$repage){
$reflashtime = $reflashtime*200;
echo "
$message
$message.
$message.
$message.
$message.