예제 #1
0
/**
 * Garbage collector
 */
function HotPotGCt($folder, $flag, $userID)
{
    // Garbage Collector
    $filelist = array();
    if ($dir = @opendir($folder)) {
        while (($file = readdir($dir)) !== false) {
            if ($file != ".") {
                if ($file != "..") {
                    $full_name = $folder . "/" . $file;
                    if (is_dir($full_name)) {
                        HotPotGCt($folder . "/" . $file, $flag);
                    } else {
                        $filelist[] = $file;
                    }
                }
            }
        }
        closedir($dir);
    }
    while (list($key, $val) = each($filelist)) {
        if (stristr($val, $userID . ".t.html")) {
            if ($flag == 1) {
                my_delete($folder . "/" . $val);
            } else {
                echo $folder . "/" . $val . "<br />";
            }
        }
    }
}
예제 #2
0
                break;
            default:
                break;
        }
    }
}
// Actions div bar
if ($is_allowedToEdit) {
    echo '<div class="actions">';
}
// Selects $limit exercises at the same time
// maximum number of exercises on a same page
$limit = 50;
// Display the next and previous link if needed
$from = $page * $limit;
HotPotGCt($documentPath, 1, $userId);
//condition for the session
$course_code = api_get_course_id();
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id, true, true);
// Only for administrators
if ($is_allowedToEdit) {
    $total_sql = "SELECT count(iid) as count FROM {$TBL_EXERCISES}\n                  WHERE c_id = {$courseId} AND active<>'-1' {$condition_session} ";
    $sql = "SELECT * FROM {$TBL_EXERCISES}\n            WHERE c_id = {$courseId} AND active<>'-1' {$condition_session}\n            ORDER BY title\n            LIMIT " . $from . "," . $limit;
} else {
    // Only for students
    $total_sql = "SELECT count(iid) as count FROM {$TBL_EXERCISES}\n                  WHERE c_id = {$courseId} AND active = '1' {$condition_session} ";
    $sql = "SELECT * FROM {$TBL_EXERCISES}\n            WHERE c_id = {$courseId} AND\n                  active='1' {$condition_session}\n            ORDER BY title LIMIT " . $from . "," . $limit;
}
$result = Database::query($sql);
$result_total = Database::query($total_sql);
예제 #3
0
                break;
            default:
                break;
        }
    }
}
// Actions div bar
if ($is_allowedToEdit) {
    echo '<div class="actions">';
}
// Selects $limit exercises at the same time
// maximum number of exercises on a same page
$limit = 50;
// Display the next and previous link if needed
$from = $page * $limit;
HotPotGCt($documentPath, 1, api_get_user_id());
//condition for the session
$course_code = api_get_course_id();
$courseId = api_get_course_int_id();
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id, true, true);
// Only for administrators
if ($is_allowedToEdit) {
    $total_sql = "SELECT count(iid) as count FROM {$TBL_EXERCICES} WHERE c_id = {$course_id} AND active<>'-1' {$condition_session} ";
    $sql = "SELECT * FROM {$TBL_EXERCICES} WHERE c_id = {$course_id} AND active<>'-1' {$condition_session} ORDER BY title LIMIT " . $from . "," . $limit;
} else {
    // Only for students
    $total_sql = "SELECT count(iid) as count FROM {$TBL_EXERCICES} WHERE c_id = {$course_id} AND active = '1' {$condition_session} ";
    $sql = "SELECT * FROM {$TBL_EXERCICES}\n            WHERE c_id = {$course_id} AND\n                  active='1' {$condition_session}\n            ORDER BY title LIMIT " . $from . "," . $limit;
}
$result = Database::query($sql);
예제 #4
0
/**
 * Hotpotato Garbage Collector
 * @param    string     Path
 * @param    integer    Flag
 * @param    integer    User id
 * @return   void       No return value, but echoes results
 */
function HotPotGCt($folder, $flag, $user_id)
{
    // Garbage Collector
    $filelist = array();
    if ($dir = @opendir($folder)) {
        while (($file = readdir($dir)) !== false) {
            if ($file != '.') {
                if ($file != '..') {
                    $full_name = $folder . '/' . $file;
                    if (is_dir($full_name)) {
                        HotPotGCt($folder . '/' . $file, $flag, $user_id);
                    } else {
                        $filelist[] = $file;
                    }
                }
            }
        }
        closedir($dir);
    }
    while (list($key, $val) = each($filelist)) {
        if (stristr($val, $user_id . '.t.html')) {
            if ($flag == 1) {
                my_delete($folder . '/' . $val);
            } else {
                echo $folder . '/' . $val . '<br />';
            }
        }
    }
}