$numChar) { $text = substr($text, 0, $numChar - strlen($append)); $text .= $append; } return $text; } // Duplicate a database record // Source: http://www.epigroove.com/posts/79/how_to_duplicate_a_record_in_mysql_using_php function mysql_duplicate_row($table, $search_arr, $new_id_col, $exceptions=array(), $appends=array()) { // prepare exceptions, if any; if (!is_array($exceptions)) { $exceptions = ($exceptions) ? array($exceptions=>'') : array(); } // prepare appends, if any; if (!is_array($appends)) { $appends = (!count($appends)) ? array() : $appends; } // build query to search for original record $query = "SELECT * FROM $table WHERE "; foreach ($search_arr as $key => $value) { $query .= '`'.$key.'` = "'.str_replace('"','\"',$value).'" AND '; } $query = substr($query,0,strlen($query)-5); # lop off the extra trailing ADD // load the original record into an array $result = mysql_query($query) or error(mysql_error(),__FILE__,__LINE__); $original_record = mysql_fetch_assoc($result); if ($original_record) { // insert the new record and get the new auto_increment id mysql_query("INSERT INTO $table () VALUES ()") or error(mysql_error(),__FILE__,__LINE__); $new_id = mysql_insert_id(); // generate the query to update the new record with the previous values $query = "UPDATE $table SET "; foreach ($original_record as $key => $value) { // we musn't duplicate the id field if ($key != $new_id_col) { // if key is an exception, use the exception value if (array_key_exists($key, $exceptions)) { $value = $exceptions[$key]; } // if key has an append and value is not blank if (array_key_exists($key, $appends) && $value) { $value = $value.$appends[$key]; } // build an insert into the query $query .= '`'.$key.'` = "'.str_replace('"','\"',$value).'", '; } } $query = substr($query,0,strlen($query)-2); # lop off the extra trailing comma $query .= " WHERE $new_id_col=$new_id"; mysql_query($query) or error(mysql_error(),__FILE__,__LINE__,$query); // return the new id return $new_id; } return false; } /*************************** COMMON: Parse & Format ***************************/ // Get the indent of INPUT following a SAMP // Explanation: Search global.css for 'samp' function get_indent($text) { if ($text) return (strlen($text)*7 +10 +2).'px'; else return false; } // Format user input for HTML output function format_user_input($input) { $allowed_tags = array('b','strong','i','em','code','pre'); $search = array("\t"); $replace = array(""); foreach($allowed_tags as $tag) { $search[] = '{'.$tag.'}'; $replace[] = '<'.$tag.'>'; $search[] = '{/'.$tag.'}'; $replace[] = ''; } $output = $input; $output = htmlspecialchars($output); $output = nl2br($output); $output = str_replace($search,$replace,$output); return $output; } // Revert URL-Safe Filename to Visually-Appealing String function filenametostr($filename) { $string = htmlspecialchars_decode($filename); $search = array('-','_'); $replace = array(' ',' '); $string = str_replace($search,$replace,$string); $string = ucwords($string); return $string; } /*************************** COMMON: Notification ***************************/ // Display a brief closable message (and any errors) function message($message,$errors=array()) { global $imgdir; $html = '
'.$message.'Close
'; if (!count($errors) && $errors) $errors[] = $errors; if (count($errors)) { foreach ($errors as $err) $err_str.= '
  • '.$err.'
  • '; $html.= '

    '.STR_ERRORS.'

      '.$err_str.'
    '; } return $html; } // Halt page and display error with details function debug($content) { echo '
    ';
    
    	if (is_array($content)) print_r($content);
    	else echo $content;
    	
    	echo '
    '; } // Halt page and display error with details function error($error, $file, $line, $extras=false) { global $settings, $l; $settings['debug'] = true; // SHOULD CREATE GLOBAL SETTINGS? $html = ' '; if ($settings['debug']) { $html .= '
    Error:
    '.$error.'
    File:
    '.$file.'
    Line:
    '.$line.'
    '; if (is_array($extras) || $extras) { $html .= "\n\t\t".'
    Other:
    '; if (is_array($extras) && count($extras)) { $html .= "\n\t\t\t".'
    '."\n\t\t\t\t".'
      '; foreach($extras as $key => $value) { $html .= "\n\t\t\t\t\t".'
    1. '.$key.': '.$value.'
    2. '; } $html .= "\n\t\t\t\t".'
    '."\n\t\t\t".'
    '; } if (!is_array($extras) && $extras) { $html .= '
    '.$extras.'
    '; } } $html .= '
    '; } else { $html .= '

    '.$l['ERROR'].'

    '; } die($html); } /*************************************************** BACKEND NAVIGATION ***************************************************/ /*************************** NAV: Query Functions ***************************/ //Initiate query for building menues function menu() { global $result_array, $Mod; $query = "SELECT * FROM io_adm, io_adm_ln WHERE io_adm.parent_id='0' AND io_adm.display='1' AND io_adm.sys='$_SESSION[sesSys]' AND io_adm.page_id=io_adm_ln.page_id AND io_adm_ln.ln='$_SESSION[sesLang]' ORDER BY io_adm.orderby"; $results = mysql_query($query) or error(mysql_error(),__FILE__,__LINE__,$query); $result_array = array(); while($rows = mysql_fetch_assoc($results)){ $rows['selected'] = ($rows['page_id'] == $Mod) ? true : false; //ARE WE CURRENTLY BROWSING A CHILD - START $child_query = "SELECT * FROM io_adm WHERE io_adm.parent_id='$rows[page_id]' AND io_adm.parent_id!='0' AND io_adm.display='1' AND io_adm.sys='$_SESSION[sesSys]'"; $child_results = mysql_query($child_query) or error(mysql_error(),__FILE__,__LINE__,$child_query); while($child_rows = mysql_fetch_assoc($child_results)){ $rows['selected'] = ($child_rows['page_id'] == $Mod) ? true : $rows['selected']; } //ARE WE CURRENTLY BROWSING A CHILD - FINISH $result_array[] = $rows; } return $result_array; } function sub_menu($id) { global $result_array, $Mod, $modinc; $query = "SELECT * FROM io_adm, io_adm_ln WHERE io_adm.parent_id='$id' AND io_adm.parent_id!='0' AND io_adm.display='1' AND io_adm.sys='$_SESSION[sesSys]' AND io_adm.page_id=io_adm_ln.page_id AND io_adm_ln.ln='$_SESSION[sesLang]' ORDER BY io_adm.orderby"; $results = mysql_query($query) or error(mysql_error(),__FILE__,__LINE__,$query); $result_array = array(); while($rows = mysql_fetch_assoc($results)){ $rows['selected'] = ($rows['page_id'] == $Mod) ? true : false; $result_array[] = $rows; } return $result_array; } /*************************** NAV: Build Classes ***************************/ //initiating menu classes for display class menu { function menu($page_id, $linkname, $modinc, $pageurl, $orderby, $ses, $selected) { $this->URL = "index.php?Mod=".$page_id."&modinc=".$modinc."&ses=".$ses; $this->PARENT_ID = $page_id; $this->PRIV = $page_id; $this->TITLE = $linkname; $this->MOD = $modinc; $this->LOC = $pageurl; $this->ORDER = $orderby; $this->CLASS = ($selected) ? 'selected' : false; } } class submenu { function submenu($page_id, $parent_id, $modinc, $linkname, $pageurl, $orderby, $ses, $selected) { $this->URL = "index.php?Mod=".$page_id."&modinc=".$modinc."&ses=".$ses; $this->SUB_ID = $page_id; $this->PRIV = $page_id; $this->TITLE = $linkname; $this->MOD = $modinc; $this->LOC = $pageurl; $this->ORDER = $orderby; $this->CLASS = ($selected) ? 'selected' : false; } } /*************************** NAV: Build Array ***************************/ // Execute Functions for class output $top_menu = menu(); for($i=0;$i_buffer = $buffer; } // This function returns the next line from the document. // If a stream follows, it is deflated into readable text. function nextline() { $pos = strpos($this->_buffer, "\r"); if ($pos === false) { return false; } $line = substr($this->_buffer, 0, $pos); $this->_buffer = substr($this->_buffer, $pos + 1); if ($line == "stream") { $endpos = strpos($this->_buffer, "endstream"); $stream = substr($this->_buffer, 1, $endpos - 1); $stream = @gzuncompress($stream); $this->_buffer = $stream . substr($this->_buffer, $endpos + 9); } return $line; } // This function returns the next line in the document that is printable text. // We need it so we can search in just that portion. function textline() { $line = $this->nextline(); if ($line === false) { return false; } if (preg_match("/[^\\\\]\\((.+)[^\\\\]\\)/", $line, $match)) { $line = preg_replace("/\\\\(\d+)/e", "chr(0\\1);", $match[1]); return stripslashes($line); } return $this->textline(); } // This function returns true or false, indicating whether the document contains // the text that is passed in $str. function textfound($str) { while (($line = $this->textline()) !== false) { if (preg_match("/$str/i", $line) != 0) { return true; } } return false; } } class enCodePass{ ###############Gen Key Password################# var $hash_key = 'fdfdsfdsafdsa4654fsdafdsf65456231fsdafd687/7998789fdsa5646asdfasdfsa'; // รหัสพิเศษ ที่จะเอาไปใส่ร่วมกับ encode ให้เปลี่ยนไปในแต่ละเว็บ // encode function encrypted($string) { $key = $this->hash_key; return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key)))); } // decode function decrypted($encrypted) { $key = $this->hash_key; return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); } } /******************** DB Template *********************/ function getDesc($field,$table,$where){ $query = mysql_query("SELECT $field FROM $table WHERE $where") or error(mysql_error(),__FILE__,__LINE__,$query); $row = mysql_fetch_assoc($query); $num = mysql_num_rows($query); if($num > 0){ return $row["$field"]; }else{ return " "; } } function countDesc($field,$table,$where,$debug=""){ $sql = "SELECT $field FROM $table WHERE $where"; if($debug==""){ $query = mysql_query("SELECT $field FROM $table WHERE $where") or error(mysql_error(),__FILE__,__LINE__,$query); $num = mysql_num_rows($query); if($num > 0){ return $num; }else{ return "0"; } }else{ return $sql; } } function countGetDesc($field,$table,$where){ $query = mysql_query("SELECT $field FROM $table WHERE $where") or error(mysql_error(),__FILE__,__LINE__,$query); $row = mysql_fetch_assoc($query); $num = mysql_num_rows($query); $arr = array('num' => $num, 'val' => $row["$field"]); if($num > 0){ return $arr; }else{ return array('num' => '0'); } } function getSum($field,$table,$where='',$group=''){ if($where != ""){ $where = " WHERE $where"; }else{ $where = ""; } if($group != ""){ $group = " GROUP BY $group"; }else{ $group = ""; } $query = mysql_query("SELECT SUM($field) AS sum FROM ".$table.$where.$group) or error(mysql_error(),__FILE__,__LINE__,$query); $row = mysql_fetch_assoc($query); $num = mysql_num_rows($query); if($num > 0){ return $row["sum"]; }else{ return " "; } } function getDescArr($field,$table,$where='',$order='',$limit=''){ if($where != ""){ $where = " WHERE $where"; }else{ $where = ""; } if($order != ""){ $order = " ORDER BY $order"; }else{ $order = ""; } if($limit != ""){ $limit = " LIMIT $limit"; }else{ $limit = ""; } $query = mysql_query("SELECT $field FROM ".$table.$where.$order.$limit) or error(mysql_error(),__FILE__,__LINE__,$query); $row = mysql_fetch_assoc($query); $num = mysql_num_rows($query); if($num > 0){ return $row; }else{ return " "; } } function insertSQL($arrData = "", $table = "", $debug = '') { $myFieldName = ""; $myFieldValue = ""; if ($arrData == "") $arrData = $data; if ($table == "") $table = $myTable; foreach ($arrData as $key => $value) { $myFieldName .= $key . " , "; if (is_array($value)) { foreach ($value as $value2) { if ($value2 == "NOW()") { $myFieldValue .= "" . $value2 . " , "; } else { $myFieldValue .= "\"" . $value2 . "\" , "; } } } else { if ($value == "NOW()") { $myFieldValue .= "" . $value . " , "; } else { $myFieldValue .= "\"" . $value . "\" , "; } } } unset($data, $myTable); $qrs = "INSERT INTO " . $table . " ( " . substr($myFieldName, 0, $myFieldName - 2) . " ) VALUES ( " . substr($myFieldValue, 0, $myFieldValue - 2) . " ) "; if($debug==""){ $rs = mysql_query($qrs); if ($rs) { return mysql_insert_id(); } else { return "Error Query : " . $qrs; } }else{ return $qrs; } unset($myFieldName); unset($myFieldValue); } function updateSQL($arrData = "", $arrKey = "", $table = "", $debug = '') { $myTableName = $table; if ($arrData == "") $arrData = $data; if ($arrKey == "") $arrKey = $myWhere; if ($table == "") $table = $myTable; foreach ($arrData as $key => $value) { if ($value == "NOW()") { $myUpdate .= $key . " = " . $value . " , "; } else { $myUpdate .= $key . " = \"" . $value . "\" , "; } } $a = 1; foreach ($arrKey as $key => $value) { if (count($arrKey) == 1) { $myWhereCauseKeyID .= $key . " = \"" . $value . "\""; } else { if($a == count($arrKey)){ $myWhereCauseKeyID .= $key . " = \"" . $value . "\""; }else{ $myWhereCauseKeyID .= $key . " = \"" . $value . "\" AND "; } } $a++; //$myWhereArr[] = $key . " = \"" . $value . "\""; //$myWhereCauseKeyID .= implode(" AND ", $myWhereArr); } $sql = "UPDATE " . $table . " SET " . substr($myUpdate, 0, -2) . " WHERE " . $myWhereCauseKeyID . " "; if($debug==""){ mysql_query($sql) or error(mysql_error(),__FILE__,__LINE__,$query); }else{ return $sql; } unset($myUpdate); unset($myWhereCauseKeyID); unset($data, $myWhere, $myTable); } function callReceiveMoney($table,$mid,$sid,$date){ global $db; $sql = "SELECT * FROM $table WHERE mainlist_id = '$mid' AND child_id = '$sid' AND receipt_date = '$date'"; $Query = mysql_query($sql) or error(mysql_error(),__FILE__,__LINE__); $RecordCount = mysql_num_rows($Query); if ($RecordCount > 0) { while($RowGroup = mysql_fetch_assoc($Query)){ $price[] = $RowGroup['price']; } return array_sum($price); }else{ return " "; } } function getSTK($pid){ $query = mysql_query("SELECT (stk_spc + stk_reg + stk_shw + stk_stu) AS stk, gm_stk FROM sc_prod_inv WHERE pid = '$pid'"); $num = mysql_num_rows($query); if($num > 0){ $row = mysql_fetch_assoc($query); return array('stk' => $row['stk'], 'gm' => $row['gm_stk']); }else{ return "0"; } } /******************** END DB Template *********************/ /******************** PAGE NAVIGATOR *********************/ function page_navigator($before_p,$plus_p,$total,$total_p,$chk_page,$url,$Prev,$Next){ global $urlquery_str; $pPrev=$chk_page-1; $pPrev=($pPrev>=0)?$pPrev:0; $pNext=$chk_page+1; $pNext=($pNext>=$total_p)?$total_p-1:$pNext; $lt_page=$total_p-4; if($chk_page>0){ echo "$Prev"; } if($total_p>=11){ if($chk_page>=4){ echo "1. . ."; } if($chk_page<4){ for($i=0;$i<$total_p;$i++){ $nClass=($chk_page==$i)?"class='selectPage'":""; if($i<=4){ echo "".intval($i+1)." "; } if($i==$total_p-1 ){ echo ". . .".intval($i+1)." "; } } } if($chk_page>=4 && $chk_page<$lt_page){ $st_page=$chk_page-3; for($i=1;$i<=5;$i++){ $nClass=($chk_page==($st_page+$i))?"class='selectPage'":""; echo "".intval($st_page+$i+1)." "; } for($i=0;$i<$total_p;$i++){ if($i==$total_p-1 ){ $nClass=($chk_page==$i)?"class='selectPage'":""; echo ". . .".intval($i+1)." "; } } } if($chk_page>=$lt_page){ for($i=0;$i<=4;$i++){ $nClass=($chk_page==($lt_page+$i-1))?"class='selectPage'":""; echo "".intval($lt_page+$i)." "; } } }else{ for($i=0;$i<$total_p;$i++){ $nClass=($chk_page==$i)?"class='selectPage'":""; echo "".intval($i+1)." "; } } if($chk_page<$total_p-1){ echo "$Next"; } } /******************** END PAGE NAVIGATOR *********************/ /******************** FUNCTIONS *********************/ function rand12($length = 1) { $characters = '12'; $charactersLength = strlen($characters); $randomString = ''; for ($i = 0; $i < $length; $i++) { $randomString .= $characters[rand(0, $charactersLength - 1)]; } return $randomString; } function to_upper($name){ $name=ucwords(strtolower($name)); $arr=explode('-', $name); $name=array(); foreach($arr as $v) { $name[]=ucfirst($v); } $name=implode('-', $name); return $name; } function short_text($str, $limit) { $charset = 'UTF-8'; if(mb_strlen($str, $charset) > $limit) { return $string = mb_substr($str, 0, $limit, $charset) . '...'; //return mb_strlen($str, $charset).' > '.$limit; }else{ return $str; } } function seotitle($raw){ $raw = preg_replace('#[^-ก-๙a-zA-Z0-9]#u', '-', $raw); $raw = ereg_replace("-+","-",$raw); if(substr($raw,0,1) == '-') $raw = substr($raw,1); $raw = trim($raw); $raw = trim($raw,"-"); return strtolower(trim($raw)); } //clean the user's input function cleanInput($value, $link = ''){ //if the variable is an array, recurse into it if(is_array($value)){ //for each element in the array... foreach($value as $key => $val){ //...clean the content of each variable in the array $value[$key] = clean($val); //$value[$key] = cleanInput($val); } //return clean array return $value; }else{ return mysql_real_escape_string(strip_tags(trim($value)), $link); } } function cleanOutput($value, $link = ''){ //if the variable is an array, recurse into it if(is_array($value)){ //for each element in the array... foreach($value as $key => $val){ //...clean the content of each variable in the array $value[$key] = htmlspecialchars($val, ENT_QUOTES, "UTF-8"); } //return clean array return $value; }else{ return htmlspecialchars($value); } } function fetchAssoc($query){ $row = mysql_fetch_assoc($query); return cleanOutput($row); } //GET ENUM VALUES function getEnum( $table, $field ){ $sql = " SELECT COLUMN_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" . mysql_real_escape_string($table) . "' AND COLUMN_NAME = '" . mysql_real_escape_string($field) . "' "; $result = mysql_query($sql) or die (mysql_error()); $row = mysql_fetch_array($result); $enum_list = explode(",", str_replace("'", "", substr($row['COLUMN_TYPE'], 5, (strlen($row['COLUMN_TYPE'])-6)))); return $enum_list; } function getExtension($str){ $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return strtolower($ext); } function ShowDateLongTime($myDate) { $myTimeArray = explode(" ", $myDate); $myTime = explode(":",$myTimeArray[1]); $myDateArray = explode("-", $myDate); $myDay = sprintf("%d", $myDateArray[2]); switch ($myDateArray[1]) { case "01" : $myMonth = "มกราคม"; break; case "02" : $myMonth = "กุมภาพันธ์"; break; case "03" : $myMonth = "มีนาคม"; break; case "04" : $myMonth = "เมษายน"; break; case "05" : $myMonth = "พฤษภาคม"; break; case "06" : $myMonth = "มิถุนายน"; break; case "07" : $myMonth = "กรกฎาคม"; break; case "08" : $myMonth = "สิงหาคม"; break; case "09" : $myMonth = "กันยายน"; break; case "10" : $myMonth = "ตุลาคม"; break; case "11" : $myMonth = "พฤศจิกายน"; break; case "12" : $myMonth = "ธันวาคม"; break; } $myYear = sprintf("%d", $myDateArray[0]) + 543; return($myDay . " " . $myMonth . " " . $myYear . ", " . $myTime[0] . ":" . $myTime[1]); } function ShowDateLong($myDate) { $myTimeArray = explode(" ", $myDate); $myTime = explode(":",$myTimeArray[1]); $myDateArray = explode("-", $myDate); $myDay = sprintf("%d", $myDateArray[2]); switch ($myDateArray[1]) { case "01" : $myMonth = "มกราคม"; break; case "02" : $myMonth = "กุมภาพันธ์"; break; case "03" : $myMonth = "มีนาคม"; break; case "04" : $myMonth = "เมษายน"; break; case "05" : $myMonth = "พฤษภาคม"; break; case "06" : $myMonth = "มิถุนายน"; break; case "07" : $myMonth = "กรกฎาคม"; break; case "08" : $myMonth = "สิงหาคม"; break; case "09" : $myMonth = "กันยายน"; break; case "10" : $myMonth = "ตุลาคม"; break; case "11" : $myMonth = "พฤศจิกายน"; break; case "12" : $myMonth = "ธันวาคม"; break; } $myYear = sprintf("%d", $myDateArray[0]) + 543; return($myDay . " " . $myMonth . " " . $myYear); } function ShowDay($myDate) { $timestamp = strtotime($myDate); $day = date('w', $timestamp); switch ($day) { case "0" : $myDay = "อาทิตย์"; break; case "1" : $myDay = "จันทร์"; break; case "2" : $myDay = "อังคาร"; break; case "3" : $myDay = "พุธ"; break; case "4" : $myDay = "พฤหัสบดี"; break; case "5" : $myDay = "ศุกร์"; break; case "6" : $myDay = "เสาร์"; break; } return($myDay); } function ShowDateLongThDay($myDate) { $myDateArray = explode("-", $myDate); $myDay = sprintf("%d", $myDateArray[2]); switch ($myDateArray[1]) { case "01" : $myMonth = "มกราคม"; break; case "02" : $myMonth = "กุมภาพันธ์"; break; case "03" : $myMonth = "มีนาคม"; break; case "04" : $myMonth = "เมษายน"; break; case "05" : $myMonth = "พฤษภาคม"; break; case "06" : $myMonth = "มิถุนายน"; break; case "07" : $myMonth = "กรกฎาคม"; break; case "08" : $myMonth = "สิงหาคม"; break; case "09" : $myMonth = "กันยายน"; break; case "10" : $myMonth = "ตุลาคม"; break; case "11" : $myMonth = "พฤศจิกายน"; break; case "12" : $myMonth = "ธันวาคม"; break; } $myYear = sprintf("%d", $myDateArray[0]) + 543; return($myDay . " เดือน " . $myMonth . " พ.ศ. " . $myYear); } function ShowMount($mount) { switch ($mount) { case "01" : $myMonth = "มกราคม"; break; case "02" : $myMonth = "กุมภาพันธ์"; break; case "03" : $myMonth = "มีนาคม"; break; case "04" : $myMonth = "เมษายน"; break; case "05" : $myMonth = "พฤษภาคม"; break; case "06" : $myMonth = "มิถุนายน"; break; case "07" : $myMonth = "กรกฎาคม"; break; case "08" : $myMonth = "สิงหาคม"; break; case "09" : $myMonth = "กันยายน"; break; case "10" : $myMonth = "ตุลาคม"; break; case "11" : $myMonth = "พฤศจิกายน"; break; case "12" : $myMonth = "ธันวาคม"; break; } return($myMonth); } function ShowDateShortTime($myDate) { $myTimeArray = explode(" ", $myDate); $myTime = explode(":",$myTimeArray[1]); $myDateArray = explode("-", $myDate); $myDay = sprintf("%d", $myDateArray[2]); switch ($myDateArray[1]) { case "01" : $myMonth = "ม.ค."; break; case "02" : $myMonth = "ก.พ."; break; case "03" : $myMonth = "มี.ค."; break; case "04" : $myMonth = "เม.ย."; break; case "05" : $myMonth = "พ.ค"; break; case "06" : $myMonth = "มิ.ย"; break; case "07" : $myMonth = "ก.ค"; break; case "08" : $myMonth = "ส.ค."; break; case "09" : $myMonth = "ก.ย."; break; case "10" : $myMonth = "ต.ค."; break; case "11" : $myMonth = "พ.ย"; break; case "12" : $myMonth = "ธ.ค."; break; } $myYear = sprintf("%d", $myDateArray[0]) + 543; return($myDay . " " . $myMonth . " " . $myYear . ", " . $myTime[0] . ":" . $myTime[1]); } function ShowTime($myDate) { $myTimeArray = explode(" ", $myDate); $myTime = explode(":",$myTimeArray[1]); return($myTime[0] . ":" . $myTime[1]); } function ShowDateShort($myDate) { $myTimeArray = explode(" ", $myDate); $myTime = explode(":",$myTimeArray[1]); $myDateArray = explode("-", $myDate); $myDay = sprintf("%d", $myDateArray[2]); switch ($myDateArray[1]) { case "01" : $myMonth = "ม.ค."; break; case "02" : $myMonth = "ก.พ."; break; case "03" : $myMonth = "มี.ค."; break; case "04" : $myMonth = "เม.ย."; break; case "05" : $myMonth = "พ.ค"; break; case "06" : $myMonth = "มิ.ย"; break; case "07" : $myMonth = "ก.ค"; break; case "08" : $myMonth = "ส.ค."; break; case "09" : $myMonth = "ก.ย."; break; case "10" : $myMonth = "ต.ค."; break; case "11" : $myMonth = "พ.ย"; break; case "12" : $myMonth = "ธ.ค."; break; } $myYear = sprintf("%d", $myDateArray[0]) + 543; return($myDay . " " . $myMonth . " " . $myYear); } function convert( $str ) { return iconv( "Windows-1252", "UTF-8", $str ); } function convertNumtoTh($number) { $txtnum1 = array('ศูนย์', 'หนึ่ง', 'สอง', 'สาม', 'สี่', 'ห้า', 'หก', 'เจ็ด', 'แปด', 'เก้า', 'สิบ'); $txtnum2 = array('', 'สิบ', 'ร้อย', 'พัน', 'หมื่น', 'แสน', 'ล้าน', 'สิบ', 'ร้อย', 'พัน', 'หมื่น', 'แสน', 'ล้าน'); $number = str_replace(",", "", $number); $number = str_replace(" ", "", $number); $number = str_replace("บาท", "", $number); $number = explode(".", $number); if (sizeof($number) > 2) { return 'ทศนิยมหลายตัวนะจ๊ะ'; exit; } $strlen = strlen($number[0]); $substr = substr($number[0], -2, 1); $convert = ''; for ($i = 0; $i < $strlen; $i++) { $n = substr($number[0], $i, 1); if ($n != 0) { if ($i == ($strlen - 1) AND $n == 1) { if($substr != "0"){ $convert .= 'เอ็ด'; }else{ $convert .= 'หนึ่ง'; } } elseif ($i == ($strlen - 2) AND $n == 2) { $convert .= 'ยี่'; } elseif ($i == ($strlen - 8) AND $n == 2 AND $i == 0) { $convert .= 'ยี่'; } elseif ($i == ($strlen - 2) AND $n == 1) { $convert .= ''; } else { $convert .= $txtnum1[$n]; } $convert .= $txtnum2[$strlen - $i - 1]; } } $convert .= 'บาท'; if ($number[1] == '0' OR $number[1] == '00' OR $number[1] == '') { $convert .= 'ถ้วน'; } else { $strlen = strlen($number[1]); for ($i = 0; $i < $strlen; $i++) { $n = substr($number[1], $i, 1); if ($n != 0) { if ($i == ($strlen - 1) AND $n == 1) { $convert .= 'เอ็ด'; } elseif ($i == ($strlen - 2) AND $n == 2) { $convert .= 'ยี่'; } elseif ($i == ($strlen - 2) AND $n == 1) { $convert .= ''; } else { $convert .= $txtnum1[$n]; } $convert .= $txtnum2[$strlen - $i - 1]; } } $convert .= 'สตางค์'; } return $convert; } function padZero($input, $digit){ return str_pad($input, $digit, "0", STR_PAD_LEFT); } function getPriceReport($where){ $slist = mysql_query(" SELECT *, SUM(rec_receive_li.act_price) AS totalActPrice FROM rec_receive_li LEFT JOIN acc_price_list ON (rec_receive_li.price_id = acc_price_list.price_id) RIGHT JOIN rec_receive ON (rec_receive_li.rec_id = rec_receive.rec_id) LEFT JOIN acc_category ON (acc_price_list.cat_id = acc_category.cat_id) LEFT JOIN acc_list ON (acc_price_list.list_id = acc_list.list_id) WHERE $where ") or error(mysql_error(),__FILE__,__LINE__); $numrow = mysql_num_rows($slist); if($numrow > 0){ $row = mysql_fetch_array($slist); return $row['totalActPrice']; }else{ return ""; } } function getPriceSlipLi($where){ $slist = mysql_query(" SELECT rec_receive_li.act_price , acc_price_list.list_id , acc_list.cat_id FROM rec_receive_li LEFT JOIN acc_price_list ON (rec_receive_li.price_id = acc_price_list.price_id) LEFT JOIN acc_list ON (acc_price_list.list_id = acc_list.list_id) LEFT JOIN acc_category ON (acc_list.cat_id = acc_category.cat_id) WHERE $where ") or error(mysql_error(),__FILE__,__LINE__); $numrow = mysql_num_rows($slist); if($numrow > 0){ $total = 0; while($row = mysql_fetch_array($slist)){ $total += $row['act_price']; } return $total; }else{ return "0"; } } /******************** END FUNCTIONS *********************/ function get_tz_options($selectedzone, $label, $desc = '') { echo '
    '; echo '
    '; echo ' ' . $desc . '
    '; } //////////////// /// SOCCER ///// //////////////// function timeGMT($format){ date_default_timezone_set('GMT'); return date($format); } $stat_lang = 'th'; $state_ch = array(); if($stat_lang == 'th'){ $state_ch[0]="เลื่อน"; $state_ch[1]="ขัดจังหวะ"; $state_ch[2]="ขัด"; $state_ch[3]="ยังไม่ตัดสิน"; $state_ch[4]="ยกเลิก"; $state_ch[13]="
    จบ
    "; $state_ch[14]=" "; $state_ch[15]="ครึ่งแรก"; $state_ch[16]="
    ครึ่ง
    "; $state_ch[17]="ครึ่งหลัง"; $state_ch[18]="ล่วงเวลา"; }else{ $state_ch[0]="Postp."; $state_ch[1]="Pause"; $state_ch[2]="Abd"; $state_ch[3]="Pend."; $state_ch[4]="Cancel"; $state_ch[13]="FT"; $state_ch[14]=" "; $state_ch[15]="Part1"; $state_ch[16]="HT"; $state_ch[17]="Part2"; $state_ch[18]="Ot"; } $state_ch_en = array(); $state_ch_en[0]="Postp."; $state_ch_en[1]="Pause"; $state_ch_en[2]="Abd"; $state_ch_en[3]="Pend."; $state_ch_en[4]="Cancel"; $state_ch_en[13]="FT"; $state_ch_en[14]=" "; $state_ch_en[15]="Part1"; $state_ch_en[16]="HT"; $state_ch_en[17]="Part2"; $state_ch_en[18]="Ot"; //$datetimegmt = timeGMT("Y-m-d H:i:s"); $GoalCn = array("0", "0/0.5", "0.5", "0.5/1", "1", "1/1.5", "1.5", "1.5/2", "2", "2/2.5", "2.5", "2.5/3", "3", "3/3.5", "3.5", "3.5/4", "4", "4/4.5", "4.5", "4.5/5", "5", "5/5.5", "5.5", "5.5/6", "6", "6/6.5", "6.5", "6.5/7", "7", "7/7.5", "7.5", "7.5/8", "8", "8/8.5", "8.5", "8.5/9", "9", "9/9.5", "9.5", "9.5/10", "10", "10/10.5", "10.5", "10.5/11", "11", "11/11.5", "11.5", "11.5/12", "12", "12/12.5", "12.5", "12.5/13", "13", "13/13.5", "13.5", "13.5/14", "14"); $GoalCn2 = array("0", "0/-0.5", "-0.5", "-0.5/-1", "-1", "-1/-1.5", "-1.5", "-1.5/-2", "-2", "-2/-2.5", "-2.5", "-2.5/-3", "-3", "-3/-3.5", "-3.5", "-3.5/-4", "-4", "-4/-4.5", "-4.5", "-4.5/-5", "-5", "-5/-5.5", "-5.5", "-5.5/-6", "-6", "-6/-6.5", "-6.5", "-6.5/-7", "-7", "-7/-7.5", "-7.5", "-7.5/-8", "-8", "-8/-8.5", "-8.5", "-8.5/-9", "-9", "-9/-9.5", "-9.5", "-9.5/-10", "-10"); function Goal2GoalCn($goal){ //handicap conversion global $GoalCn, $GoalCn2; if ($goal > 0) { $Odd = $GoalCn[$goal * 4]; } else { $Odd = $GoalCn2[$goal * (-4)]; } return $Odd; } function ConOdds($odds=""){ if($odds > 1){ $newodds = $odds + 1; $num = 1 / (1 - $newodds); $odds = number_format($num,2); } return $odds; } ?> ดูบอลออนไลน์ ผลบอล ผลบอลสด ผลบอลย้อนหลัง โปรแกรมบอล Livescore
    โปรแกรมบอลวันนี้ ผลบอลสด ราคาไหล ประจำวันที่