date_default_timezone_set('Asia/Bangkok');
function codepoint_utf8($codepoint) {
$ascii = "";
if ($codepoint < 0x80) {
$ascii .= chr($codepoint);
} elseif ($codepoint < 0x800) {
$ascii .= chr(0xc0 | ($codepoint >> 6));
$ascii .= chr(0x80 | ($codepoint & 0x3f));
} elseif ($codepoint < 0x10000) {
$ascii .= chr(0xe0 | ($codepoint >> 12));
$ascii .= chr(0x80 | ($codepoint >> 6 ) & 0x3f);
$ascii .= chr(0x80 | ($codepoint & 0x3f));
} else {
$ascii .= chr(0xf0 | ($codepoint >> 18));
$ascii .= chr(0x80 | ($codepoint >> 12 ) & 0x3f);
$ascii .= chr(0x80 | ($codepoint >> 6 ) & 0x3f);
$ascii .= chr(0x80 | ($codepoint & 0x3f));
}
return $ascii;
}
function to_char(&$item, $key) {
$item = chr($item);
}
function to_unicode(&$item, $key) {
$item = codepoint_utf8($item);
}
$__tis620 = range(0xa1, 0xff);
$__tis620[] = 0xa0;
array_walk($__tis620, "to_char");
$__utf8 = range(0xe01, 0xe5f);
$__utf8[] = 0xa0;
array_walk($__utf8, "to_unicode");
function tis620_utf8($str) {
global $__tis620, $__utf8;
if (function_exists("array_combine")) {
$str = strtr($str, array_combine($__tis620, $__utf8));
} else {
$str = strtr($str, _array_combine($__tis620, $__utf8));
}
return $str;
}
function utf8_tis620($str) {
global $__tis620, $__utf8;
if (function_exists("array_combine")) {
$str = strtr($str, array_combine($__utf8, $__tis620));
} else {
$str = strtr($str, _array_combine($__utf8, $__tis620));
}
return $str;
}
function _array_combine($k, $v) {
$output = array();
for ($i = 0; $i < count($k); $i++) {
$output[$k[$i]] = $v[$i];
}
return $output;
}
?>
Report Form to Study at Khon Kaen University
if(isset($_POST['saved']) && $_POST['saved']=="save")
{
include("dbcf.php");
$report_id=$_POST['report_id'];
$resg=mysql_fetch_array(mysql_query("select photo,passport from study_report where report_id=$report_id"));
@unlink("photo/".$resg['photo']);
@unlink("passport/".$resg['passport']);
$pass_name = $report_id."_pass";
$photo_name = $report_id."_photo";
if($_FILES['photo']['tmp_name'] != "")
{
$utf_name = split("\\.",$_FILES['photo']['name']);
$fileup = utf8_tis620($photo_name.".".$utf_name[1]);
move_uploaded_file($_FILES['photo']['tmp_name'], "photo/".$fileup);
$photoupload = $photo_name.".".$utf_name[1];
}
if($_FILES['passport']['tmp_name'] != "")
{
$utf_name = split("\\.",$_FILES['passport']['name']);
$fileup = utf8_tis620($pass_name.".".$utf_name[1]);
move_uploaded_file($_FILES['passport']['tmp_name'], "passport/".$fileup);
$passupload = $pass_name.".".$utf_name[1];
}
$sql="update study_report set photo='$photoupload', passport='$passupload' where report_id=$report_id";
mysql_query($sql);
$msg = "saved";
}
?>
For international students only
if(isset($msg) && $msg=="saved"){ ?>
Upload successful.
} ?>
if(isset($msg) && $msg=="niddup"){ ?>
Duplicate registration.
} ?>
if(!isset($_POST['edit']))
{
?>
}
else if(isset($_POST['edit']) && $_POST['edit']=='edit')
{
include("dbcf.php");
$passport = mysql_real_escape_string(htmlspecialchars($_POST['passport']));
$chkpass=mysql_num_rows(mysql_query("select * from study_report where passnum='$passport'"));
if($chkpass < 1)
{
echo "
Passport number not found.
Back to Upload Documents page.";
}
else
{
$res=mysql_fetch_array(mysql_query("select * from study_report where passnum='$passport'"));
?>
echo $res['title']." ".$res['fname']." ".$res['mname']." ".$res['lname']; ?>
echo $res['passnum']; ?>
>>Click here to download your report form.<<
}
}
?>
include("footer.php"); ?>