Example #1
0
}
// view course details
$header_tag_extras = "";
$header_section_styles = "";
$header_section_metas = "";
$header_section_scripts = "";
$header_section_extras = "";
$body_tag_extras = "";
$body_section_styles = "";
$body_section_scripts = "";
$navbar_signup_login = "";
require '../database/models.php';
$loggedin_user_info = getUserInfoByUserID($_SESSION['user_id']);
$logged_in_name = "Welcome " . $loggedin_user_info['name'];
// get all files
$course = getInfoByCourseID($_REQUEST['page_course_id']);
$files = getFilesByCourseID($_REQUEST['page_course_id']);
$body_section_content = '<h1> Information About Course: </h1>';
$body_section_content .= '<form enctype="multipart/form-data" method="POST" action="upload.php">
        ID: <input type="text" readonly name="ID" value="' . $course['ID'] . '"><br>
        Name: <input type="text" readonly name="name" value="' . $course['name'] . '"><br>
        Code: <input type="text" readonly name="code" value="' . $course['code'] . '"><br>
        Semester: <input type="text" readonly name="semester" value="' . $course['semster'] . '"><br>
        Year: <input type="text" readonly name="year" value="' . $course['year'] . '"><br>';
$body_section_content .= '<p>You can add links to files, remove links or update links or save your files on the cloud.</p><table border=1><tr>';
$i = 1;
// add information about the 6 files of the Course
foreach ($files as $file) {
    $body_section_content .= '<td>' . str_replace("_", " ", $file['type']) . ': <input type="text" name="' . $file['type'] . '" value="';
    if ($file['data'] == NULL) {
        $body_section_content .= '" placeholder="Insert Link to file."/><br>';
Example #2
0
<?php

session_start();
if (!isset($_SESSION['user_id']) || strcmp($_SESSION['type'], 'instractor') != 0 || !isset($_POST['ID'])) {
    // redirect unauthorized user at once to homepage
    header('Location: http://localhost/qa/index.php');
    die;
}
require '../database/models.php';
echo "<h1>Please wait while processing your request</h1><p><ol>";
$course = getInfoByCourseID($_POST['ID']);
$names = array('Course_Specifications', 'Materials_&_Labs', 'Assignments_&_Project_Documents', 'Midterm_Exam', 'Final_Exam', 'End_of_Course_Report');
$db_files = getFilesByCourseID($_POST['ID']);
// base directory
$target_dir = "../uploads/" . $course['code'] . '_' . $course['semster'] . '_' . $course['year'] . '/';
$uploadOk = 1;
foreach ($names as $name) {
    $update_link = $_POST[$name];
    $file = 'upload_' . $name;
    if (!empty($_FILES[$file]["name"])) {
        $target_file = $target_dir . basename($_FILES[$file]["name"]);
        // Check if file already exists
        if (file_exists($target_file)) {
            echo "<li>Sorry, file already exists.</li>";
            $uploadOk = 0;
        }
        // Check file size, max 32 MB
        if ($_FILES[$file]["size"] > 33554432) {
            echo "<li>Sorry, your file is too large." . $_FILES[$file]["size"] . '</li>';
            $uploadOk = 0;
        }