<?php
// when is now? ;-)
date_default_timezone_set('Asia/Bangkok');
$now = date( "Y-m-d" );
$curdate = split( "-", $now );
$cur_year = intval($curdate[0]);
$cur_month = intval($curdate[1]);
$cur_day = intval($curdate[2]);
if ( !empty( $HTTP_GET_VARS[ "Y" ] ) )
{
$cal_year = $HTTP_GET_VARS[ "Y" ];
} else $cal_year = $cur_year;
if ( !empty( $HTTP_GET_VARS[ "m" ] ) )
{
$cal_month = $HTTP_GET_VARS[ "m" ];
} else $cal_month = $cur_month;
if ( !empty( $HTTP_GET_VARS[ "d" ] ) )
{
$cal_day = $HTTP_GET_VARS[ "d" ];
} else
{
$cal_day = $cur_day;
}
// คำนวณเดือนและปีถัดไป
$cal_next_year = $cal_year;
if ( $cal_month < 12 )
{
$cal_next_month = $cal_month + 1;
}
else
{
$cal_next_month = 1;
$cal_next_year = $cal_year + 1;
}
// คำนวณเดือนและปีก่อนหน้า
$cal_prev_year = $cal_year;
if ( $cal_month > 1 )
{
$cal_prev_month = $cal_month - 1;
}
else
{
$cal_prev_month = 12;
$cal_prev_year = $cal_year - 1;
}
function num_days($year,$month)
{
$num = 31;
while (!checkdate( $month, $num, $year ) ) { $num--; }
return $num;
}
function pictureNumber($number){
$counter = strlen($number);
for ($i=0; $i < $counter; $i++) {
$image = substr($number,$i,1);
echo "<img src=\"images/counter/$image.png\" border=\"1\" align=\"absmiddle\">";
}
}
function pictureNumber_ck($number){
$counter = strlen($number);
for ($i=0; $i < $counter; $i++) {
$image = substr($number,$i,1);
echo "<img src=\"images/counter/$image.png\" border=\"0\" align=\"absmiddle\">";
}
}
function buildMonthSelect($month) {
for ($i = 1; $i <= 12; $i++) {
if ($i == $month) $sel = "SELECTED";
else $sel = "";
echo "<option $sel value=\"$i\">$i\n</option>";
}
}
function buildDaySelect($day) {
for ($i = 1; $i <= 31; $i++) {
if ($i == $day) $sel = "SELECTED";
else $sel = "";
echo "<option $sel value=\"$i\">$i\n</option>";
}
}
function buildYearSelect($year) {
for ($i = 1997; $i <= 2030; $i++) {
if ($i == $year) $sel = "SELECTED";
else $sel = "";
echo "<option $sel value=\"$i\">$i\n</option>";
}
}
function getTime($time) {
$time_Array = explode(":",$time);
$min = $time_Array[1];
if ($time_Array[0] == "00") {
$hour = "12";
$ampm = "AM";
} elseif ($time_Array[0] == "12") {
$hour = "12";
$ampm = "PM";
} elseif ($time_Array[0] > 12) {
$hour = $time_Array[0] - 12;
$ampm = "PM";
} else {
if ($time_Array[0] < 10)
$hour = substr($time_Array[0],1,1);
else
$hour = $time_Array[0];
$ampm = "AM";
}
$time = "$hour:$min $ampm";
return $time;
}
function getMonthName($Date) {
$month = Date("m",$Date);
if ($month == "01") {
$monthname = _CALJAN;
} elseif ($month == "02") {
$monthname = _CALFEB;
} elseif ($month == "03") {
$monthname = _CALMAR;
} elseif ($month == "04") {
$monthname = _CALAPR;
} elseif ($month == "05") {
$monthname = _CALMAY;
} elseif ($month == "06") {
$monthname = _CALJUN;
} elseif ($month == "07") {
$monthname = _CALJUL;
} elseif ($month == "08") {
$monthname = _CALAUG;
} elseif ($month == "09") {
$monthname = _CALSEP;
} elseif ($month == "10") {
$monthname = _CALOCT;
} elseif ($month == "11") {
$monthname = _CALNOV;
} elseif ($month == "12") {
$monthname = _CALDEC;
}
return $monthname;
}
function getMonthEnName($Date) {
$monthEn = Date("m",$Date);
if ($monthEn == "01") {
$monthEnname = _CALEJAN;
} elseif ($monthEn == "02") {
$monthEnname = _CALEFEB;
} elseif ($monthEn == "03") {
$monthEnname = _CALEMAR;
} elseif ($monthEn == "04") {
$monthEnname = _CALEAPR;
} elseif ($monthEn == "05") {
$monthEnname = _CALEMAY;
} elseif ($monthEn == "06") {
$monthEnname = _CALEJUN;
} elseif ($monthEn == "07") {
$monthEnname = _CALEJUL;
} elseif ($monthEn == "08") {
$monthEnname = _CALEAUG;
} elseif ($monthEn == "09") {
$monthEnname = _CALESEP;
} elseif ($monthEn == "10") {
$monthEnname = _CALEOCT;
} elseif ($monthEn == "11") {
$monthEnname = _CALENOV;
} elseif ($monthEn == "12") {
$monthEnname = _CALEDEC;
}
return $monthEnname;
}
function getLongDayName($Date) {
$month = Date("w",$Date);
if ($month == "0") {
$dayname = _CALLONGFIRSTDAY;
} elseif ($month == "1") {
$dayname = _CALLONGSECONDDAY;
} elseif ($month == "2") {
$dayname = _CALLONGTHIRDDAY;
} elseif ($month == "3") {
$dayname = _CALLONGFOURTHDAY;
} elseif ($month == "4") {
$dayname = _CALLONGFIFTHDAY;
} elseif ($month == "5") {
$dayname = _CALLONGSIXTHDAY;
} elseif ($month == "6") {
$dayname = _CALLONGSEVENTHDAY;
}
return $dayname;
}
function list_file($path, $sub, $indent) {
if(($dir = @opendir("$path\\$sub"))===false) die ("Can't open $path\n");
while (($file = readdir($dir)) !== false) {
for($i=0; $i<$indent; $i++) echo " "; echo $file;
if (is_dir("$path\\$sub\\${file}") && ($file != "." && $file != "..") ) {
list_file("$path\\$sub", $file, $indent+1);
echo "\n";
}else{
echo "xxx";
}
}
closedir($dir);
}
//dir016.php โคตรเซียน PHP http://www.oa1web.com
function resizeImage($src_dir, $src_file, $new_width, $output_dir)
{
$filename = $src_dir.$src_file;
$format='';
if(preg_match("/.jpg/i", "$filename"))
{
$format = 'image/jpeg';
}
if (preg_match("/.gif/i", "$filename"))
{
$format = 'image/gif';
}
if(preg_match("/.png/i", "$filename"))
{
$format = 'image/png';
}
if($format!='')
{
list($width, $height) = getimagesize($filename);
$newheight=$height*$new_width/$width;
switch($format)
{
case 'image/jpeg':
$source = imagecreatefromjpeg($filename);
break;
case 'image/gif';
$source = imagecreatefromgif($filename);
break;
case 'image/png':
$source = imagecreatefrompng($filename);
break;
}
$thumb = imagecreatetruecolor($new_width,$newheight);
imagealphablending($thumb, false);
$source = @imagecreatefromjpeg("$filename");
imagecopyresized($thumb, $source, 0, 0, 0, 0, $new_width, $newheight, $width, $height);
$filename= $output_dir.$src_file;
echo $filename ;
@imagejpeg($thumb, $filename );
}
}
//Random ชื่อผู้ใช้ และรหัสผ่านให้สมาชิก
function random_username($len) {
srand((double)microtime()*10000000);
$chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
$ret_str = "";
$num = strlen($chars);
for($i = 0; $i < $len; $i++) {
$ret_str.= $chars[rand()%$num];
$ret_str.="";
}
return $ret_str;
}
function ThaiBahtConversion($amount_number)
{
$amount_number = number_format($amount_number, 2, ".","");
//echo "<br/>amount = " . $amount_number . "<br/>";
$pt = strpos($amount_number , ".");
$number = $fraction = "";
if ($pt === false)
$number = $amount_number;
else
{
$number = substr($amount_number, 0, $pt);
$fraction = substr($amount_number, $pt + 1);
}
//list($number, $fraction) = explode(".", $number);
if ($number=='0')
$ret = "ศูนย์";
else
$ret = "";
$baht = ReadNumber ($number);
//if ($baht != "")
$ret .= $baht . "บาท";
$satang = ReadNumber($fraction);
if ($satang != "")
$ret .= $satang . "สตางค์";
else
$ret .= "ถ้วน";
//return iconv("UTF-8", "TIS-620", $ret);
return $ret;
}
function ReadNumber($number)
{
$position_call = array("แสน", "หมื่น", "พัน", "ร้อย", "สิบ", "");
$number_call = array("", "หนึ่ง", "สอง", "สาม", "สี่", "ห้า", "หก", "เจ็ด", "แปด", "เก้า");
$number = $number + 0;
$ret = "";
if ($number == 0) return $ret;
if ($number > 1000000)
{
$ret .= ReadNumber(intval($number / 1000000)) . "ล้าน";
$number = intval(fmod($number, 1000000));
}
$divider = 100000;
$pos = 0;
while($number > 0)
{
$d = intval($number / $divider);
$ret .= (($divider == 10) && ($d == 2)) ? "ยี่" :
((($divider == 10) && ($d == 1)) ? "" :
((($divider == 1) && ($d == 1) && ($ret != "")) ? "เอ็ด" : $number_call[$d]));
$ret .= ($d ? $position_call[$pos] : "");
$number = $number % $divider;
$divider = $divider / 10;
$pos++;
}
return $ret;
}
function wysiwyg_nicEdit()
{
echo "<script type='text/javascript' src='include/nicEdit/nicEdit.js'></script>";
echo "<script type='text/javascript'>
bkLib.onDomLoaded(function() {
new nicEditor({maxHeight : 300}).panelInstance('textarea1');
new nicEditor({maxHeight : 300}).panelInstance('textarea2');
new nicEditor({maxHeight : 300}).panelInstance('textarea3');
});
</script>";
//nicEditors.allTextAreas()
//new nicEditor({fullPanel : true}).panelInstance('area');
}
function wysiwyg_textarea($name, $value, $ToolbarSet, $cols, $rows)
{
@require_once('include/FCKeditor/fckeditor.php');
$FCKeditor = new FCKeditor($name);
$FCKeditor->BasePath = 'include/FCKeditor/';
$FCKeditor->Value = $value;
$FCKeditor->ToolbarSet = $ToolbarSet;
$FCKeditor->Width = $cols ;
$FCKeditor->Height = $rows * 20 ;
$FCKeditor->Create();
}
function utf8_strlen($str)
{
$c = strlen($str);
$l = 0;
for ($i = 0; $i < $c; ++$i){
if ((ord($str[$i]) & 0xC0) != 0x80){
++$l;
}
}
return $l;
}
function random_color_part() {
return str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT);
}
function random_color() {
return random_color_part() . random_color_part() . random_color_part();
}
?>
<!-- script แสดงเลขหน้ากรอบสี่เหลี่ยม -->
<script src="css/bootstrap.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
<script type="text/javascript" src="css/main.js" charset="UTF-8"></script>
<!-- script แสดงเลขหน้ากรอบสี่เหลี่ยม -->
<!-- Text Editor -->
<!-- รูปแบบ defaultdark modern office office-toolbar square -->
<link rel="stylesheet" href="include/sceditor-2.1.3/minified/themes/modern.min.css" id="theme-style" />
<script src="include/sceditor-2.1.3/minified/sceditor.min.js"></script>
<script src="include/sceditor-2.1.3/minified/icons/monocons.js"></script>
<script src="include/sceditor-2.1.3/minified/formats/xhtml.js"></script>