Пример #1
0
function delDirTree($dir)
{
    $files = array_diff(scandir($dir), array('.', '..'));
    foreach ($files as $file) {
        is_dir("{$dir}/{$file}") && !is_link($dir) ? delDirTree("{$dir}/{$file}") : unlink("{$dir}/{$file}");
    }
    return rmdir($dir);
}
Пример #2
0
function delDirTree($path)
{
    $dirobj = dir($path);
    while (false !== ($entry = $dirobj->read())) {
        if ($entry != "." && $entry != "..") {
            $currpath = $dirobj->path . '/' . $entry;
            if (is_dir($currpath)) {
                delDirTree($currpath);
            } else {
                unlink($currpath);
            }
        }
    }
    $dirobj->close();
    rmdir($path);
}
Пример #3
0
function _scorm_deleteitem($idscorm_package, $idscorm_organization, $erasetrackcontent = FALSE)
{
    /* remove items: based on organizations */
    //$rs = sql_query("SELECT idscorm_organization FROM ".$prefix."_scorm_organizations WHERE idscorm_package=".$idscorm_package);
    //while(list($idscorm_organization) = sql_fetch_row($rs)) {
    if ($erasetrackcontent) {
        // selected tracking remove
        $rsItems = sql_query("SELECT idscorm_item FROM " . $GLOBALS['prefix_lms'] . "_scorm_items WHERE idscorm_organization=" . $idscorm_organization);
        while (list($idscorm_item) = sql_fetch_row($rsItems)) {
            sql_query("DELETE FROM " . $GLOBALS['prefix_lms'] . "_scorm_tracking WHERE idscorm_resource=" . $idscorm_item);
        }
    }
    sql_query("DELETE FROM " . $GLOBALS['prefix_lms'] . "_scorm_items WHERE idscorm_organization=" . $idscorm_organization);
    //}
    /* remove organizations */
    sql_query("DELETE FROM " . $GLOBALS['prefix_lms'] . "_scorm_organizations WHERE idscorm_organization=" . $idscorm_organization);
    // detect if there are other organization in package
    $rs = sql_query("SELECT idscorm_organization FROM " . $GLOBALS['prefix_lms'] . "_scorm_organizations WHERE idscorm_package=" . $idscorm_package);
    if (mysql_num_rows($rs) == 0) {
        $rs = sql_query("SELECT path FROM " . $GLOBALS['prefix_lms'] . "_scorm_package WHERE idscorm_package='" . (int) $idscorm_package . "'") or die(mysql_error());
        list($path) = sql_fetch_row($rs);
        $scopath = str_replace('\\', '/', $GLOBALS['where_files_relative'] . '/appLms/' . Get::sett('pathscorm'));
        /* remove all zip directory */
        if (file_exists($scopath . $path)) {
            /* if is the only occurrence of path in db delete files */
            $rs = sql_query("SELECT idscorm_package FROM " . $GLOBALS['prefix_lms'] . "_scorm_package" . " WHERE path = '" . $path . "'");
            if (mysql_num_rows($rs) == 1) {
                $size = Get::dir_size($scopath . $path);
                require_once dirname(__FILE__) . '/scorm_utils.php';
                // for del tree
                delDirTree($scopath . $path);
                if (isset($_SESSION['idCourse']) && defined("LMS")) {
                    $GLOBALS['course_descriptor']->subFileToUsedSpace(false, $size);
                }
            }
        }
        /* remove resources */
        sql_query("DELETE FROM " . $GLOBALS['prefix_lms'] . "_scorm_resources WHERE idscorm_package=" . $idscorm_package);
        /* remove packages */
        sql_query("DELETE FROM " . $GLOBALS['prefix_lms'] . "_scorm_package WHERE idscorm_package=" . $idscorm_package);
    }
}