.:: :[ AK-74 Security Team Web-shell ]: ::.
phpinfo()
PHP
<?php function sql_query($sql, $return_insert_id=false) { global $hostname; global $dbUsername; global $dbPassword; global $dbName; //global $conn; $conn = mysqli_connect($hostname,$dbUsername,$dbPassword) or die("connection to db fail"); mysqli_select_db($conn, $dbName); mysqli_query($conn, "set names 'utf8'"); $query = mysqli_query($conn, $sql); if ($return_insert_id) { $query = mysqli_insert_id($conn); } mysqli_close($conn); return $query; } // end function function querySQL($sql, $return_insert_id=false) { function sql_fetch_array($query) { return mysqli_fetch_array($query); } function sql_num_rows($query) { return mysqli_num_rows($query); } function sql_data_seek($query, $index) { return mysqli_data_seek($query, $index); } function connectDB() { global $hostname; global $dbUsername; global $dbPassword; global $dbName; global $conn; $conn = mysql_connect($hostname,$dbUsername,$dbPassword) or die("connection to db fail"); mysql_select_db($dbName); mysql_query("set names 'utf8'"); } // end function function disConnectDB() { global $conn; mysql_close($conn); } // end function function format_date_en ($value,$type) { if (strlen ($value) > 10) { list ($s_date,$s_time) = explode (" ", $value); list ($s_year, $s_month, $s_day) = explode ("-", $s_date); list ($s_hour, $s_minute, $s_second) = explode (":", $s_time); } else { list ($s_year, $s_month, $s_day) = explode ("-", $value); } $s_month +=0; $s_day += 0; if ($s_day == "0") return ""; if ($s_hour == '') $s_hour = 0; if ($s_minute == '') $s_minute = 0; if ($s_second == '') $s_second = 0; $mktime = @mktime ($s_hour, $s_minute, $s_second, $s_month, $s_day, $s_year); switch ($type) { case "1" : // Friday 11 November 2005 $msg = @date ("l d F Y", $mktime); break; case "2" : // 11 Nov 05 $msg = @date ("d M y", $mktime); break; case "3" : // Friday 11 November 2005 00:11 $msg = @date ("l d F Y H:m", $mktime); break; case "4" : // 11 Nov 05 00:11 $msg = @date ("d M y H:m", $mktime); break; case "5" : // 11 Nov 05 00:11 $msg = @date ("d M Y", $mktime); break; case "6" : // Nov 05 $msg = @date ("M d", $mktime); break; case "7" : // $msg = date ("d/m/y", $mktime); break; } return ($msg); } function format_date_th ($value,$type) { if (strlen ($value) > 10) { list ($s_date,$s_time) = explode (" ", $value); list ($s_year, $s_month, $s_day) = explode ("-", $s_date); list ($s_hour, $s_minute, $s_second) = explode (":", $s_time); } else { list ($s_year, $s_month, $s_day) = explode ("-", $value); } $s_month +=0; $s_day += 0; if ($s_day == "0") return ""; $s_year += 543; $month_full_th = array ('','มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม','กันยายน', 'ตุลาคม', 'พฤศจิกายน','ธันวาคม'); $month_brief_th = array ('','ม.ค.','ก.พ.','มี.ค.','เม.ย.','พ.ค.','มิ.ย.','ก.ค.','ส.ค.','ก.ย.','ต.ค.','พ.ย.','ธ.ค.'); $day_of_week = array("จันทร์","อังคาร","พุธ","พฤหัส","ศุกร์","เสาร์","อาทิตย์"); switch ($type) { case "1" : // ?????? 4 ????????? 2548 $msg = "วันที่ ". $s_day . " " . $month_full_th[$s_month] . " " . $s_year ; break; case "2" : // 4 ?.?. 2548 $msg = $s_day . " " . $month_brief_th[$s_month] . " " . $s_year ; break; case "3" : // ?????? 4 ????????? 2548 ???? 14.11 ?. $msg = "วันที่ ". $s_day . " " . $month_full_th[$s_month] . " " . $s_year . " ???? " . $s_hour . "." . $s_minute . " ?." ; break; case "4" : // 4 ?.?. 2548 14.11 ?. $msg = $s_day . " " . $month_brief_th[$s_month] . " " . $s_year . " " . $s_hour . "." . $s_minute . " ?." ; break; case "5" : // 4 ?.?. 2548 $msg = $s_day . " " . $month_brief_th[$s_month] . " " . $s_year ; break; case "6" : // 4 ?.?. 2548 $msg = $s_day . " / " . $s_month . " / " . substr($s_year, -2) ; break; case "7" : $msg = $s_day . " " . $month_brief_th[$s_month] . " " . substr($s_year, -2) ; break; case "8" : $msg = $s_day . " " . $month_brief_th[$s_month] . " " . substr($s_year, -2) . ", " . $s_hour . ":" . $s_minute . ":" . $s_second ; break; case "9" : // 4 ?.?. 2548 $msg = $s_day . "-" . $s_month . "-" . substr($s_year, -2) ; break; } return ($msg); } function gen_random ($length) { $keychars = "abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ23456789"; // RANDOM KEY GENERATOR $randkey = ""; $max=strlen($keychars)-1; for ($i=1;$i<=$length;$i++) { $randkey .= substr($keychars, rand(0, $max), 1); } return $randkey; } function gen_random2 ($length , $type) { switch($type) { case '1' : $keychars = "ABCDEFGHJKMNPQRSTUVWXYZ123456789"; break; case '2' : $keychars = "0123456789"; break; case '3' : $keychars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; break; }// end switch // RANDOM KEY GENERATOR $randkey = ""; $max=strlen($keychars)-1; for ($i=1;$i<=$length;$i++) { $randkey .= substr($keychars, rand(0, $max), 1); } return $randkey; } function Show_Data ($tbl_name, $key, $value, $fieldname) { $sql = "select * from $tbl_name where $key like '" . $value . "'"; $query = sql_query ($sql); $fields = explode (":", $fieldname); $msg = ""; if ($rec = sql_fetch_array ($query)) { foreach ($fields as $key => $value ) { $msg .= " : " . $rec[$value]; } $msg = substr ($msg, 3); } return $msg; } function Show_Sort ($orderby, $cn, $field_select, $sortby,$page) { global $FK_field; global $$FK_field; if ($sortby <> "" and ($orderby == $field_select)) $img = '<img src="/admin/icons/' . $sortby . '.gif">'; if ($sortby == "desc" or $sortby == "") $sortby = "asc"; else $sortby = "desc"; if ($orderby <> $field_select) $sortby = "asc"; $param = "orderby=$orderby"; if ($FK_field <> "") $param .= "&" . $FK_field . "=" . $$FK_field; if ($sortby <> "") $param .= "&sortby=$sortby"; if ($keyword <> "") $param .= "&keyword=$keyword"; if ($page <> "") $param .= "&page=$_GET[page]"; $link_1 = "<a href ='" . $_SERVER['SCRIPT_NAME'] ."?" . $param ."'>"; $url = $link_1 . $cn . "</a>" ; if ($sortby <> "") $url .= $img; echo $url; } function Show_Sort_new ($orderby, $cn, $field_select, $sortby,$page,$param) { global $FK_field; global $$FK_field; if ($sortby <> "" and ($orderby == $field_select)) $img = '<img src="../icons/' . $sortby . '.gif">'; if ($sortby == "desc" or $sortby == "") $sortby = "asc"; else $sortby = "desc"; if ($orderby <> $field_select) $sortby = "asc"; $param .= "&orderby=".$orderby."&sortby=".$sortby; $link_1 = "<a href ='" . $_SERVER['SCRIPT_NAME'] ."?" . $param ."'>"; $url = $link_1 . $cn . "</a>" ; if ($sortby <> "") $url .= $img; echo $url; } function Show_Sort_bg ($field, $sortby) { if ($field == $sortby) { echo 'class="sort"'; } } function date_diff_php($date_from,$date_to,$unit='d') /* Calculates difference from date_from to date_to, taking into account leap years if date_from > date_to, the number of days is returned negative date_from and date_to format is: "dd-mm-yyyy" It can calculate ANY date difference, for example between 21-04-345 and 11-11-3412 This is possible by mapping any date to the "range 0" dates, as this table shows: INI END RANGE LEAP YEARS ... ... ... ... 01/01/1920 01/01/1939 -3 5 01/01/1940 01/01/1959 -2 5 01/01/1960 01/01/1979 -1 5 01/01/1980 01/01/1999 0 5 * this is the range used for calculations with mktime 01/01/2000 01/01/2019 1 5 01/01/2020 01/01/2039 2 5 01/01/2040 01/01/2059 3 5 01/01/2060 01/01/2079 4 5 ... ... ... ... The difference is calculated in the unit specified by $unit (default is "days") $unit: 'd' or 'D' = days 'y' or 'Y' = years */ { //get parts of the dates $date_from_parts = explode('-', $date_from); $date_to_parts = explode('-', $date_to); $day_from = $date_from_parts[2]; $mon_from = $date_from_parts[1]; $year_from = $date_from_parts[0]; $day_to = $date_to_parts[2]; $mon_to = $date_to_parts[1]; $year_to = $date_to_parts[0]; //if date_from is newer than date to, invert dates $sign=1; if ($year_from>$year_to) $sign=-1; else if ($year_from==$year_to) { if ($mon_from>$mon_to) $sign=-1; else if ($mon_from==$mon_to) if ($day_from>$day_to) $sign=-1; } if ($sign==-1) {//invert dates $day_from = $date_to_parts[2]; $mon_from = $date_to_parts[1]; $year_from = $date_to_parts[0]; $day_to = $date_from_parts[2]; $mon_to = $date_from_parts[1]; $year_to = $date_from_parts[0]; } switch ($unit) { case 'd': case 'D': //calculates difference in days $yearfrom1=$year_from; //actual years $yearto1=$year_to; //(yearfrom2 and yearto2 are used to calculate inside the range "0") //checks ini date if ($yearfrom1<1980) {//year is under range 0 $deltafrom=-floor((1999-$yearfrom1)/20)*20; //delta t1 $yearfrom2=$yearfrom1-$deltafrom; //year used for calculations } else if($yearfrom1>1999) {//year is over range 0 $deltafrom=floor(($yearfrom1-1980)/20)*20; //delta t1 $yearfrom2=$yearfrom1-$deltafrom; //year used for calculations } else {//year is in range 0 $deltafrom=0; $yearfrom2=$yearfrom1; } //checks end date if ($yearto1<1980) {//year is under range 0 $deltato=-floor((1999-$yearto1)/20)*20; //delta t2 $yearto2=$yearto1-$deltato; //year used for calculations } else if($yearto1>1999) {//year is over range 0 $deltato=floor(($yearto1-1980)/20)*20; //delta t2 $yearto2=$yearto1-$deltato; //year used for calculations } else {//year is in range 0 $deltato=0; $yearto2=$yearto1; } //Calculates the UNIX Timestamp for both dates (inside range 0) $ts_from = mktime(0, 0, 0, $mon_from, $day_from, $yearfrom2); $ts_to = mktime(0, 0, 0, $mon_to, $day_to, $yearto2); $diff = ($ts_to-$ts_from)/86400; //adjust ranges $diff += 7305 * (($deltato-$deltafrom) / 20); return $sign*$diff; break; case 'y': case 'Y': //calculates difference in years $diff=$year_to-$year_from; $adjust=0; if ($mon_from>$mon_to) $adjust=-1; else if ($mon_from==$mon_to) if ($day_from>$day_to) $adjust=-1; return $sign*($diff+$adjust); break; } } function make_thumb($input_file_name, $input_file_path, $width, $quality) { global $config; $config[thumbnail_width] = $width; $config[thumbnail_height] = $width; $imagedata = GetImageSize( "$input_file_path" . "$input_file_name" ); $imagewidth = $imagedata[0]; $imageheight = $imagedata[1]; $imagetype = $imagedata[2]; // type definitions // 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP // 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order) // 9 = JPC, 10 = JP2, 11 = JPX $thumb_name = $input_file_name; //by default if ($imagetype == 2){ $shrinkage = 1; if ($imagewidth > $imageheight) { if ($imagewidth > $config[thumbnail_width]){ $shrinkage = $config[thumbnail_width]/$imagewidth; $dest_height = $shrinkage * $imageheight; $dest_width = $config[thumbnail_width]; } else { $dest_height = $imageheight; $dest_width = $imagewidth; } } else { if ($imageheight > $config[thumbnail_height]){ $shrinkage = $config[thumbnail_height]/$imageheight; $dest_width = $shrinkage * $imagewidth; $dest_height = $config[thumbnail_height]; } else { $dest_height = $imageheight; $dest_width = $imagewidth; } } $src_img = imagecreatefromjpeg("$input_file_path/$input_file_name"); $dst_img=imagecreatetruecolor($dest_width,$dest_height); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width,$dest_height, $imagewidth, $imageheight); $thumb_name = "$input_file_name"; imagejpeg($dst_img, "$input_file_path/$thumb_name", $quality); imagedestroy($src_img); imagedestroy($dst_img); } // end if $imagetype == 2 return $thumb_name; } // end function make_thumb function make_thumb2($input_file_name, $input_file_path, $width, $quality, $actionFix) { global $config; $config[thumbnail_width] = $width; $config[thumbnail_height] = $width; $imagedata = GetImageSize( "$input_file_path" . "$input_file_name" ); $imagewidth = $imagedata[0]; $imageheight = $imagedata[1]; $imagetype = $imagedata[2]; // type definitions // 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP // 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order) // 9 = JPC, 10 = JP2, 11 = JPX $thumb_name = $input_file_name; //by default $shrinkage = 1; //if ($imagewidth > $imageheight) { if ($actionFix == 'width') { if ($imagewidth > $config[thumbnail_width]){ $shrinkage = $config[thumbnail_width]/$imagewidth; $dest_height = $shrinkage * $imageheight; $dest_width = $config[thumbnail_width]; } else { $dest_height = $imageheight; $dest_width = $imagewidth; } } elseif ($actionFix == 'height') { if ($imageheight > $config[thumbnail_height]){ $shrinkage = $config[thumbnail_height]/$imageheight; $dest_width = $shrinkage * $imagewidth; $dest_height = $config[thumbnail_height]; } else { $dest_height = $imageheight; $dest_width = $imagewidth; } } if ($imagetype == 1){ return true; $src_img = imagecreatefromgif("$input_file_path/$input_file_name"); } elseif ($imagetype == 2) { $src_img = imagecreatefromjpeg("$input_file_path/$input_file_name"); } elseif ($imagetype == 3) { $src_img = imagecreatefrompng("$input_file_path/$input_file_name"); } // end if $imagetype == 2 $dst_img=@imagecreatetruecolor($dest_width,$dest_height); @imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width,$dest_height, $imagewidth, $imageheight); $thumb_name = "$input_file_name"; @imagejpeg($dst_img, "$input_file_path/$thumb_name", $quality); @imagedestroy($src_img); @imagedestroy($dst_img); return $thumb_name; } // end function make_thumb function make_thumbBanner($input_file_name, $input_file_path, $width, $quality, $actionFix) { global $config; $config[thumbnail_width] = $width; $config[thumbnail_height] = $width; $imagedata = GetImageSize( "$input_file_path" . "$input_file_name" ); $imagewidth = $imagedata[0]; $imageheight = $imagedata[1]; $imagetype = $imagedata[2]; // type definitions // 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP // 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order) // 9 = JPC, 10 = JP2, 11 = JPX $thumb_name = $input_file_name; //by default $shrinkage = 1; //if ($imagewidth > $imageheight) { if ($actionFix == 'width') { if ($imagewidth > $config[thumbnail_width]){ $shrinkage = $config[thumbnail_width]/$imagewidth; $dest_height = $shrinkage * $imageheight; $dest_width = $config[thumbnail_width]; } else { $dest_height = $imageheight; $dest_width = $imagewidth; } } elseif ($actionFix == 'height') { if ($imageheight > $config[thumbnail_height]){ $shrinkage = $config[thumbnail_height]/$imageheight; $dest_width = $shrinkage * $imagewidth; $dest_height = $config[thumbnail_height]; } else { $dest_height = $imageheight; $dest_width = $imagewidth; } } if ($imagetype == 1){ return true; $src_img = imagecreatefromgif("$input_file_path/$input_file_name"); } elseif ($imagetype == 2) { $src_img = imagecreatefromjpeg("$input_file_path/$input_file_name"); } elseif ($imagetype == 3) { $src_img = imagecreatefrompng("$input_file_path/$input_file_name"); } // end if $imagetype == 2 $dst_img=imagecreatetruecolor($dest_width,$dest_height); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $dest_width,$dest_height, $imagewidth, $imageheight); $thumb_name = "$input_file_name"; imagejpeg($dst_img, "$input_file_path/$thumb_name", $quality); imagedestroy($src_img); imagedestroy($dst_img); return $thumb_name; } // end function make_thumbBanner function make_thumb3($input_file_name, $input_file_path, $width, $quality, $actionFix, $bgWidth, $bgHeight, $myImageType) { global $config; $config[thumbnail_width] = $width; $config[thumbnail_height] = $width; $imagedata = GetImageSize( "$input_file_path" . "$input_file_name" ); $imagewidth = $imagedata[0]; $imageheight = $imagedata[1]; $imagetype = $imagedata[2]; $position_y = 0; // type definitions // 1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP // 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order) // 9 = JPC, 10 = JP2, 11 = JPX $thumb_name = $input_file_name; //by default $shrinkage = 1; //if ($imagewidth > $imageheight) { if ($actionFix == 'width') { if ($imagewidth > $config[thumbnail_width]){ $shrinkage = $config[thumbnail_width]/$imagewidth; $dest_height = $shrinkage * $imageheight; $dest_width = $config[thumbnail_width]; } else { $dest_height = $imageheight; $dest_width = $imagewidth; } if ($myImageType == 'panorama') { $position_y = round($bgHeight/2)- round($dest_height/2); } } elseif ($actionFix == 'height') { if ($imageheight > $config[thumbnail_height]){ $shrinkage = $config[thumbnail_height]/$imageheight; $dest_width = $shrinkage * $imagewidth; $dest_height = $config[thumbnail_height]; } else { $dest_height = $imageheight; $dest_width = $imagewidth; } } if ($imagetype == 1){ $src_img = imagecreatefromgif("$input_file_path/$input_file_name"); } elseif ($imagetype == 2) { $src_img = imagecreatefromjpeg("$input_file_path/$input_file_name"); } elseif ($imagetype == 3) { $src_img = imagecreatefrompng("$input_file_path/$input_file_name"); } // end if $imagetype == 2 //$dst_img=imagecreatetruecolor($dest_width,$dest_height); $dst_img=imagecreatetruecolor($bgWidth,$bgHeight); $bgcolor = imagecolorallocate($dst_img, 249, 249, 249); imagefill($dst_img, 0, 0, $bgcolor); imagecopyresampled($dst_img, $src_img, 0, $position_y, 0, 0, $dest_width,$dest_height, $imagewidth, $imageheight); $thumb_name = "$input_file_name"; imagejpeg($dst_img, "$input_file_path/$thumb_name", $quality); imagedestroy($src_img); imagedestroy($dst_img); return $thumb_name; } // end function make_thumb function uploadfile($input_file_path, $input_file_name, $file, $sizes, $quality){ $version="linux"; if ($file != "") { if (!copy($file, $input_file_path . $input_file_name)) { echo ("failed to copy $file_name...<br>\n"); } if ($version!="windows"){ $pic=$input_file_path.$input_file_name; $size = GetImageSize("$pic") ; $w=$size[0] ; $h=$size[1]; make_thumb($input_file_name, $input_file_path, $sizes, $quality); } } } function uploadfile2($input_file_path, $input_file_name, $file, $width , $quality, $actionFix){ $version="linux"; if ($file != "") { if (!copy($file, $input_file_path . $input_file_name)) { echo ("failed to copy $file_name...<br>\n"); } if ($version!="windows"){ $pic=$input_file_path.$input_file_name; $size = GetImageSize("$pic") ; $w=$size[0] ; $h=$size[1]; make_thumb2($input_file_name, $input_file_path, $width , $quality, $actionFix); } } } function uploadfileBanner($input_file_path, $input_file_name, $file, $width , $quality, $actionFix){ $version="linux"; if ($file != "") { if (!copy($file, $input_file_path . $input_file_name)) { echo ("failed to copy $file_name...<br>\n"); } if ($version!="windows"){ $pic=$input_file_path.$input_file_name; $size = GetImageSize("$pic") ; $w=$size[0] ; $h=$size[1]; make_thumbBanner($input_file_name, $input_file_path, $width , $quality, $actionFix); } } } function uploadfileFixBackGround($input_file_path, $input_file_name, $file, $width , $quality, $actionFix, $bgWidth, $bgHeight){ $version="linux"; $myImageType = ''; if ($file != "") { if (!copy($file, $input_file_path . $input_file_name)) { echo ("failed to copy $file_name...<br>\n"); } if ($version!="windows"){ $pic=$input_file_path.$input_file_name; $size = GetImageSize("$pic") ; $w=$size[0]; $h=$size[1]; if ($h < ($w/2 + 10)) { $myImageType = 'panorama'; } make_thumb3($input_file_name, $input_file_path, $width , $quality, $actionFix, $bgWidth, $bgHeight ,$myImageType); } } } function Check_Permission ($check_module,$user_id,$action) { $sql = "select * from s_user_group where user_id = '$user_id'"; $query = sql_query ($sql) or die ("1"); $groups = ""; while ($rec = sql_fetch_array ($query)) { $groups .= "or group_id = '$rec[group_id]'"; } if ($groups <> "") { $groups = substr ($groups, 3); $groups = " and (" . $groups . ")"; } $sql = "select * from s_module where module_name like '$check_module'"; $query = sql_query ($sql) or die ("2"); $module_id = 0; while ($rec = sql_fetch_array ($query)) { $module_id = $rec["module_id"]; } $sql = "select * from s_user where user_id = '$user_id'"; $query = sql_query ($sql) or die ("3"); if ($rec = sql_fetch_array ($query)) { if ($rec["admin_flag"] == '1' or $check_module == "") { } else { /* if ($action == "read") $sql .= " read_p like '1'"; if ($action == "add") $sql .= " add_p like '1'"; if ($action == "update") $sql .= " update_p like '1'"; if ($action == "delete") $sql .= " delete_p like '1'"; */ $sql = "select * from s_user_p where user_id = '$user_id' and module_id like '$module_id'"; $query = sql_query ($sql) or die ("4"); if (sql_num_rows ($query)) { while ($rec = sql_fetch_array ($query)) { switch ($action) { case "read" : $code = $rec["read_p"]; break; case "add" : $code = $rec["add_p"]; break; case "update" : $code = $rec["update_p"]; break; case "delete" : $code = $rec["delete_p"]; break; } }// end while if ( ($code == "0") || ($code == "") ) { header ("location:/myadmin/error/permission.php"); } } else { $code =""; if($groups <> "") { $sql = "select sum(read_p) as s_read,sum(add_p) as s_add,sum(update_p) as s_update,sum(delete_p) as s_delete,module_id,group_id from s_user_p group by module_id,group_id having module_id like '$module_id' ".$groups ; $query = sql_query($sql) or die("5"); if (sql_num_rows ($query) == 0) $code = ""; if ($rec = sql_fetch_array ($query)) { switch ($action) { case "read" : $code = $rec["s_read"]; break; case "add" : $code = $rec["s_add"]; break; case "update" : $code = $rec["s_update"]; break; case "delete" : $code = $rec["s_delete"]; break; }// end switch } } if (trim($code) == '' or $code == '0') { header ("location:/myadmin/error/permission.php"); } } } } else { header ("location:/myadmin/error/permission.php"); } } function Check_Permission_menu ($check_module,$user_id,$action) { $permission_denine = 1; $sql = "select * from s_user_group where user_id = '$user_id'"; $query = sql_query ($sql) or die ("1"); $groups = ""; while ($rec = sql_fetch_array ($query)) { $groups .= "or group_id = '$rec[group_id]'"; } if ($groups <> "") { $groups = substr ($groups, 3); $groups = " and (" . $groups . ")"; } $sql = "select * from s_module where module_name like '$check_module'"; $query = sql_query ($sql) or die ("2"); $module_id = 0; while ($rec = sql_fetch_array ($query)) { $module_id = $rec["module_id"]; } $sql = "select * from s_user where user_id = '$user_id'"; $query = sql_query ($sql) or die ("3"); if ($rec = sql_fetch_array ($query)) { if ($rec["admin_flag"] == '1' or $_SESSION[s_group_all] == "ALL") { } else { /* if ($action == "read") $sql .= " read_p like '1'"; if ($action == "add") $sql .= " add_p like '1'"; if ($action == "update") $sql .= " update_p like '1'"; if ($action == "delete") $sql .= " delete_p like '1'"; */ $sql = "select * from s_user_p where user_id = '$user_id' and module_id like '$module_id'"; $query = sql_query ($sql) or die ("4"); if (sql_num_rows ($query)) { while ($rec = sql_fetch_array ($query)) { switch ($action) { case "read" : $code = $rec["read_p"]; break; case "add" : $code = $rec["add_p"]; break; case "update" : $code = $rec["update_p"]; break; case "delete" : $code = $rec["delete_p"]; break; } }// end while if ( ($code == "0") || ($code == "") ) { //header ("location:/myadmin/error/permission.php"); $permission_denine = 0; } } else { $code =""; if($groups <> "") { $sql = "select sum(read_p) as s_read,sum(add_p) as s_add,sum(update_p) as s_update,sum(delete_p) as s_delete,module_id,group_id from s_user_p group by module_id,group_id having module_id like '$module_id' ".$groups ; $query = sql_query($sql) or die("5"); if (sql_num_rows ($query) == 0) $code = ""; if ($rec = sql_fetch_array ($query)) { switch ($action) { case "read" : $code = $rec["s_read"]; break; case "add" : $code = $rec["s_add"]; break; case "update" : $code = $rec["s_update"]; break; case "delete" : $code = $rec["s_delete"]; break; }// end switch } } if (trim($code) == '' or $code == '0') { //header ("location:/myadmin/error/permission.php"); $permission_denine = 0; } } } } else { //header ("location:/myadmin/error/permission.php"); $permission_denine = 0; } return $permission_denine; } function isemail($e) { if(preg_match("/^[a-zA-Z0-9]+[_a-zA-Z0-9-]*(\.[_a-z0-9-]+)*@[a-z??0-9]+(-[a-z??0-9]+)*(\.[a-z??0-9-]+)*(\.[a-z]{2,4})$/", $e)) { return TRUE; } return FALSE; } function check_azAZ09($text){ if(preg_match("/[^0-9A-Za-z]/",$text)) return false; else return true; } function check_09($text){ if(preg_match("/[^0-9]/",$text)) return false; else return true; } $a_month_th = array ('','มกราคม', 'กุมภาพันธ์', 'มีนาคม', 'เมษายน', 'พฤษภาคม', 'มิถุนายน', 'กรกฎาคม', 'สิงหาคม',' กันยายน', 'ตุลาคม', 'พฤศจิกายน','ธันวาคม'); function check_azAZ09_($text){ if(preg_match("/[^0-9A-Za-z_]/",$text)) return false; else return true; } function check_full($text){ if(preg_match("/[^0-9A-Za-z_-]/",$text)) return false; else return true; } function get_param($a_param,$a_not_exists){ $param = $param2 = ""; if(count($a_param) > 0) { foreach($a_param as $key => $value){ if( (!@in_array($value,$a_not_exists)) && ($_REQUEST[$value] <> "") ) $param .= "&".$value."=".$_REQUEST[$value]; } } if(count($_REQUEST) > 0){ foreach($_REQUEST as $key => $value){ if( preg_match("/^pre_/",$key) && ($value <> "") ) $param2 .= "&".$key."=".$value; } } $param = $param.$param2; return substr($param,1); } function post_param($a_param,$a_not_exists){ $param = ""; if(count($a_param) > 0) { foreach($a_param as $key => $value){ if( (!@in_array($value,$a_not_exists)) && ($_REQUEST[$value] <> "") ) echo "<input type=\"hidden\" name=\"$value\" value=\"".$_REQUEST[$value]."\">"; }// end foreach } if(count($_REQUEST) > 0) { foreach($_REQUEST as $key => $value){ if( preg_match("/^pre_/",$key) && ($value <> "") ) echo "<input type=\"hidden\" name=\"$key\" value=\"$value\">"; }// end foreach } } function get_pre_param($a_param){ $param = ""; if(count($a_param) > 0) { foreach($a_param as $key => $value){ if( $_REQUEST[$value] <> "" ) $param .= "&pre_".$value."=".$_REQUEST[$value]; } $param = substr($param,1); } return $param; } function get_return_param(){ $param = ""; if(count($_REQUEST) > 0) { foreach($_REQUEST as $key => $value){ if( preg_match("/^pre_/",$key) && ($value <> "") ) $param .= "&".str_replace("pre_","",$key)."=".$value; } $param = substr($param,1); } return $param; } function check_file_in_path($file_type,$path,$length){ $filename = gen_random ($length-1).".".$file_type; while(1){ if(!file_exists($path.$filename)){ break; }else{ $filename = gen_random ($length-1).".".$file_type; } } return $filename; } function cropImage($nw, $nh, $source, $stype, $dest) { $size = getimagesize($source); $w = $size[0]; $h = $size[1]; switch($stype) { case 'gif': $simg = imagecreatefromgif($source); break; case 'jpg': $simg = imagecreatefromjpeg($source); break; case 'png': $simg = imagecreatefrompng($source); break; } $dimg = imagecreatetruecolor($nw, $nh); $wm = $w/$nw; $hm = $h/$nh; $h_height = $nh/2; $w_height = $nw/2; if($w> $h) { $adjusted_width = $w / $hm; $half_width = $adjusted_width / 2; $int_width = $half_width - $w_height; //imagecopyresampled($dimg,$simg,0,0,0,0,$adjusted_width,$nh,$w,$h); //imagecopyresampled($dimg,$simg,-$int_width,0,0,0,$adjusted_width,$nh,$w,$h); imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w,$h); } elseif(($w <$h) || ($w == $h)) { $adjusted_height = $h / $wm; $half_height = $adjusted_height / 2; $int_height = $half_height - $h_height; // imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$adjusted_height,$w,$h); imagecopyresampled($dimg,$simg,0,-$int_height,0,0,$nw,$adjusted_height,$w,$h); } else { imagecopyresampled($dimg,$simg,0,0,0,0,$nw,$nh,$w,$h); } imagejpeg($dimg,$dest,100); } function calage($pbday){ $today = date("Y-m-d"); list( $byear, $bmonth , $bady) = explode("-" , $pbday); list($tyear, $tmonth ,$tday) = explode("-" , $today); if($byear < 1970){ $yearad =1970 - $byear; $byear =1970; }else{ $yearad = 0; } $mbirth = mktime(0,0,0,$bmonth,$bday,$byear); $mnow = mktime(0,0,0,$tmonth,$tday,$tyear); $mage= ($mnow - $mbirth); $age = (date("Y",$mage)-1970 + $yearad)."-".(date("m", $mage)-1)."-" . (date("d", $mage)-1); return($age); } // end function function scanInvective ($text, $textReplace) { global $aInvective; global $configMemberPostNormalMaxlength; if (mb_strlen($text, 'utf8') > $configMemberPostNormalMaxlength) $text = mb_substr($text, 0, $configMemberPostNormalMaxlength, 'utf8'); foreach ($aInvective as $value) { $text = str_ireplace($value,$textReplace,$text); } // end foreach return $text; } // enf function function scanInvectiveExtra ($text, $textReplace) { global $aInvectiveExtra; global $configMemberPostMaxlength; if (mb_strlen($text, 'utf8') > $configMemberPostMaxlength) $text = mb_substr($text, 0, $configMemberPostMaxlength, 'utf8'); foreach ($aInvectiveExtra as $value) { $text = str_ireplace($value,$textReplace,$text); } // end foreach return $text; } // enf function function checkBandIP($ip) { $sql = "SELECT COUNT(band_ip_id) AS num FROM band_ip WHERE band_ip = '".$ip."' "; $query = sql_query($sql); $rec = sql_fetch_array($query); if ($rec['num'] > 0) return false; else return true; } // end function function checkBandEmail($member_id) { $sql = "SELECT COUNT(band_email_id) AS num FROM band_email WHERE member_id = '".$member_id."' "; $query = sql_query($sql); $rec = sql_fetch_array($query); if ($rec['num'] > 0) return false; else return true; } // end function function checkLastLogin(){ if ($_SESSION['s_save_last_login'] != 1) { if ($_SESSION['s_member_id'] <> '') { $sql = "SELECT last_login FROM member WHERE member_id = '".$_SESSION['s_member_id']."'"; $query = sql_query($sql); $rec = sql_fetch_array($query); $nowDate = date("Y-m-d"); if ($rec['last_login'] <> $nowDate) { $sql = "UPDATE member SET last_login = '".$nowDate."', date_count = (date_count+1) WHERE member_id = '".$_SESSION['s_member_id']."' "; sql_query($sql); } // end if ($rec['last_login'] <> $nowDate) { } // end if ($_SESSION['s_member_id'] <> '') { $_SESSION['s_save_last_login'] = 1; } // end if ($_SESSION['s_save_last_login'] != 1) { } // end function function sendMailEncode($email, $fromname, $frommail, $subject, $message, $cType='html',$CC="",$BCC="",$attach="",$attach_name=""){ /*$subject ="=?utf-8?B?".base64_encode($subject)."?="; // Start MIME Boundary $mime_boundary="----kaomail----".md5(time()); $headers .= "MIME-Version: 1.0\n"; $headers .="From: ".$frommail."\n"; //$headers .="From: ".$fromname." <".$frommail.">\n"; if ($CC <> '') $headers .= "Cc:".$CC."\n"; if ($BCC <> '') $headers .= "Bcc:".$BCC."\n"; //$headers .= "Content-Type: multipart/mixed; boundary=\"$mime_boundary\"\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n"; //$headers .= "--".$mime_boundary."\n"; if($attach != ""){ $strContent = chunk_split(base64_encode(file_get_contents($attach))); $headers .= "--".$mime_boundary."\n"; $headers .= "Content-Type: application/octet-stream; name=\"".$attach_name."\"\n"; //$headers .= chunk_split(base64_encode(file_get_contents($attach))); $headers .= "Content-Transfer-Encoding: base64\n"; $headers .= "Content-Disposition: attachment; filename=\"".$attach_name."\"\n\n"; $headers .= $strContent."\n\n"; } // text plain part $messages = "--$mime_boundary\n"; $messages .= "Content-Type: text/plain; charset=\"utf-8\"\n"; $messages .= "Content-Transfer-Encoding: base64\n\n"; $messages .= chunk_split(base64_encode(strip_tags($message)))."\n\n"; // text html part $messages .= "--$mime_boundary\n"; $messages .= "Content-Type: text/html; charset=\"utf-8\"\n"; $messages .= "Content-Transfer-Encoding: base64\n\n"; $messages .= chunk_split(base64_encode($message))."\n\n"; // End of Boundary $messages .= "--$mime_boundary--\n\n"; if (strlen($email) > 0 && strpos($email, "@") !== false) { if(!mail($email, $subject, $messages , $headers)) { return false; }else{ return true; } }else{ return true; }*/ global $configMandrillAPIKeys; $mailHTML = $message; $args = array( 'key' => $configMandrillAPIKeys, 'message' => array( "html" => $mailHTML, "text" => strip_tags($mailHTML), "from_email" => $frommail, "from_name" => $fromname, "subject" => $subject, "to" => array(array("email" => $email)), "track_opens" => true, "track_clicks" => true, "auto_text" => true ) ); // Open a curl session for making the call $curl = curl_init('https://mandrillapp.com/api/1.0/messages/send.json' ); // Tell curl to use HTTP POST curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // Tell curl not to return headers, but do return the response curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); // Set the POST arguments to pass on curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($args)); // Make the REST call, returning the result $response = curl_exec($curl); return 1; } // end function function sendMailEncodeTest($email, $fromname, $frommail, $subject, $message, $cType='html',$CC="",$BCC="",$attach="",$attach_name=""){ $subject ="=?UTF-8?B?".base64_encode($subject)."?="; // Start MIME Boundary $mime_boundary="----kaomail----".md5(time()); $headers .= "MIME-Version: 1.0\n"; $headers .="From: ".$frommail."\n"; //$headers .="From: ".$fromname." <".$frommail.">\n"; $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n"; //$headers .= "--".$mime_boundary."\n"; if($attach != ""){ $strContent = chunk_split(base64_encode(file_get_contents($attach))); $headers .= "--".$mime_boundary."\n"; $headers .= "Content-Type: application/octet-stream; name=\"".$attach_name."\"\n"; $headers .= chunk_split(base64_encode(file_get_contents($attach))); $headers .= "Content-Transfer-Encoding: base64\n"; $headers .= "Content-Disposition: attachment; filename=\"".$attach_name."\"\n\n"; $headers .= $strContent."\n\n"; } // text plain part $messages = "--$mime_boundary\n"; $messages .= "Content-Type: text/plain; charset=\"utf-8\"\n"; $messages .= "Content-Transfer-Encoding: base64\n\n"; $messages .= chunk_split(base64_encode(strip_tags($message)))."\n\n"; // text html part $messages .= "--$mime_boundary\n"; $messages .= "Content-Type: text/html; charset=\"utf-8\"\n"; $messages .= "Content-Transfer-Encoding: base64\n\n"; $messages .= chunk_split(base64_encode($message))."\n\n"; // End of Boundary $messages .= "--$mime_boundary--\n\n"; if (strlen($email) > 0 && strpos($email, "@") !== false) { if(!mail($email, $subject, $messages , $headers)) { return false; }else{ return true; } }else{ return true; } } // end function function changeGender(){ $mktime = mktime(0,0,0,date("m"),(date("d")-2),date("Y")); $sql = " SELECT member_id, old_gender FROM sponsor WHERE stop_date < '".date("Y-m-d")."' AND stop_date >= '".date("Y-m-d", $mktime)."' "; $query = sql_query($sql); while ($rec = sql_fetch_array($query)) { $sql = " UPDATE member SET gender = '".$rec['old_gender']."' WHERE member_id = '".$rec['member_id']."' "; sql_query($sql); } // end while } // end function function checkVipTag($member_id, $vipType){ /*$sql = " SELECT COUNT(vip_id) AS num FROM vip WHERE member_id = '".$member_id."' AND start_date <= '".date("Y-m-d")."' AND stop_date >= '".date("Y-m-d")."' "; $query = sql_query($sql); $rec = sql_fetch_array($query); if ($rec['num'] == 0) return false; else return true;*/ } // end function function sendMailFactory($email, $frommail, $subject, $message, $attchPath, $attchName, $replyTo, $includeFileMail) { global $configFromEmail; global $configFromEmailPassword; if ($replyTo == '') $replyTo = $frommail; if ($attchPath <> '') { $fileatt_name = $attchName; // Filename that will be used for the file as the attachment $fileatt_type = "application/octet-stream"; // File Type $file = fopen($attchPath,'rb'); $data = fread($file,filesize($attchPath)); fclose($file); $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers["Content-Type"] = "multipart/mixed; boundary=\"{$mime_boundary}\""; $email_message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"utf-8\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}--\n"; } else { // end if ($fileatt <> '') { $mime_boundary="----kaomail----".md5(time()); $headers["Content-Type"] = "multipart/alternative; boundary=\"$mime_boundary\""; // text plain part $messages = "--$mime_boundary\n"; $messages .= "Content-Type: text/plain; charset=\"utf-8\"\n"; $messages .= "Content-Transfer-Encoding: base64\n\n"; $messages .= chunk_split(base64_encode(strip_tags($message)))."\n\n"; // text html part $messages .= "--$mime_boundary\n"; $messages .= "Content-Type: text/html; charset=\"utf-8\"\n"; $messages .= "Content-Transfer-Encoding: base64\n\n"; $messages .= chunk_split(base64_encode($message))."\n\n"; // End of Boundary $messages .= "--$mime_boundary--\n\n"; $email_message = $messages; } // if ($attchPath <> '') { if ($includeFileMail <> 'no') include("Mail.php"); /* mail setup recipients, subject etc */ $recipients = $email; $mailmsg = $email_message; $headers["MIME-Version"] = "1.0"; $headers["From"] = $frommail; $headers["To"] = $email; $headers["Reply-To"] = $replyTo; $headers["Subject"] = "=?utf-8?B?".base64_encode($subject)."?="; /* SMTP server name, port, user/passwd */ $smtpinfo["host"] = "localhost"; $smtpinfo["port"] = "25"; $smtpinfo["auth"] = true; $smtpinfo["username"] = $configFromEmail; $smtpinfo["password"] = $configFromEmailPassword; /* Create the mail object using the Mail::factory method */ $mail_object =& Mail::factory("smtp", $smtpinfo); /* Ok send mail */ $mail_object->send($recipients, $headers, $mailmsg); } // end function function fineBannerMobileNumber($number) { $outputNumber = ''; $aMobile = explode(',', $number); if (count($aMobile) > 0) { foreach ($aMobile as $value) { $mobileNo = trim($value); $mobileNo = str_replace('-', '', $mobileNo); if ( (strlen($mobileNo) == 10) && (preg_match("/^08/", $mobileNo)) ) { $outputNumber = $mobileNo; break; } // end if } // end foreach ($aMobile as $mobileNo) { } // end if (count($aMobile) > 0) { return $outputNumber; } // end function function checkSwiffyBrowser() { $agent = $_SERVER['HTTP_USER_AGENT']; if(preg_match("/Netcaptor/", $agent)){ $browser = "Netcaptor"; } elseif(preg_match("/(opera) ([0-9]{1,2}.[0-9]{1,3}){0,1}/", $agent, $ver) || preg_match("/(opera\/)([0-9]{1,2}.[0-9]{1,3}){0,1}/", $agent, $ver)){ $browser = "Opera $ver[2]"; } elseif(preg_match("/(konqueror)\/([0-9]{1,2}.[0-9]{1,3})/", $agent, $ver)){ $browser = "Konqueror $ver[2]"; } elseif(preg_match("/(lynx)\/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})/", $agent, $ver)){ $browser = "Lynx $ver[2]"; } elseif(preg_match("/(msie) ([0-9]{1,2}.[0-9]{1,3})/", $agent, $ver)){ //$browser = "Internet Explorer $ver[2]"; if ($ver[2] < '9.0') return false; } elseif(preg_match("/Links/", $agent)){ $browser = "Lynx"; } elseif(preg_match("/(Firebird\/)([0-9]{1,2}.[0-9]{1,3}){0,1}/", $agent, $ver)){ $browser = "Firebird $ver[2]"; } elseif(preg_match("/(Firefox\/)([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})/", $agent, $ver)){ $browser = "FireFox $ver[2]"; } elseif(preg_match("/Mozilla\/5/",$agent)){$browser = "Netscape 5"; } elseif(preg_match("/Gecko/", $agent)){ $browser = "Mozilla"; } elseif(preg_match("/Safari/",$agent)){ $browser = "OS-X Safari"; } elseif(preg_match("/(netscape6)\/(6.[0-9]{1,3})/", $agent, $ver)){ $browser = "Netscape $ver[2]"; } elseif(preg_match("/(Mozilla)\/([0-9]{1,2}.[0-9]{1,3})/", $agent, $ver)){ $browser = "Netscape $ver[2]"; } elseif(preg_match("/Galeon/", $agent)){ $browser = "Galeon"; } elseif(preg_match("/(lynx)\/([0-9]{1,2}.[0-9]{1,2}.[0-9]{1,2})/", $agent, $ver) ){$browser = "Lynx $ver[2]"; } elseif(preg_match("/Avant Browser/", $agent)){ $browser = "Avant"; } elseif(preg_match("/(omniweb\/)([0-9]{1,2}.[0-9]{1,3})/", $agent, $ver) ){$browser = "OmniWeb $ver[2]"; } elseif(preg_match("/ZyBorg|WebCrawler|Slurp|Googlebot|MuscatFerret|ia_archiver/", $agent)){ $browser = "Web indexing robot"; } elseif(preg_match("/(webtv\/)([0-9]{1,2}.[0-9]{1,3})/", $agent, $ver) ){$browser = "WebTV $ver[2]"; } else {$browser = "Unknown";} return true; } // end function function setRankMemberPost() { $sql = " SELECT max_rank, member_post.member_post_id AS member_post_id, member_post.member_id AS member_id, member_post.rank AS now_rank FROM member_package INNER JOIN package_star ON member_package.package_star_id = package_star.package_star_id INNER JOIN member_post ON member_package.member_id = member_post.member_id AND member_package.start_date <= '" . @date("Y-m-d") . "' AND member_package.stop_date >= '" . @date("Y-m-d") . "' ORDER BY member_package.package_star_id, member_post.rank "; $query = sql_query($sql); while ($rec = sql_fetch_array($query)) { if ($rec['now_rank'] > $rec['max_rank']) { $sql = " UPDATE member_post SET rank = (rank+1) WHERE rank > 0 AND rank < " . $rec['now_rank'] . " "; sql_query($sql); $sql = " UPDATE member_post SET rank = 1, post_date = '" . @date('Y-m-d H:i:s') . "' WHERE member_post_id = '" . $rec['member_post_id'] . "' "; sql_query($sql); } // end if ($rec['now_rank'] > $rec['max_rank']) { } // end while ($rec = sql_fetch_array($query)) { } // end function function loadConfigBannerGroup() { $sql_group_banner_config = " SELECT banner_group_id, sort_by, banner_type, banner_width, banner_height FROM banner_group WHERE enable = 1 "; $queryGroup = sql_query($sql_group_banner_config); while ($recGroup = sql_fetch_array($queryGroup)) { $a_group_banner_config['sort_by'][$recGroup['banner_group_id']] = $recGroup['sort_by']; $a_group_banner_config['banner_type'][$recGroup['banner_group_id']] = $recGroup['banner_type']; $a_group_banner_config['banner_width'][$recGroup['banner_group_id']] = $recGroup['banner_width']; $a_group_banner_config['banner_height'][$recGroup['banner_group_id']] = $recGroup['banner_height']; } // end while ($recGroup = sql_fetch_array($queryGroup)) { return $a_group_banner_config; } // end function function shuffle_assoc($list) { if (!is_array($list)) return $list; $keys = array_keys($list); shuffle($keys); $random = array(); foreach ($keys as $key) $random[$key] = $list[$key]; return $random; } // end function function loadAllBanner() { if (!isset($_SESSION['s_group_banner_config']) && !isset($_SESSION['s_banner_load'])) { $nowDate = @date("Y-m-d"); $sql = " SELECT banner_group_id, sort_by, banner_type, banner_width, banner_height FROM banner_group WHERE enable = 1 "; $query = sql_query($sql); $a_random_group = array(); while ($rec = sql_fetch_array($query)) { $a_group_banner_config['sort_by'][$rec['banner_group_id']] = $rec['sort_by']; $a_group_banner_config['banner_type'][$rec['banner_group_id']] = $rec['banner_type']; $a_group_banner_config['banner_width'][$rec['banner_group_id']] = $rec['banner_width']; $a_group_banner_config['banner_height'][$rec['banner_group_id']] = $rec['banner_height']; if ($a_group_banner_config['sort_by'][$rec['banner_group_id']] == 'Random') $a_random_group[] = $rec['banner_group_id']; } // end while ($rec = sql_fetch_array($query)) { $sql = " SELECT banner_group_id, image, html_file, link, description FROM banner WHERE start_date <= '" . $nowDate . "' AND stop_date >= '" . $nowDate . "' AND enable = 1 "; $query = sql_query($sql); while ($rec = sql_fetch_array($query)) { $a_banner_load['image'][$rec['banner_group_id']][] = $rec['image']; $a_banner_load['html_file'][$rec['banner_group_id']][] = $rec['html_file']; $a_banner_load['link'][$rec['banner_group_id']][] = $rec['link']; $a_banner_load['description'][$rec['banner_group_id']][] = $rec['description']; } // end while ($rec = sql_fetch_array($query)) { if (count($a_random_group) > 0) { foreach ($a_random_group as $banner_group_id) { $a_banner_load['image'][$banner_group_id] = shuffle_assoc($a_banner_load['image'][$banner_group_id]); } // end foreach ($a_random_group as $banner_group_id) { } // end if (count($a_random_group) > 0) { $_SESSION['s_group_banner_config'] = $a_group_banner_config; $_SESSION['s_banner_load'] = $a_banner_load; } else { // end if (!isset($_SESSION['s_group_banner_config']) && !isset($_SESSION['s_banner_load'])) { $a_group_banner_config = $_SESSION['s_group_banner_config']; $a_banner_load = $_SESSION['s_banner_load']; } // if (!isset($_SESSION['s_group_banner_config']) && !isset($_SESSION['s_banner_load'])) { return array($a_group_banner_config, $a_banner_load); } // end function function saveQtyMember($pathToFile) { global $configQtyMemberFile; $sql = " SELECT COUNT(member.member_id) AS all_member FROM member INNER JOIN member_post ON member.member_id = member_post.member_id AND member.active_status = 1 "; $query = sql_query($sql); $rec = sql_fetch_array($query); $filename = $pathToFile . $configQtyMemberFile; $fp = fopen($filename, 'w'); fwrite($fp, $rec['all_member']); fclose($fp); } // end function saveQtyMember() { function getQtyMember($pathToFile) { global $configQtyMemberFile; $filename = $pathToFile . $configQtyMemberFile; $fp = @fopen($filename, 'r'); $qty = (int)trim(@fread($fp, @filesize($filename))); fclose($fp); return $qty; } // end function getQtyMember() { function getListModelLike() { $aData = array(); if (isset($_SESSION['s_member_id'])) { $sql = " SELECT like_id FROM member_like WHERE member_id = '" . $_SESSION['s_member_id'] . "' "; $query = sql_query($sql); while ($rec = sql_fetch_array($query)) { $aData[] = $rec['like_id']; } // end while ($rec = sql_fetch_array($query)) { } // end if (isset($_SESSION['s_member_id'])) { return $aData; } // end function function createLikeTab($mode_action, $mod_id, $like_action, $like_qty, $showDetail=0) { $output = ''; //if (isset($_SESSION['s_member_id'])) { $mod_id = (int)$mod_id; /*if ($mode_action == 'create') $output .= '<div class="like-mod-' . $mod_id . '">'; $output .= ' <div class="like-tab"> <div class="' . ( ($like_action == 0) ? 'dislike-btn' : 'like-btn') . '" onclick="saveLike(' . $mod_id .', ' . $like_action . ', ' . $showDetail . ')"><span class="like-btn-' . $mod_id . '"></span></div> <div class="like-text">'; if ( $like_qty > 0 ) { $output .= '<div class="text" onclick="getLikeModelList(' . $mod_id . ', $(\'#like-text-' . $mod_id . '-value\').val(), 1)" style="cursor:pointer"> <span class="like-text-' . $mod_id . '">' . number_format($like_qty) . '</span> <input type="hidden" id="like-text-' . $mod_id . '-value" value="' . $like_qty . '"> </div>'; } else { // end if ( $like_qty > 0 ) { $output .= '<div class="text"> x</div>'; } // if ( $like_qty > 0 ) { $output .= ' </div> <div class="like-end"></div> </div> ';*/ if ($mode_action == 'create') $output .= '<div class="like-mod-' . $mod_id . '">'; $javascript = isset($_SESSION['s_member_id']) ? 'saveLike(' . $mod_id .', ' . $like_action . ', ' . $showDetail . ')' : "alert('กรุณา Login เข้าสู่ระบบ หรือ สมัครสมาชิก่อน')"; $output .= ' <div class="like-tab"> <div class="' . ( ($like_action == 0) ? 'dislike-btn' : 'like-btn') . '" onclick="' . $javascript . '"><span class="like-btn-' . $mod_id . '"></span></div> <div>'; if ( $like_qty > 0 ) { $output .= '<div class="text" style="text-align:right"> <span class="like-text-' . $mod_id . '">' . number_format($like_qty) . '</span> <input type="hidden" id="like-text-' . $mod_id . '-value" value="' . $like_qty . '"> </div>'; } else { // end if ( $like_qty > 0 ) { $output .= '<div class="text"> </div>'; } // if ( $like_qty > 0 ) { $output .= ' </div> </div> '; /*if ($showDetail) { $sql = " SELECT mem_user FROM model_like INNER JOIN member ON model_like.mem_id = member.mem_id WHERE model_like.mod_id = '" . $mod_id . "' ORDER BY like_date DESC LIMIT 0, 3 "; $query = sql_query($sql); $text = ''; while ($rec = sql_fetch_array($query)) { $text .= ', ' . $rec['mem_user']; } // end while ($rec = sql_fetch_array($query)) { $output .= '<div onclick="getLikeModelList(' . $mod_id . ', $(\'#like-text-' . $mod_id . '-value\').val(), 1)" style="cursor:pointer"><span class="orange">' . mb_substr($text, 2, mb_strlen($text, 'utf8'), 'utf8') . '</span>'; if ($like_qty > 3) $output .= '<br>and <span class="orange">the other ' . number_format($like_qty - 2) . ' people</span> like this.'; $output .= ' </div>'; } // end if ($showDetail) {*/ if ($mode_action == 'create') $output .= '</div>'; //} // end if (isset($_SESSION['s_member_id'])) { return $output; } // end function function getAllMemberVIP() { // หา ว่าใครบ้างที่มี Tag VIP $sqlVIP = " SELECT member_id FROM vip WHERE start_date <= '".@date("Y-m-d")."' AND stop_date >= '".@date("Y-m-d")."' "; $queryVIP = sql_query($sqlVIP); $a_member_VIP = array(); while ($recVIP = sql_fetch_array($queryVIP)) { $a_member_VIP[] = $recVIP['member_id']; } // end while ($recVIP = sql_fetch_array($queryVIP)) { return $a_member_VIP; } // end function if ( $startFunctionDefault != 'no' ) { checkLastLogin(); // เรียกใช้งานเพื่อเก็บจำนวนวัน ที่เข้ามาใช้งานของแต่ละ User //changeGender(); // เปลี่ยนสถานพวกที่มีเพศเป็นแบบจ่ายเงิน ให้เป็นสถานะเดิมในกรณีที่หมดอายุแล้ว } // end if ( $startFunctionDefault != 'no' ) { ?>
Rename:
-