From a56b4c00dd96177f09fdf9f5ad196d5de76c4334 Mon Sep 17 00:00:00 2001 From: Lan Hui Date: Tue, 1 Aug 2023 17:02:33 +0800 Subject: [PATCH] (1) Make php files look better; (2) Removed Visitors.php and Reset_password.php because they are no longer used; (3) TODO: review Submissions.php, Script.php, Course.php and Courses.php. --- Admin.php | 431 ++++++++--------- Course.php | 1086 +++++++++++++++++++++--------------------- Courses.php | 34 +- Header.php | 4 + NoDirectPhpAcess.php | 10 +- Reset_password.php | 49 -- Student.php | 5 +- SubmitLab.php | 189 ++++---- Visitors.php | 63 --- logout.php | 1 + phpinfo.php | 7 - recover_password.php | 73 ++- signup.php | 14 - 13 files changed, 899 insertions(+), 1067 deletions(-) delete mode 100644 Reset_password.php delete mode 100644 Visitors.php delete mode 100644 phpinfo.php diff --git a/Admin.php b/Admin.php index 8280aa5..bf39f0f 100644 --- a/Admin.php +++ b/Admin.php @@ -16,278 +16,261 @@ if ($_SESSION['user_type'] != "Lecturer" && $_SESSION['user_type'] != "Admin") { ?> - -
-

Administration Panel

+

Administration panel


- -
+
- TA Account Management -
" ; - echo "TA Accounts
" ; - } - else if($_SESSION['user_type'] == "Admin"){ - echo "

Lecturer Account Management

-
"; - echo "Lecturer Accounts
"; - } - - ?> - -
- - - - - -
- -

- - Create TA Accounts "; + - Passport Number / ID (Used as Initial Password) - -
User Type : +
- +
+ + + + + + + + +
+
-
-
+
-
- -
- - - - +
+
- -
- \ No newline at end of file + window.location.href = "\Script.php\?action=passchange&uid=" + id + "&pass=" + pass; + } + + function blockUser(id, status) { + if (!confirm('Are you sure to change user status?')) { + return; + } + window.location.href = "\Script.php\?action=statuschange&uid=" + id + "&status=" + status; + } + diff --git a/Course.php b/Course.php index 5dc8583..ae67582 100644 --- a/Course.php +++ b/Course.php @@ -15,17 +15,17 @@ if(!empty($_GET["url"])) { $course_url = mysqli_real_escape_string($con, $_GET["url"]); $result = mysqli_query($con,"SELECT `Course_ID`, `Course_Name`, `Academic_Year`, `Faculty`," - . " `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` " - . " , users_table.Full_Name FROM `courses_table` INNER JOIN users_table" - . " ON users_table.User_ID=courses_table.Lecturer_User_ID where URL='$course_url' "); - + . " `Lecturer_User_ID`, `TA_User_ID`, `Course_Code`, `URL`, `Verify_New_Members` " + . " , users_table.Full_Name FROM `courses_table` INNER JOIN users_table" + . " ON users_table.User_ID=courses_table.Lecturer_User_ID where URL='$course_url' "); + if(mysqli_num_rows($result)==0) { echo "No course matching the given course URL: ".$course_url; } else { while($row = mysqli_fetch_assoc($result)) { - $name = $row['Course_Name']; + $name = $row['Course_Name']; $code = $row['Course_Code']; $faculty = $row['Faculty']; $lecturer = $row['Full_Name']; @@ -55,18 +55,18 @@ if(!empty($_GET["url"]))
-'; - $_SESSION['info_general']=null; -} - -if (isset($_SESSION['info_courses'])) { - echo '
'; - $_SESSION['info_courses']=null; -} -?> + if (isset($_SESSION['info_general'])) { + echo '
'; + $_SESSION['info_general']=null; + } + + if (isset($_SESSION['info_courses'])) { + echo '
'; + $_SESSION['info_courses']=null; + } + ?>
@@ -77,232 +77,232 @@ if (isset($_SESSION['info_courses'])) { if( $_SESSION['user_type'] == "Student") { - ?> +?>
-
- - +
+ + - - -
- + +
+

Class Groups

+ + Create Group"; - - ?> - - - -
-Create group"; + + ?> + + + +
+ Invite Others"; - - if($status=="Invited") - { - $extra2=" Accept"; - $extra3=" Decline"; - - } + + if(mysqli_num_rows($result)==0) + { + echo "You have no group in this course."; + } else { while($row = mysqli_fetch_assoc($result)) { + $name=$row['Group_Name']; + $id=$row['Course_Group_id']; + $status=$row['Status']; + + + $extra=" - Invite Others"; + + if($status=="Invited") + { + $extra2=" Accept"; + $extra3=" Decline"; + + } - # Add "delete group" button and allow only group creator to delete it - $extra4 = ""; - echo "
$name ($status) $extra $extra2 $extra3" . - (($status == "Created")? "$extra4": "") - ."
"; - - $rs2=mysqli_query($con,"SELECT `ID`, `Course_Group_id`, course_group_members_table.Student_ID, + echo "
$name ($status) $extra $extra2 $extra3" . + (($status == "Created")? "$extra4": "") + ."
"; + + $rs2=mysqli_query($con,"SELECT `ID`, `Course_Group_id`, course_group_members_table.Student_ID, course_group_members_table.`Status`,users_table.Full_Name FROM `course_group_members_table` INNER JOIN users_table on users_table.Student_ID=course_group_members_table.Student_ID where course_group_members_table.Course_Group_id=$id"); - - #Check whether the current user in session is the creator of the group - $rs3 = mysqli_query($con, "SELECT `Status` from course_group_members_table where Student_ID = $student_id"); - $flag = mysqli_fetch_assoc($rs3)['Status'] == "Created"; + + #Check whether the current user in session is the creator of the group + $rs3 = mysqli_query($con, "SELECT `Status` from course_group_members_table where Student_ID = $student_id"); + $flag = mysqli_fetch_assoc($rs3)['Status'] == "Created"; - while($row = mysqli_fetch_assoc($rs2)) { - $name=$row['Full_Name']; - $id=$row['Course_Group_id']; - $status=$row['Status']; - $Student_ID=$row['Student_ID']; - - #Show group members + remove button next to each member except the creator of the group - if($flag){ - echo "
  • $name-$Student_ID ($status)".(($status != "Created")?"":"")."
  • "; - }else{ - echo "
  • $name-$Student_ID ($status)"; - } - + }else{ + echo "
  • $name-$Student_ID ($status)"; + } + + } + + + + + + + } - - - - - - - - } - } - ?> - + } + ?> + - - - -
  • - + + + +
    +
    @@ -596,66 +596,66 @@ include 'Footer.php'; - + diff --git a/Courses.php b/Courses.php index 4279f40..a82642f 100644 --- a/Courses.php +++ b/Courses.php @@ -203,7 +203,7 @@ New Date/Time
    -

    Post new Lab Assignment

    +

    New an assignment

    - Deadline Date/Time + Deadline (date and time)
    @@ -221,9 +221,9 @@ New Date/Time
    - Instructions + Instruction - Marks + Mark Attachment 1 @@ -238,11 +238,11 @@ New Date/Time

    - Submission Type Individual + Submission type: Individual Group
    -
    +




    "; - echo "

    Lab Report Assignment list

    "; + echo "

    Assignment list

    "; error_reporting(0); if(isset($_SESSION["info_Updated"])){ @@ -276,7 +276,7 @@ New Date/Time
    *Only Lecturer can post a new lab report assignment
    "; + echo "Only Lecturer can post assignments.
    "; } if(mysqli_num_rows($result)==0) { @@ -441,7 +441,7 @@ WHERE Lecturer_User_ID=$lecturer_id and course_students_table.Status='Pending'" if(mysqli_num_rows($result)==0) { - echo "
    No Course joining request so far for all your courses
    "; + echo "
    No course-joining request so far for all your courses
    "; } else { while($row = mysqli_fetch_assoc($result)) { $id=$row['ID']; @@ -464,7 +464,7 @@ WHERE Lecturer_User_ID=$lecturer_id and course_students_table.Status='Pending'" Only Lecturers can Post new Lab report Assignments"; + echo "
    Only Lecturer can post assignments
    "; } if( $_SESSION['user_type']=="Lecturer"){ ?> @@ -473,16 +473,16 @@ WHERE Lecturer_User_ID=$lecturer_id and course_students_table.Status='Pending'"
    - Course Name + Course name - Course Code + Course code URL (Leave blank to use Course Code & Year) - Academic Year + Academic year Faculty
    @@ -492,7 +492,7 @@ WHERE Lecturer_User_ID=$lecturer_id and course_students_table.Status='Pending'" - Verify Joining Students + Verify joining students? Yes No @@ -570,7 +570,7 @@ if( $_SESSION['user_type']=="Student") if(mysqli_num_rows($result)==0) { - echo "No results found for your Search
    "; + echo "No results found ...
    "; } else { @@ -643,9 +643,9 @@ INNER JOIN course_students_table on course_students_table.Course_ID=courses_tabl
    -
    Find course by Code +
    Find course by course code -
    +
    List courses by faculty - - Email - -
    - New Password - - -
    - -
    - - -
    - -
    -
    - -
    - -
    -
    diff --git a/Student.php b/Student.php index 4541fc5..bcca070 100644 --- a/Student.php +++ b/Student.php @@ -1,7 +1,6 @@


    @@ -9,7 +8,7 @@ include 'Header.php';
    -

    Student Account Created. Now you can Browse Course Portals

    +

    Student account created. Now you can browse the course portal.

    -
    \ No newline at end of file +
    diff --git a/SubmitLab.php b/SubmitLab.php index c8b1fdb..167087c 100644 --- a/SubmitLab.php +++ b/SubmitLab.php @@ -10,126 +10,121 @@ include 'Header.php';
    - '$c_date' ORDER by Lab_Report_ID DESC"); - if(mysqli_num_rows($result1) == 0) + $c_date = date("Y-m-d H:i"); + $student_id = $_SESSION["user_student_id"]; + + if(!empty($_GET["id"])) { - echo "No active assignments for this course so far."; - - } else { - - while($row = mysqli_fetch_assoc($result1)) { - - $Course_ID = $row['Course_ID']; - $title = $row['Title']; - $ins = $row['Instructions']; - $posted = $row['Posted_Date']; - $deadline = $row['Deadline']; - $att1 = $row['Attachment_link_1']; - $att2 = $row['Attachment_link_2']; - $att3 = $row['Attachment_link_3']; - $att4 = $row['Attachment_link_4']; - $labid = $row['Lab_Report_ID']; - $type = $row['Type']; - - //----------------------------------Giving both the Group Admin and Group Members same priviledges to submit assignment-------------------------------------- - if($type=="Group"){ - $resultx1 = mysqli_query($con,"SELECT Course_Group_id FROM `course_groups_table` WHERE (Course_id=$Course_ID) and ((Group_Member=$student_id ) or (Group_Member2=$student_id ) or (Group_Member3=$student_id ) or (Group_Member4=$student_id ) or (Group_Leader=$student_id))"); - while($row = mysqli_fetch_assoc($resultx1)) { - $_SESSION["Group_ID"] = $row['Course_Group_id']; - } - - if($_SESSION["Group_ID"] < 1) - { - echo"

    This Lab report can only be submitted by Group Admin

    "; - return; - } - } - - - $full_link="$att1"; - - if($att2!=""){ - $full_link = $full_link."| $att2"; - } - if($att3!=""){ - $full_link = $full_link."| $att3"; - } - - if($att4!=""){ - $full_link = $full_link."| $att4"; - } - - echo "
    + $id = mysqli_real_escape_string($con, $_GET["id"]); + $url = mysqli_real_escape_string($con, $_GET["url"]); + + $result1 = mysqli_query($con," SELECT `Type`, `Lab_Report_ID`, `Course_ID`, `Posted_Date`, `Deadline`, `Instructions`, `Title`, `Attachment_link_1`, `Attachment_link_2`, `Attachment_link_3`, `Attachment_link_4` FROM `lab_reports_table` WHERE Lab_Report_ID=$id and Deadline > '$c_date' ORDER by Lab_Report_ID DESC"); + if(mysqli_num_rows($result1) == 0) + { + echo "No active assignments for this course so far."; + + } else { + + while($row = mysqli_fetch_assoc($result1)) { + + $Course_ID = $row['Course_ID']; + $title = $row['Title']; + $ins = $row['Instructions']; + $posted = $row['Posted_Date']; + $deadline = $row['Deadline']; + $att1 = $row['Attachment_link_1']; + $att2 = $row['Attachment_link_2']; + $att3 = $row['Attachment_link_3']; + $att4 = $row['Attachment_link_4']; + $labid = $row['Lab_Report_ID']; + $type = $row['Type']; + + //----------------------------------Giving both the Group Admin and Group Members same priviledges to submit assignment-------------------------------------- + if($type=="Group"){ + $resultx1 = mysqli_query($con,"SELECT Course_Group_id FROM `course_groups_table` WHERE (Course_id=$Course_ID) and ((Group_Member=$student_id ) or (Group_Member2=$student_id ) or (Group_Member3=$student_id ) or (Group_Member4=$student_id ) or (Group_Leader=$student_id))"); + while($row = mysqli_fetch_assoc($resultx1)) { + $_SESSION["Group_ID"] = $row['Course_Group_id']; + } + + if($_SESSION["Group_ID"] < 1) + { + echo"

    This Lab report can only be submitted by Group Admin

    "; + return; + } + } + + + $full_link="
    $att1"; + + if($att2!=""){ + $full_link = $full_link."| $att2"; + } + if($att3!=""){ + $full_link = $full_link."| $att3"; + } + + if($att4!=""){ + $full_link = $full_link."| $att4"; + } + + echo " - "; + "; - echo ""; - } + echo ""; + } + } } -} -$Group_ID = $_SESSION["Group_ID"]; + $Group_ID = $_SESSION["Group_ID"]; -?> + ?>
    - -
    -

    Submit Lab Report Assignment

    -
    +

    Submit assignment

    +
    - -
    + +
    -
    - - - - - - - Title - + + + + + + + + Title + - Attachment 1 - + Attachment 1 + - Attachment 2 - + Attachment 2 + -
    -
    + Attachment 3 + - Attachment 3 - + Attachment 4 + +
    + +
    + + +
    - Attachment 4 - -
    - -
    - - -
    - -
    +
    diff --git a/Visitors.php b/Visitors.php deleted file mode 100644 index c732ce2..0000000 --- a/Visitors.php +++ /dev/null @@ -1,63 +0,0 @@ - - - - "; - - $result = mysqli_query($con, "SELECT `Submission_ID`, `Submission_Date`, lab_report_submissions.Student_id, - `Attachment1`, `Notes`, `Attachment2`, `Attachment3`, `Attachment4`, `Marks`, `Title`, `Visibility` , - users_table.Full_Name,course_groups_table.Group_Name -FROM `lab_report_submissions` -left join users_table on users_table.Student_ID=lab_report_submissions.Student_id -left JOIN course_groups_table on course_groups_table.Course_Group_id=lab_report_submissions.Course_Group_id -WHERE Visibility='Public' "); - if (mysqli_num_rows($result) == 0) { - } else { - while ($row = mysqli_fetch_assoc($result)) { - $att1 = $row['Attachment1']; - $att2 = $row['Attachment2']; - - $sdate = $row['Submission_Date']; - $att3 = $row['Attachment3']; - $att4 = $row['Attachment4']; - $labid = $row['Lab_Report_ID']; - $title = $row['Title']; - - $submitted_std = $row['Student_id']; - $submitted_group = $row['Course_Group_id']; - $Submission_ID = $row['Submission_ID']; - $sname = $row['Full_Name']; - $gname = $row['Group_Name']; - $Visibility = $row['Visibility']; - - $full_link = "$att1"; - - if ($att2 != "") { - $full_link = $full_link . "| $att2"; - } - if ($att3 != "") { - $full_link = $full_link . "| $att3"; - } - - if ($att4 != "") { - $full_link = $full_link . "| $att4"; - } - - echo " - -
    - $title by $gname $sname -
    Submission Date :$sdate      Files : $full_link -
    - "; - } - } ?> -
    \ No newline at end of file diff --git a/logout.php b/logout.php index 7ff6624..8b98508 100644 --- a/logout.php +++ b/logout.php @@ -2,6 +2,7 @@ // Start a new session session_start(); + // Destory sessions & redirect to index session_destroy(); session_unset(); diff --git a/phpinfo.php b/phpinfo.php deleted file mode 100644 index 74a8ccc..0000000 --- a/phpinfo.php +++ /dev/null @@ -1,7 +0,0 @@ -'; -echo 'LOADED EXTENSIONS:
    '; -print_r(get_loaded_extensions()); -echo ''; -echo phpinfo(); -?> \ No newline at end of file diff --git a/recover_password.php b/recover_password.php index d9ae8a2..0e9348d 100644 --- a/recover_password.php +++ b/recover_password.php @@ -1,60 +1,43 @@
    - -
    + +
    -
    - -

    Reset my password

    -
    +
    + +

    Reset password

    +
    -
    -
    - - Student number -
    - Email -
    - - -
    +
    +
    + + Student number +
    + Email +
    + +
    -'; - $_SESSION['info_recover_password']=null; -} + if(isset($_SESSION['info_recover_password'])) { + echo '
    '; + $_SESSION['info_recover_password'] = null; + } -?> + ?> +
    - +
    + +
    + +
    diff --git a/signup.php b/signup.php index ae17b5e..b5c7d3b 100644 --- a/signup.php +++ b/signup.php @@ -48,17 +48,3 @@ include 'Header.php';
    - \ No newline at end of file