0 ) { return mysql_data_seek($result,$str); } } // add MYSQL function add_db($column_ , $values_ ,$tb_) { $result = mysql_query('select * from '. $tb_ ); for ($i=0;$i < count($column_);$i++) { $meta = mysql_fetch_field($result, $column_[$i]); if($i==(count($column_)-1)) $comma=''; else $comma=','; $column_data[]=$meta->name.$comma ; } for($i=0;$iname."='".$values_[$i]."'".$comma; } $sql="update $tb_ set "; foreach ($set as $key) { $sql.= $key; } $sql.=" where $where_ "; return "$sql"; } // delete MYSQL function delete_db($tb_,$where_){ $sql="delete from $tb_ "; $sql.=" where $where_ "; return "$sql"; } function imageResize($parameters) { $fileTmp = $parameters['sourceFile']; //$_FILES['Filedata']['tmp_name']; $imageInfo = $parameters['imageInfo']; $outputFile = $parameters['destinationFile']; $newWidth = $resizeWidth = $parameters['width']; //120; $newHeight = $resizeHeight = $parameters['height']; //90; $origRatio = $imageInfo[0]/$imageInfo[1]; $offsetX = $offsetY = 0; $resizeRatio= $resizeWidth/$resizeHeight; if($imageInfo[0]<$resizeWidth && $imageInfo[1]<$resizeHeight) { @copy($fileTmp,$outputFile); return; } switch($imageInfo[2]) { case 1: $origImg = imagecreatefromgif($fileTmp); break; case 2: $origImg = imagecreatefromjpeg($fileTmp); break; default: $origImg = imagecreatefrompng($fileTmp); break; } $method = 'scale'; if($parameters['method']) $method = $parameters['method']; if($method == 'crop' && ($imageInfo[0]<$resizeWidth || $imageInfo[1]<$resizeHeight)) $method = 'scale'; if($method == 'scale') { if($origRatio > $resizeRatio) { $quot = $resizeWidth / $imageInfo[0]; $resizeHeight = $newHeight = round($imageInfo[1]*$quot); $newWidth = $resizeWidth; } else if( $origRatio < $resizeRatio) { $quot = $resizeHeight / $imageInfo[1]; $resizeWidth = $newWidth = round($imageInfo[0]*$quot); $newHeight = $resizeHeight; } } else if($method=='crop') { if($origRatio > $resizeRatio) { $quot = $resizeHeight / $imageInfo[1]; $newHeight = $resizeHeight; $newWidth = round($imageInfo[0]*$quot); $offsetX = round( (($newWidth-$resizeWidth)/2)/$quot ); } else if( $origRatio < $resizeRatio) { $quot = $resizeWidth / $imageInfo[0]; $newWidth = $resizeWidth; $newHeight = round($imageInfo[1]*$quot); $offsetY = round( (($newHeight-$resizeHeight)/2)/$quot ); } } $newImg = imagecreatetruecolor($resizeWidth,$resizeHeight); imagecopyresampled($newImg, $origImg, 0, 0,$offsetX,$offsetY, $newWidth, $newHeight, $imageInfo[0], $imageInfo[1]); switch($imageInfo[2]) { case 1: imagegif($newImg, $outputFile); break; case 2: imagejpeg($newImg, $outputFile,100); break; default: imagepng($newImg, $outputFile); break; } imagedestroy($newImg); imagedestroy($origImg); } function let_to_num($v) { $l = substr($v, -1); $ret = substr($v, 0, -1); switch(strtoupper($l)) { case 'P': $ret *= 1024; case 'T': $ret *= 1024; case 'G': $ret *= 1024; case 'M': $ret *= 1024; case 'K': $ret *= 1024; break; } return $ret; } function show_select($tbl, $id, $field, $whr){ global $prefix_table; $result = q("select ".$field." from ".$prefix_table.$tbl." where ".(($whr == "")?"id":$whr)." = '$id' "); $arr = q_array($result); return $arr[$field]; } function project_name($id){ global $prefix_table; $result = q("select * from ".$prefix_table."projects where id = '$id' "); $arr = q_array($result); return $arr[name]; } function return_link($url,$time=0){ $time = $time*1000; //echo ""; //plasewait(_PLEASEWAIT); echo ""; } /* function return_link($link){ echo ""; } */ function show_alert($msg){ echo ""; } function check_lang($str_th, $str_en){ global $_SESSION; if($_SESSION['lang'] == "th"){ return $str_th; }else{ return $str_en; } } function conhtml($str){ $str = htmlspecialchars($str, ENT_QUOTES); return $str; } function clearhtml($str) { return strip_tags($str); } function cutstring($str, $len) { //if (strlen($str)<=$len) return $str; // else return sprintf("%.".$len."s", strip_tags($str))."..."; if(strlen($str) > $len){ $p = "..."; } return iconv_substr($str, 0, $len, "UTF-8").$p; } function picyoutube($link, $t=1){ $arr_link = explode("v=", $link); $arr_link1 = explode("&", $arr_link[1]); if(count($arr_link1) == 1){ $link = $arr_link[1]; }else{ $link = $arr_link1[0]; } if($t == 1){ //320*180 return "http://img.youtube.com/vi/".$link."/mqdefault.jpg"; }else if($t ==2){ //640*480 return "http://img.youtube.com/vi/".$link."/hqdefault.jpg"; } } function tag($str){ $arr = explode(",", $str); for($i=0;$i$arr[$i] "; } return $link1; } function convertdate($datetime, $display=1, $type=1){ global $_SESSION; if($datetime){ list($date,$time1) = split(" ",$datetime); $arrtime = explode(":", $time1); $time = $arrtime[0].":".$arrtime[1]; $date_array = explode("-",$date); $y = $date_array[0]; $m = $date_array [1]-1; $d = $date_array[2]; if($display == 1){ $month = explode(",", "Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec"); $m = $month[$m]; }else if($display == 2){ $month = explode(",", "มกราคม,กุมภาพันธ์,มีนาคม,เมษายน,พฤษภาคม,มิถุนายน,กรกฏาคม,สิงหาคม,กันยายน,ตุลาคม,พฤศจิกายน,ธันวาคม"); $m = $month[$m]; }else if($display == 3){ $m = $date_array [1]; } if($type == 1){ $displaydate = "$m $y"; }else if($type == 2){ $displaydate = "$d/$m/$y"; }else if($type == 3){ $displaydate = "$d $m $y $time"; } }else{ $displaydate = "-"; } return $displaydate; } function caldatarolling($date, $datarolling){ $arrdate_start = explode("-", $date); $date_expire = mktime(0,0,0,($arrdate_start[1]-$datarolling),01,$arrdate_start[0]); $date_expire =date("Y-m", $date_expire); return $date_expire; } function caldatarolling1($date, $datarolling){ $arrdate_start = explode("-", $date); $date_expire = mktime(0,0,0,($arrdate_start[1]+$datarolling),01,$arrdate_start[0]); $date_expire =date("Y-m", $date_expire); return $date_expire; } function time_elapsed_string($ptime) { $etime = time() - $ptime; if ($etime < 1) { return '0 seconds'; } $a = array( 12 * 30 * 24 * 60 * 60 => 'year', 30 * 24 * 60 * 60 => 'month', 7 * 24 * 60 * 60 => 'week', 24 * 60 * 60 => 'day', 60 * 60 => 'hour', 60 => 'minute', 1 => 'second' ); foreach ($a as $secs => $str) { $d = $etime / $secs; if ($d >= 1) { $r = round($d); if($r == 1 && $str == 'day'){ return 'Yesterdays'; }if($str == 'hour' || $str == 'minute' || $str == 'second'){ return 'Todays'; }else{ return 'days ago'; //return $r . ' ' . $str . ($r > 1 ? ' agos' : ''); } } } } function time_stamp($time){ $arrtime = explode(" ", $time); $arrtime1 = explode("-", $arrtime[0]); $arrtime2 = explode(":", $arrtime[1]); return mktime($arrtime2[0],$arrtime2[1],$arrtime2[2],$arrtime1[1],$arrtime1[2],$arrtime1[0]); } function CheckRude($temp){ $wordrude = array("ashole","a s h o l e","a.s.h.o.l.e","bitch","b i t c h","b.i.t.c.h","shit","s h i t","s.h.i.t","fuck","dick","f u c k","d i c k","f.u.c.k","d.i.c.k","มึง","มึ ง","ม ึ ง","ม ึง","มงึ","มึ.ง","มึ_ง","มึ-ง","มึ+ง","กู","ควย","ค ว ย","ค.ว.ย","คอ วอ ยอ","คอ-วอ-ยอ","ปี้","เหี้ย","ไอ้เหี้ย","เฮี้ย","ชาติหมา","ชาดหมา","ช า ด ห ม า","ช.า.ด.ห.ม.า","ช า ติ ห ม า","ช.า.ติ.ห.ม.า","สัดหมา","สัด","เย็ด","หี","สันดาน","แม่ง","ระยำ","ส้นตีน","แตด") ; $wordchange = ("xxx") ; for ( $i=0 ; $i $v){ $count += $v; } } return $count; } function pricepro($price, $discount, $d_price, $d_percent, $t){ if($discount == 1){ $tprice['price'] = $price; $tprice['price_show'] = number_format($price); }else if($discount == 2){ $tprice['price'] = ($price-$d_price); $tprice['price_show'] = "฿".number_format($price)." ฿".number_format($tprice['price']); }else if($discount == 3){ $tprice1 = ($price*$d_percent)/100; $tprice['price'] = ($price-$tprice1); $tprice['price_show'] = "฿".number_format($price)." ฿".number_format($tprice['price']); } if($t == 1){ return $tprice['price_show']; }else{ return $tprice['price']; } } function totalcart(){ foreach($_SESSION['cart'] as $k => $v){ $sql = q("select * from 01_products where id = '".$v[pro_id]."' "); $arr = mysql_fetch_assoc($sql); $price1 = pricepro($arr[price], $arr[discount], $arr[discount_price], $arr[discount_percent],1); $price2 = pricepro($arr[price], $arr[discount], $arr[discount_price], $arr[discount_percent],0); $price3 = $price2*$v[qty]; $price_total = $price3+$price_total; $proall = $v[qty]+$proall; } $data[0] = number_format($proall); $data[1] = number_format($price_total); return $data; } function setconstant(){ $arrsep[] = strtoupper(dechex(ord("~")) . dechex(ord("|"))); $arrsep[] = strtoupper(dechex(ord("|")) . dechex(ord("~"))); $arrsep[] = strtoupper(dechex(ord("@")) . dechex(ord("|"))); $arrsep[] = strtoupper(dechex(ord("|")) . dechex(ord("@"))); $arrsep[] = strtoupper(dechex(ord("~")) . dechex(ord("@"))); $arrsep[] = strtoupper(dechex(ord("@")) . dechex(ord("~"))); $arrsep[] = strtoupper(dechex(ord("~")) . dechex(ord("^"))); $arrsep[] = strtoupper(dechex(ord("^")) . dechex(ord("~"))); $arrsep[] = strtoupper(dechex(ord("^")) . dechex(ord("@"))); $arrsep[] = strtoupper(dechex(ord("@")) . dechex(ord("^"))); return $arrsep; } function encode($strencode, $intfixed = -1){ if (trim($strencode) == ""){ return ""; } $arrchk = setconstant(); $intrand = ($intfixed == -1) ? rand(0, 9) : $intfixed; $strtmp = ""; for ($i = 0; $i <= (strlen($strencode) - 1); $i++){ $chartmp = substr($strencode, $i, 1); $decvalue = ord($chartmp); $strhex = dechex($decvalue) . $arrchk[$intrand]; $strtmp .= $strhex; } $strtmp = strtolower(substr($strtmp, 0, -(strlen($arrchk[$intrand])))); return base64_encode($strtmp) . $intrand; } function decode($strdecode){ if (trim($strdecode) == ""){ return ""; } $arrchk = setconstant(); $inttype = substr($strdecode, -1); if (!is_numeric($inttype)){ return $strdecode; } $strdecode = strtoupper(base64_decode(substr($strdecode, 0, -1))); $arrexp = explode($arrchk[$inttype], $strdecode); foreach ($arrexp as $value){ $strtmp .= chr(hexdec($value)); } return $strtmp; } function insertzero($str, $count){ return str_pad( $str , $count, "0" , STR_PAD_LEFT ); } function timeAgo($time_ago) { $time_ago = strtotime($time_ago); $cur_time = time(); $time_elapsed = $cur_time - $time_ago; $seconds = $time_elapsed ; $minutes = round($time_elapsed / 60 ); $hours = round($time_elapsed / 3600); $days = round($time_elapsed / 86400 ); $weeks = round($time_elapsed / 604800); $months = round($time_elapsed / 2600640 ); $years = round($time_elapsed / 31207680 ); // Seconds if($seconds <= 60){ return "just now"; } //Minutes else if($minutes <=60){ if($minutes==1){ return "one minute ago"; } else{ return "$minutes minutes ago"; } } //Hours else if($hours <=24){ if($hours==1){ return "an hour ago"; }else{ return "$hours hrs ago"; } } //Days else if($days <= 7){ if($days==1){ return "yesterday"; }else{ return "$days days ago"; } } //Weeks else if($weeks <= 4.3){ if($weeks==1){ return "a week ago"; }else{ return "$weeks weeks ago"; } } //Months else if($months <=12){ if($months==1){ return "a month ago"; }else{ return "$months months ago"; } } //Years else{ if($years==1){ return "one year ago"; }else{ return "$years years ago"; } } } $id = $_GET[id]; $cid = $_GET[cid]; $module = $_GET[module]; $action = $_GET[action]; $rowkey = $_GET[rowkey]; $cat = $_GET[cat]; $p = $_GET[p]; $page = $_GET[page]; $ipp = $_GET[ipp]; if($module == ""){ $module = "home"; } if($action == ""){ $action = "index"; } if($rowkey == "add"){ $txtdialog = "Add"; }else if($rowkey == "edit"){ $txtdialog = "Edit"; } $lang=(isset($_GET["lang"]))?$_GET["lang"]:$_SESSION["lang"]; if ($lang == "") $lang='th'; $_SESSION["lang"] = $lang; ?>