ob_start() ;
if (!ini_get("register_globals")) {
import_request_variables('GPC');
}
###############################
function login($error) {
//include("header.php");
if ($error==1) {
$ErrMsg = "กรุณาใส่ Username และ Password ";
}elseif($error==2) {
$ErrMsg = "ขออภัย Username หรือ Password ไม่ถูกต้อง ";
}
?>
ระบบสำนักงานอิเล็กทรอนิกส์ (E-Office) สพม.เขต 31
E-office สำนักงานเขตพื้นที่การศึกษามัธยมศึกษา เขต 31
ระบบสำนักงานอิเล็กทรอนิกส์ (e-Office)
สำนักงานเขตพื้นที่การศึกษามัธยมศึกษา เขต 31
ถนนโคกกรวด-หนองปลิง ตำบลโคกกรวด อำเภอมือง จังหวัดนครราชสีมา 30280
//include("footer.php");
}
############################################
function checklogin($Username,$Password,$refferal) {
//include("header.php");
include "config.php" ;
//$Username = md5($Username) ;
$Password = md5($Password) ;
mysql_query("UPDATE counter SET counter = counter + 1"); // add counter
$sql = mysql_query ("SELECT * FROM $tb_user where e_username='$Username' and e_password='$Password' " ) ;
$num = mysql_num_rows ($sql) ; #หาจำนวนแถว
$row = mysql_fetch_array($sql) ;
$e_username = $row [e_username];
$e_status = $row [e_status];
$send_prefix = $row [send_prefix];
mysql_close () ;
if ($num==1) {
session_start ( ) ;
$_SESSION [sess_userid] = session_id ( ) ;
$_SESSION [login_username] = $e_username ;
$_SESSION [status] = $e_status ;
$_SESSION [online_send_prefix] = $send_prefix ;
include "config.php" ;
mysql_query ("INSERT INTO $tb_userlogin Values ('','$Username',NOW(),'Yes')") ;
echo "
" ;
}else{
include "config.php" ;
mysql_query ("INSERT INTO $tb_userlogin Values ('','$Username',NOW(),'No')") ;
echo "
" ;
}
//include("footer.php");
}
########################################
function logout1() {
//include("header.php");
include "chksession.php" ;
include "getname.php";
include "config.php" ;
mysql_query("delete from useronline where name = '$online_name' ");
mysql_query("delete from $ontblname where session='$userid'");
unset ( $_SESSION ['sess_userid']) ;
unset ( $_SESSION ['login_username']) ;
unset ( $_SESSION ['status']) ;
unset ( $_SESSION ['online_send_prefix']) ;
session_destroy () ;
echo "
" ;
//include("footer.php");
}
########################################
function list_book_out($field, $search, $Page) {
include("header.php");
include "config.php" ;
?>
if ($field<>"") {
$sql = "select b_id from $tb_newbook1 where $field like '%$search%' and b_from='$online_name' " ;
} else {
$sql = "select b_id From $tb_newbook1 where b_from='$online_name' ";
}
/* ตั้งค่า แสดงผลต่อหน้า $Per_Page */
$Per_Page =25;
if(!$Page)
$Page=1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$result = mysql_query($sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
if($Num_Rows<=$Per_Page)
$Num_Pages =1;
else if(($Num_Rows % $Per_Page)==0)
$Num_Pages =($Num_Rows/$Per_Page) ;
else
$Num_Pages =($Num_Rows/$Per_Page) +1;
$Num_Pages = (int)$Num_Pages;
if(($Page>$Num_Pages) || ($Page<0))
echo "
จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ ";
if ($field<>"") {
$sql = "select * from $tb_newbook1 where $field like '%$search%' and b_from='$online_name'" ;
} else {
$sql = "select * From $tb_newbook1 where b_from='$online_name'";
}
$sql .= " Order by b_id DESC LIMIT $Page_start , $Per_Page";
?>
แสดงรายการ : ทะเบียนหนังสือส่ง [ทะเบียนหนังสือรับ] [ส่งหนังสือ] [ทะเบียนหนังสือทั้งหมด] }?>
ระดับความสำคัญ ปกติ ด่วน ด่วนมาก ด่วนที่สุด
echo " ";
echo "แสดงข้อมูลทั้งหมด $Num_Rows รายการ กำลังแสดงผลหน้าที่ $Page จากทั้งหมด $Num_Pages หน้า " ;
echo " " ;
if($Prev_Page) {
echo " ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page){
echo " [$i ] ";
}elseif($i == $Page){
echo " [$i] ";
}
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages){
echo " ";
}
?>
//include("footer.php");
}
########################################
function list_book_in($field, $search, $Page) {
include("header.php");
include "config.php" ;
?>
แสดงรายการ : ทะเบียนหนังสือรับ [ทะเบียนหนังสือส่ง] [ทะเบียนหนังสือทั้งหมด] }?>
ระดับความสำคัญ ปกติ ด่วน ด่วนมาก ด่วนที่สุด
ที่
เลขหนังสือส่ง
เลขทะเบียนรับ / วันที่รับ
เรื่อง
จาก
ลงวันที่
วันเวลาที่ส่ง
// check status to find book in
if ($status=="user") {
$online_status = "alluser" ;
}
$sql = "SELECT idtempsend FROM $tb_sendtonamebook1 WHERE sendtoname = '$online_name' or sendtoname = '$online_status' Order By t_id Desc" ;
/* ตั้งค่า แสดงผลต่อหน้า $Per_Page */
$Per_Page =25;
if(!$Page)
$Page=1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$result = mysql_query($sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
if($Num_Rows<=$Per_Page)
$Num_Pages =1;
else if(($Num_Rows % $Per_Page)==0)
$Num_Pages =($Num_Rows/$Per_Page) ;
else
$Num_Pages =($Num_Rows/$Per_Page) +1;
$Num_Pages = (int)$Num_Pages;
if(($Page>$Num_Pages) || ($Page<0))
echo "จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ ";
$sql .= " LIMIT $Page_start , $Per_Page";
$result = mysql_query($sql);
$list=1;
While($list<=$Num_Rows&&$row= mysql_fetch_array($result)){
$idtempsend = $row[idtempsend ];
if ($field<>"") {
$selec_sql = mysql_query ("SELECT * FROM $tb_newbook1 WHERE idtempsend ='$idtempsend' and $field like '%$search%' and b_from <> '$online_name' ") ;
} else {
$selec_sql = mysql_query ("SELECT * FROM $tb_newbook1 WHERE idtempsend ='$idtempsend' and b_from <> '$online_name' ") ;
}
$sct_num = mysql_num_rows ($selec_sql) ;
// if ($sct_num==0) {mysql_query ("DELETE FROM $tb_sendtonamebook1 WHERE idtempsend ='$idtempsend ' ") ; } ;
While ($row2= mysql_fetch_array($selec_sql)) {
$b_id = $row2[b_id];
$b_bookno = $row2[b_bookno];
$b_subject= $row2[b_subject];
$b_from = $row2[b_from];
$b_signdate = $row2[b_signdate];
$b_date = $row2[b_date];
$b_level = $row2[b_level];
$idtempsend = $row2[idtempsend];
$receive_id = $row2[receive_id];
$receive_date = $row2[receive_date];
###########
//แปลง ลงวันที่
$array_sign = explode("-" ,$b_signdate) ;
$sign_d = $array_sign[2] ;
$sign_m = $array_sign[1] ;
$sign_y = $array_sign[0]+543 ;
//แปลงวันที่ส่ง
$array_send = explode(" " ,$b_date) ;
$send_date = $array_send[0] ;
$send_time = $array_send[1] ;
$array_date = explode("-" ,$send_date) ;
$send_d = $array_date[2] ;
$send_m = $array_date[1] ;
$send_y = $array_date[0]+543 ;
/////////////////////
if ($sign_m == "01") {
$sign_m = "ม.ค." ;
} elseif ($sign_m == "02") {
$sign_m = "ก.พ." ;
} elseif ($sign_m == "03") {
$sign_m = "มี.ค." ;
} elseif ($sign_m == "04") {
$sign_m = "เม.ย." ;
} elseif ($sign_m == "05") {
$sign_m ="พ.ค." ;
}elseif ($sign_m == "06") {
$sign_m="มิ.ย." ;
}elseif ($sign_m == "07") {
$sign_m="ก.ค." ;
}elseif ($sign_m == "08") {
$sign_m="ส.ค." ;
}elseif ($sign_m == "09") {
$sign_m="ก.ย." ;
}elseif ($sign_m == "10") {
$sign_m="ต.ค." ;
}elseif ($sign_m == "11") {
$sign_m="พ.ย." ;
}elseif ($sign_m == "12") {
$sign_m="ธ.ค." ;
}
if ($send_m == "01") {
$send_m = "ม.ค." ;
} elseif ($send_m == "02") {
$send_m = "ก.พ." ;
} elseif ($send_m == "03") {
$send_m = "มี.ค." ;
} elseif ($send_m == "04") {
$send_m = "เม.ย." ;
} elseif ($send_m == "05") {
$send_m ="พ.ค." ;
}elseif ($send_m == "06") {
$send_m="มิ.ย." ;
}elseif ($send_m == "07") {
$send_m="ก.ค." ;
}elseif ($send_m == "08") {
$send_m="ส.ค." ;
}elseif ($send_m == "09") {
$send_m="ก.ย." ;
}elseif ($send_m == "10") {
$send_m="ต.ค." ;
}elseif ($send_m == "11") {
$send_m="พ.ย." ;
}elseif ($send_m == "12") {
$send_m="ธ.ค." ;
}
// img of level
if ($b_level==1) {
$img_level = " " ;
}else if ($b_level==2) {
$img_level = " " ;
}else if ($b_level==3) {
$img_level = " " ;
}else if ($b_level==4) {
$img_level = " " ;
}
// check attach file
$file = mysql_query ("SELECT b_id FROM $tb_filebook1 WHERE b_id='$b_id' ") ;
$file_num = mysql_num_rows($file) ;
if ($file_num==0) {
$file_img = "" ;
}else{
$file_img = " " ;
}
// list
$mylist = ((($Page-1) * $Per_Page) + $list);
if ($list % 2 == 0) {
$color = "#ffffff";
}
else {
$color = "#E7E4E7";
}
$b_list=sprintf("%05d", $Num_Rows - $mylist + 1) ;
$sql_answer = mysql_query ("SELECT * FROM $tb_answerbook1 WHERE idtempsend ='$idtempsend' and b_name = '$online_name' ") ;
$ans_num = mysql_num_rows ($sql_answer) ;
$row3= mysql_fetch_array($sql_answer) ;
$receive_id = $row3[receive_id];
$ans_time = $row3[ans_time];
$array_send2 = explode(" " ,$ans_time) ;
$send_date2 = $array_send2[0] ;
$send_time2 = $array_send2[1] ;
$array_time = explode(":" ,$send_time2) ;
$send_time_h = $array_time[0] ;
$send_time_m = $array_time[1] ;
$array_date2 = explode("-" ,$send_date2) ;
$send_d2 = $array_date2[2] ;
$send_m2 = $array_date2[1] ;
$send_y2 = $array_date2[0]+543 ;
if ($send_m2 == "01") {
$send_m2 = "ม.ค." ;
} elseif ($send_m2 == "02") {
$send_m2 = "ก.พ." ;
} elseif ($send_m2 == "03") {
$send_m2 = "มี.ค." ;
} elseif ($send_m2 == "04") {
$send_m2 = "เม.ย." ;
} elseif ($send_m2 == "05") {
$send_m2 ="พ.ค." ;
}elseif ($send_m2 == "06") {
$send_m2="มิ.ย." ;
}elseif ($send_m2 == "07") {
$send_m2="ก.ค." ;
}elseif ($send_m2 == "08") {
$send_m2="ส.ค." ;
}elseif ($send_m2 == "09") {
$send_m2="ก.ย." ;
}elseif ($send_m2 == "10") {
$send_m2="ต.ค." ;
}elseif ($send_m2 == "11") {
$send_m2="พ.ย." ;
}elseif ($send_m2 == "12") {
$send_m2="ธ.ค." ;
}
if ($ans_num == 0) {
$ans_img = " " ;
} else {
$ans_img = " " ;
}
?>
ที่
if($ans_num!=0)
{
echo $receive_id." / ".$send_d2." ".$send_m2." ".$send_y2; //แสดงวันที่รับ
echo " ".$send_time_h.":".$send_time_m; //แสดงเวลาที่รับ
}
//else
//{
// echo " ";
//}
?>
น.
}
$list++ ;
}
mysql_close() ;
?>
ลงทะเบียนรับแล้ว ยังไม่ลงทะเบียนรับ
echo " ";
echo "แสดงข้อมูลทั้งหมด $Num_Rows รายการ กำลังแสดงผลหน้าที่ $Page จากทั้งหมด $Num_Pages หน้า " ;
echo " " ;
if($Prev_Page) {
echo " ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page){
echo " [$i ] ";
}elseif($i == $Page){
echo " [$i] ";
}
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages){
echo " ";
}
?>
//include("footer.php");
}
########################################
function form_send($online_name) {
include("header.php");
$anstimestamp = mktime(date("H"), date("i"),date("s"), date("m") ,date("d"), date("Y")) ; //timestamp เวลาปัจจุบัน
$msg_id = $userid.$anstimestamp ;
session_start ( ) ;
$_SESSION [msg_id] = $msg_id ;
?>
if ($status=="user") { ?>
}else if ($status=="staff") { ?>
}?>
กรุณาระบุรายละเอียดของหนังสือที่ต้องการส่ง [กลับ]
}
############################################
function user($field, $search, $Page ) {
include("header.php");
include "config.php" ;
if ($status<>"admin") {
header ("Location:index.php") ;
exit ();
}
?>
if ($field<>"") {
$sql = "select e_id from $tb_user where $field like '%$search%' and e_status='user' " ;
} else {
$sql = "select e_id From $tb_user where e_status='user'";
}
/* ตั้งค่า แสดงผลต่อหน้า $Per_Page */
$Per_Page =50;
if(!$Page)
$Page=1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$result = mysql_query($sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
if($Num_Rows<=$Per_Page)
$Num_Pages =1;
else if(($Num_Rows % $Per_Page)==0)
$Num_Pages =($Num_Rows/$Per_Page) ;
else
$Num_Pages =($Num_Rows/$Per_Page) +1;
$Num_Pages = (int)$Num_Pages;
if(($Page>$Num_Pages) || ($Page<0))
echo "จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ ";
if ($field<>"") {
$sql = "select * from $tb_user where $field like '%$search%' and e_status='user' " ;
} else {
$sql = "select * From $tb_user where e_status='user' ";
}
$sql .= " Order by e_id DESC LIMIT $Page_start , $Per_Page";
?>
รายชื่อผู้ใช้งานระบบ (โรงเรียน)
[เพิ่มโรงเรียนผู้ใช้งาน]
[เพิ่มกลุ่มโรงเรียนผู้ใช้งาน]
ที่
ชื่อ
ชื่อล็อกอิน
กลุ่ม
เลขรับล่าสุด
ที่หนังสือส่ง
เลขส่งล่าสุด
แก้ไข
ลบ
$result = mysql_query($sql);
$list=1;
While($list<=$Num_Rows&&$row= mysql_fetch_array($result)){
$e_id = $row[e_id];
$e_name = $row[e_name];
$e_username= $row[e_username];
$g_id = $row[g_id];
$last_receive_id = $row[last_receive_id];
$last_send_id = $row[last_send_id];
$send_prefix = $row[send_prefix];
$mylist = ((($Page-1) * $Per_Page) + $list);
if ($mylist % 2 == 0) {
$color = "#ffffff";
}
else {
$color = "#E7E4E7";
}
?>
$list++;
}
mysql_close() ;
?>
echo " ";
echo "แสดงข้อมูลทั้งหมด $Num_Rows รายการ กำลังแสดงผลหน้าที่ $Page จากทั้งหมด $Num_Pages หน้า " ;
echo " " ;
if($Prev_Page) {
echo " ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page){
echo " [$i ] ";
}elseif($i == $Page){
echo " $i ";
}
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages){
echo " ";
}
?>
เพิ่มผู้ใช้เข้าสู่ระบบ
############### layer2?>
เพิ่มกลุ่มผู้ใช้งาน
//include("footer.php");
}
############# user
function addgroup($groupname) {
include "chksession.php" ;
if ($status<>"admin") {
header ("Location:index.php") ;
exit ();
}
include "config.php" ;
mysql_query("INSERT INTO $tb_group Values('','$groupname')") ;
echo "
" ;
}
function del_group($g_id, $boxchecked) {
include "chksession.php" ;
include "config.php" ;
for ($i=1;$i<=$boxchecked;$i++)
{
if ($g_id[$i]!="") // Check Select Topic
{
//echo"$mid[$i]
";
mysql_query("delete from $tb_group where g_id='$g_id[$i]' ") or die ("ไม่สามารถลบข้อมูลได้ ");
mysql_query("delete from $tb_user where g_id='$g_id[$i]' ") ;
}
}
mysql_close ( ); echo "
" ;
}
function adduser($name, $username, $password, $status, $group) {
include "chksession.php" ;
if ($status<>"admin") {
header ("Location:index.php") ;
exit ();
}
include "config.php" ;
$username_exist = mysql_query ("SELECT e_username FROM $tb_user WHERE e_username='$username' ") ;
$num = mysql_num_rows($username_exist) ;
if ($num > 0) {
echo "
username นี้มีอยู่ในระบบแล้วกรุณาระบุใหม่ ";
echo "[ กลับ ]" ;
exit () ;
}
//$username = md5($Password) ;
$password = md5($password) ;
mysql_query("INSERT INTO $tb_user Values('','$name', '$username', '$password', 'user', '$group','ศธ ',0,0)") ;
echo " " ;
}
#########################################################################################
############################################
function usergroup($field, $search, $Page ) {
include("header.php");
if ($status<>"admin") {
header ("Location:index.php") ;
exit ();
}
include "config.php" ;
?>
if ($field<>"") {
$sql = "select e_id from $tb_user where $field like '%$search%' where e_status='staff' " ;
} else {
$sql = "select e_id From $tb_user where e_status='staff' ";
}
/* ตั้งค่า แสดงผลต่อหน้า $Per_Page */
$Per_Page =50;
if(!$Page)
$Page=1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$result = mysql_query($sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
if($Num_Rows<=$Per_Page)
$Num_Pages =1;
else if(($Num_Rows % $Per_Page)==0)
$Num_Pages =($Num_Rows/$Per_Page) ;
else
$Num_Pages =($Num_Rows/$Per_Page) +1;
$Num_Pages = (int)$Num_Pages;
if(($Page>$Num_Pages) || ($Page<0))
echo " จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ ";
if ($field<>"") {
$sql = "select * from $tb_user where $field like '%$search%' and e_status='staff' " ;
} else {
$sql = "select * From $tb_user where e_status='staff' ";
}
$sql .= " Order by e_id DESC LIMIT $Page_start , $Per_Page";
?>
ที่
ชื่อ
ชื่อล็อกอิน
เลขรับล่าสุด
ที่หนังสือส่ง
เลขส่งล่าสุด
แก้ไข
ลบ
$result = mysql_query($sql);
$list=1;
While($list<=$Num_Rows&&$row= mysql_fetch_array($result)){
$e_id = $row[e_id];
$e_name = $row[e_name];
$e_username= $row[e_username];
$last_receive_id = $row[last_receive_id];
$last_send_id = $row[last_send_id];
$send_prefix = $row[send_prefix];
$mylist = ((($Page-1) * $Per_Page) + $list);
if ($mylist % 2 == 0) {
$color = "#ffffff";
}
else {
$color = "#E7E4E7";
}
?>
$list++;
}
mysql_close() ;
?>
echo "
";
echo "
แสดงข้อมูลทั้งหมด $Num_Rows รายการ กำลังแสดงผลหน้าที่ $Page จากทั้งหมด $Num_Pages หน้า " ;
echo "
" ;
if($Prev_Page) {
echo "
";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page){
echo " [
$i ] ";
}elseif($i == $Page){
echo "
$i ";
}
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages){
echo "
";
}
?>
เพิ่มผู้ใช้เข้าสู่ระบบ
//include("footer.php");
}
function addusergroup($name, $username, $password, $status, $group) {
include "chksession.php" ;
if ($status<>"admin") {
header ("Location:index.php") ;
exit ();
}
include "config.php" ;
$username_exist = mysql_query ("SELECT e_username FROM $tb_user WHERE e_username='$username' ") ;
$num = mysql_num_rows($username_exist) ;
if ($num > 0) {
echo " username นี้มีอยู่ในระบบแล้วกรุณาระบุใหม่ ";
echo "[ กลับ ]" ;
exit () ;
}
//$username = md5($Password) ;
$password = md5($password) ;
mysql_query("INSERT INTO $tb_user Values('','$name', '$username', '$password', 'staff', '','ศธ ',0,0)") ;
echo " " ;
}
############################################
function userpublic($field, $search, $Page ) {
include("header.php");
if ($status<>"admin") {
header ("Location:index.php") ;
exit ();
}
include "config.php" ;
?>
if ($field<>"") {
$sql = "select e_id from $tb_user where $field like '%$search%' where e_status='public' " ;
} else {
$sql = "select e_id From $tb_user where e_status='public' ";
}
/* ตั้งค่า แสดงผลต่อหน้า $Per_Page */
$Per_Page =50;
if(!$Page)
$Page=1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$result = mysql_query($sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
if($Num_Rows<=$Per_Page)
$Num_Pages =1;
else if(($Num_Rows % $Per_Page)==0)
$Num_Pages =($Num_Rows/$Per_Page) ;
else
$Num_Pages =($Num_Rows/$Per_Page) +1;
$Num_Pages = (int)$Num_Pages;
if(($Page>$Num_Pages) || ($Page<0))
echo " จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ ";
if ($field<>"") {
$sql = "select * from $tb_user where $field like '%$search%' and e_status='public' " ;
} else {
$sql = "select * From $tb_user where e_status='public' ";
}
$sql .= " Order by e_id DESC LIMIT $Page_start , $Per_Page";
?>
ที่
ชื่อ
ชื่อล็อกอิน
แก้ไข
ลบ
$result = mysql_query($sql);
$list=1;
While($list<=$Num_Rows&&$row= mysql_fetch_array($result)){
$e_id = $row[e_id];
$e_name = $row[e_name];
$e_username= $row[e_username];
$mylist = ((($Page-1) * $Per_Page) + $list);
if ($mylist % 2 == 0) {
$color = "#ffffff";
}
else {
$color = "#E7E4E7";
}
?>
$list++;
}
mysql_close() ;
?>
echo "
";
echo "
แสดงข้อมูลทั้งหมด $Num_Rows รายการ กำลังแสดงผลหน้าที่ $Page จากทั้งหมด $Num_Pages หน้า " ;
echo "
" ;
if($Prev_Page) {
echo "
";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page){
echo " [
$i ] ";
}elseif($i == $Page){
echo "
$i ";
}
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages){
echo "
";
}
?>
เพิ่มผู้ใช ้ส่วนราชการ เข้าสู่ระบบ
//include("footer.php");
}
function adduserpublic($name, $username, $password, $status, $group) {
include "chksession.php" ;
if ($status<>"admin") {
header ("Location:index.php") ;
exit ();
}
include "config.php" ;
$username_exist = mysql_query ("SELECT e_username FROM $tb_user WHERE e_username='$username' ") ;
$num = mysql_num_rows($username_exist) ;
if ($num > 0) {
echo " username นี้มีอยู่ในระบบแล้วกรุณาระบุใหม่ ";
echo "[ กลับ ]" ;
exit () ;
}
//$username = md5($Password) ;
$password = md5($password) ;
mysql_query("INSERT INTO $tb_user Values('','$name', '$username', '$password', 'public', '','ศธ ',0,0)") ;
echo " " ;
}
##################################
function detail() {
include("header.php");
include "config.php" ;
$mydetail = mysql_query("SELECT * FROM $tb_userdetail WHERE e_username='$login_username'") ;
$num = mysql_num_rows ($mydetail) ;
$mydetail_arr = mysql_fetch_array ($mydetail) ;
$user_name = $mydetail_arr[user_name] ;
$user_position = $mydetail_arr[user_position] ;
$user_tel = $mydetail_arr[user_tel] ;
$user_email = $mydetail_arr[user_email] ;
$myUser = mysql_query("SELECT * FROM $tb_user WHERE e_username='$login_username'") ;
$numUser = mysql_num_rows ($myUser) ;
$myUser_arr = mysql_fetch_array ($myUser) ;
$last_receive_id = $myUser_arr[last_receive_id] ;
$last_send_id = $myUser_arr[last_send_id] ;
$send_prefix = $myUser_arr[send_prefix] ;
mysql_close() ;
?>
if ($num==0){ ?>
}?>
เปลี่ยนรหัสผ่าน
//include("footer.php");
}
function editdetail($user_name, $user_position, $user_tel, $user_email, $last_receive_id, $last_send_id, $send_prefix) {
include "chksession.php" ;
include "config.php" ;
$sql = mysql_query ("SELECT e_username FROM $tb_userdetail WHERE e_username='$login_username' ") ;
$num = mysql_num_rows($sql) ;
if ($num == 0) {
mysql_query("INSERT INTO $tb_userdetail Values('$login_username', '$user_name', '$user_position', '$user_tel', '$user_email')") ;
echo " " ;
}else{
mysql_query("UPDATE $tb_userdetail SET user_name='$user_name', user_position='$user_position', user_tel='$user_tel', user_email='$user_email' WHERE e_username='$login_username' ") ;
echo " " ;
}
mysql_query("UPDATE $tb_user SET last_receive_id = '$last_receive_id',last_send_id = '$last_send_id', send_prefix = '$send_prefix' WHERE e_username='$login_username'");
}
##################
function chngpwd( $e_username, $oldpass, $newpass) {
include "chksession.php" ;
include("header.php");
include "config.php" ;
$sql = mysql_query ("SELECT e_password FROM $tb_user WHERE e_username='$e_username' ") ;
$result = mysql_fetch_array($sql);
$mypass = $result [e_password] ;
$oldpass = md5($oldpass) ;
if ($mypass <> $oldpass) {
echo " ";
echo " คุณระบุรหัสผ่านเดิมไม่ถูกต้อง ";
echo "[ กลับ ]" ;
exit () ;
} else{
include "config.php" ;
//$username = md5($Password) ;
$newpass = md5($newpass) ;
mysql_query("update $tb_user set e_password='$newpass' WHERE e_username='$e_username' ") ;
echo " " ;
exit () ;
}
}
#################
function formedituser($e_username, $user_type, $last_receive_id, $last_send_id, $send_prefix) {
//include "chksession.php" ;
include("header.php");
if ($status<>"admin") {
header ("Location:index.php") ;
exit ();
}
$sql_edit = mysql_query("SELECT * FROM $tb_user WHERE e_username='$e_username' ");
$r_edit = mysql_fetch_array($sql_edit) ;
$e_name= $r_edit [e_name] ;
$e_status= $r_edit [e_status] ;
$g_id= $r_edit [g_id] ;
$last_receive_id= $r_edit [last_receive_id] ;
$last_send_id= $r_edit [last_send_id] ;
$send_prefix= $r_edit [send_prefix] ;
mysql_close() ;
?>
}
###############################
function edituser($e_username, $e_name, $e_password, $group, $user_type, $last_receive_id, $last_send_id, $send_prefix) {
include "chksession.php" ;
if ($status<>"admin") {
header ("Location:index.php") ;
exit ();
}
if ($user_type=="sch") {
$mod1="user" ;
} else if ($user_type=="grp") {
$mod1="usergroup" ;
} else if ($user_type=="pbl") {
$mod1="userpublic" ;
}
if (empty($e_password)) {
include "config.php" ;
mysql_query("UPDATE `ef_user` SET e_name = '$e_name' , last_receive_id = $last_receive_id , last_send_id = $last_send_id, send_prefix = '$send_prefix' WHERE e_username = '$e_username' LIMIT 1") ;
echo " " ;
} else{
include "config.php" ;
$e_password = md5($e_password) ;
mysql_query("UPDATE `ef_user` SET e_name = '$e_name' , e_password = '$e_password' , last_receive_id = $last_receive_id , last_send_id = $last_send_id, send_prefix = '$send_prefix' WHERE e_username = '$e_username' LIMIT 1") ;
echo " " ;
}
}
#####################
########################################
function listallbook($field, $search, $Page) {
include("header.php");
include "config.php" ;
if ($status=="admin" ||$status=="saraban" ) {
if ($field<>"") {
$sql = "select b_id from $tb_newbook1 where $field like '%$search%'" ;
} else {
$sql = "select b_id From $tb_newbook1 ";
}
/* ตั้งค่า แสดงผลต่อหน้า $Per_Page */
$Per_Page =15;
if(!$Page)
$Page=1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$result = mysql_query($sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
if($Num_Rows<=$Per_Page)
$Num_Pages =1;
else if(($Num_Rows % $Per_Page)==0)
$Num_Pages =($Num_Rows/$Per_Page) ;
else
$Num_Pages =($Num_Rows/$Per_Page) +1;
$Num_Pages = (int)$Num_Pages;
if(($Page>$Num_Pages) || ($Page<0))
echo " จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ ";
if ($field<>"") {
$sql = "select * from $tb_newbook1 where $field like '%$search%' " ;
} else {
$sql = "select * From $tb_newbook1";
}
$sql .= " Order by b_id DESC LIMIT $Page_start , $Per_Page";
?>
แสดงรายการ : ทะเบียนหนังสือทั้งหมด [ทะเบียนหนังสือรับ] [ทะเบียนหนังสือส่ง] [ส่งหนังสือ]
echo " ";
echo "แสดงข้อมูลทั้งหมด $Num_Rows รายการ กำลังแสดงผลหน้าที่ $Page จากทั้งหมด $Num_Pages หน้า " ;
echo " " ;
if($Prev_Page) {
echo " ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page){
echo " [$i ] ";
}elseif($i == $Page){
echo " [$i] ";
}
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages){
echo " ";
}
?>
}else {
header ("Location:index.php") ;
exit ();
} //จบการอนุญาตเฉพาะ admin และ สารบรรณ
include("footer.php");
}
############################################
###################
switch($mod) {
case "listallbook":
listallbook($field, $search, $Page) ;
break;
case "edituser":
edituser($e_username, $e_name, $e_password, $group, $user_type, $last_receive_id, $last_send_id, $send_prefix ) ;
break;
case "formedituser":
formedituser($e_username, $user_type, $last_receive_id, $last_send_id, $send_prefix) ;
break;
case "chngpwd":
chngpwd( $e_username, $oldpass, $newpass) ;
break;
case "detail":
detail();
break;
case "editdetail":
editdetail($user_name, $user_position, $user_tel, $user_email, $last_receive_id, $last_send_id, $send_prefix);
break;
case "usergroup":
usergroup($field, $search, $Page );
break;
case "addusergroup":
addusergroup($name, $username, $password, $status, $group);
break;
case "userpublic":
userpublic($field, $search, $Page );
break;
case "adduserpublic":
adduserpublic($name, $username, $password, $status, $group);
break;
case "adduser":
adduser($name, $username, $password, $status, $group);
break;
case "del_group":
del_group($g_id, $boxchecked);
break;
case "addgroup":
addgroup($groupname);
break;
case "user":
user($field, $search, $Page );
break;
case "form_send":
form_send($online_name);
break;
case "list_book_in":
list_book_in($field, $search, $Page);
break;
case "list_book_out":
list_book_out($field, $search, $Page);
break;
case "checklogin":
checklogin($Username,$Password,$refferal);
break;
case "logout1":
logout1();
break;
case "login":
login($error);
break;
default:
login($error);
break;
}
?>