Esempio n. 1
0
/**
 display the contents of a directory
*/
function display_directory($dir, $valid_file_types, $type, $lessons_ID)
{
    //$dir = urldecode($dir);
    $dir = preg_replace("#/+#", "/", "{$dir}");
    $dir = preg_replace("#/\$#", "", $dir);
    $dir = stripslashes($dir);
    //echo $dir;
    if (!($d = dir($dir))) {
        mkdir($dir, 0755);
        if (!($d = dir($dir))) {
            echo "\t " . _CANNOTOPENFOLDER . " - [{$dir}]";
            return;
        }
    }
    if ($type == "all") {
        $parentpage = "add_files.php";
        $target = 'target = "_parent"';
        echo '<a href = "javascript:void(0)" onClick = "popUp(\'/add_files.php?op=createfolder&dir=' . urlencode(str_replace(G_LESSONSPATH, '', $dir)) . '\', 300, 300)"><img hspace = "2" src = "icons/close_folder.png" alt = "' . _CREATEFOLDER . '" border = "0">' . _CREATEFOLDER . '</a><br>';
    } else {
        $parentpage = "editor/browse.php";
    }
    // ��� ������� ���� import/export ������;
    if (is_file(G_LESSONSPATH . $lessons_ID . "/data.tgz")) {
        @unlink(G_LESSONSPATH . $lessons_ID . "/data.tgz");
    }
    if ($lessons_ID != "") {
        if (G_LESSONSPATH . $lessons_ID != $dir) {
            //This means that we are in a different folder (namely a subfolder) than the lesson root folder
            if ($_SESSION['s_type'] != "student") {
                $parts = explode('/', $dir);
                //Make directories array
                unset($parts[sizeof($parts) - 1]);
                //Unset the last one
                $previousdir = implode('/', $parts);
                //Rebuild path, which is now withot the last part of it
                $previousdir = str_replace(G_LESSONSPATH, '', $previousdir);
                //Remove path information from dir
                echo '
                    <a href = "' . $parentpage . '?lessons_ID=' . $lessons_ID . '&dir=' . urlencode($previousdir) . '&for_type=' . $type . '" ' . $target . '>
                    <img hspace = "2" src = "icons/close_folder.png" border = "0">&laquo;' . _BACK . '</a>
                    <br><br/>';
            }
            echo '<br/><img hspace = "2" src = "icons/open_folder.png" border = "0"><B>/' . mb_substr($dir, mb_strlen(G_LESSONSPATH . $lessons_ID) + 1) . '</B>';
        }
    } else {
        //echo $dir;
        if (G_ADMINPATH != $dir . "/") {
            //This means that we are in a different folder (namely a subfolder) than the admin root folder
            if ($_SESSION['s_type'] == "administrator") {
                $parts = explode('/', $dir);
                //Make directories array
                unset($parts[sizeof($parts) - 1]);
                //Unset the last one
                $previousdir = implode('/', $parts);
                //Rebuild path, which is now withot the last part of it
                $previousdir = str_replace(G_ADMINPATH, '/', $previousdir . "/");
                //Remove path information from dir
                echo '
                    <a href = "' . $parentpage . '?dir=' . urlencode($previousdir) . '&for_type=' . $type . '" ' . $target . '>
                    <img hspace = "2" src = "icons/close_folder.png" border = "0">&laquo;' . _BACK . '</a>
                    <br><br/>';
            }
            echo '<br/><img hspace = "2" src = "icons/open_folder.png" border = "0"><B>/' . mb_substr($dir, mb_strlen(G_ADMINPATH) + 1) . '</B>';
        }
    }
    echo "<hr/>";
    $first_time = true;
    while ($entry = $d->read()) {
        if (is_file("{$dir}/{$entry}")) {
            $ext = pathinfo($entry, PATHINFO_EXTENSION);
            if (!is_file("icons/{$ext}.png")) {
                $ext = "unknown";
            }
            if ($type == "all") {
                echo "<img hspace = \"2\" src = \"icons/{$ext}.png\" alt = \"\" border = \"0\">\n";
                print_file_name("{$dir}/{$entry}", $entry);
                echo " (", print_filesize("{$dir}/{$entry}"), ")";
                echo ' (<a href = "javascript:void(0)" onClick = "if (confirm(\'' . _IRREVERSIBLEACTIONAREYOUSURE . '\')) popUp(\'/add_files.php?op=delete&filename=' . urlencode(str_replace(G_LESSONSPATH, '', $dir) . '/' . $entry) . '\', 300, 300)">' . _DELETE . '</a>)<br>' . "\n";
            } elseif (in_array($ext, $valid_file_types) || sizeof($valid_file_types) == 0) {
                if ($_SESSION['s_type'] != "student") {
                    echo "<img hspace = \"2\" src = \"icons/{$ext}.png\" alt = \"\" border = \"0\">\n";
                }
                if ($type == "image") {
                    //echo "<br>".$dir."<br>".$entry;
                    print_copy_link_image("{$dir}/{$entry}", $entry);
                } elseif ($type == "files" || $type == 'all_files') {
                    if ($_SESSION['s_type'] == "student") {
                        if ($first_time) {
                            print '<table width = "100%">';
                            $first_time = false;
                        }
                        print_download_link("{$dir}/{$entry}", $entry, $ext);
                    } else {
                        print_copy_link("{$dir}/{$entry}", $entry);
                    }
                } elseif ($type == "flash") {
                    print_copy_link_flash("{$dir}/{$entry}", $entry);
                } elseif ($type == "java") {
                    print_copy_link_java("{$dir}/{$entry}", $entry);
                } elseif ($type == "videomusic") {
                    print_copy_link_videomusic("{$dir}/{$entry}", $entry);
                } elseif ($type == "media") {
                    print_copy_link_videomusic("{$dir}/{$entry}", $entry);
                }
                if ($_SESSION['s_type'] != "student") {
                    echo " (", print_filesize("{$dir}/{$entry}"), ")<br>\n";
                }
            }
        }
        if (is_dir("{$dir}/{$entry}") && $entry != '.' && $entry != '..') {
            $contents = eF_getDirContents($dir . '/' . $entry . '/');
            if (sizeof($contents) > 0) {
                $confirm_msg = _THISFOLDERCONTAINS . ' ' . sizeof($contents) . ' ' . _FILESANDSUBFOLDERS . '! ';
            }
            //echo $dir."<br>".$entry."<br>".$target;
            //echo $dir."<br>";
            //echo $entry."<br>";
            //echo $target;
            if ($lessons_ID != "") {
                printf("<a href = \"" . $parentpage . "?lessons_ID=" . $lessons_ID . "&dir=%s&for_type=" . $type . "\" " . $target . ">", urlencode(str_replace(G_LESSONSPATH, '', $dir) . "/" . $entry));
            } elseif ($_SESSION['s_type'] == "administrator") {
                printf("<a href = \"" . $parentpage . "?dir=%s&for_type=" . $type . "\" " . $target . ">", urlencode(str_replace(G_ADMINPATH, '', $dir . "/") . "/" . $entry));
            }
            printf("<img hspace = \"2\" src = \"icons/close_folder.png\" alt = \"" . _OPENFOLDER . "\" border = \"0\">%s</a>", $entry);
            if ($_SESSION['s_type'] != 'student') {
                echo ' (<a href = "javascript:void(0)" onClick = "if (confirm(\'' . $confirm_msg . _IRREVERSIBLEACTIONAREYOUSURE . '\')) popUp(\'/add_files.php?op=deletefolder&filename=' . urlencode(str_replace(G_LESSONSPATH, '', $dir) . '/' . $entry) . '\', 300, 300)">' . _DELETE . '</a>)<br>' . "\n";
            }
        }
    }
    if ($_SESSION['s_type'] == "student") {
        print "</table>";
    }
}
Esempio n. 2
0
        if ($value !== "/." && ($ext == "gif" || $ext == "jpg" || $ext == "jpeg" || $ext == "png" || substr($value, 0, 1) == "/")) {
            if (substr($value, 0, 1) == "/") {
                if ($value == "/..") {
                    $va = explode("/", $dir);
                    array_pop($va);
                    $dir1 = implode("/", $va);
                    $value1 = "";
                } else {
                    $dir1 = $dir;
                    $value1 = $value;
                }
                $image_manager_tr .= "<tr><td><b><a href=\"im.php?dir={$dir1}{$value1}&fake=" . time() . "\" onClick=\"javascript:parent.UPLOAD.document.NEWIMAGE.path.value='{$dir1}{$value1}';\">{$value}</a></td><td>" . $lang["Folder"] . "</b></td></tr>\n";
            } else {
                $size = getimagesize("{$d}/" . urldecode($value));
                $fs = stat("{$d}/" . urldecode($value));
                $a = print_copy_link("{$d}/" . $value, urldecode($value));
                $image_manager_tr .= "<tr><td>" . $a . "</td><td align=\"right\">" . $fs[7] / 1000 . "K</td></tr>\n";
            }
        }
    }
    closedir($handle);
    chdir("../");
    eval('$image_manager="' . admin::template("im") . '";');
    echo $image_manager;
}
function print_copy_link($path, $name)
{
    global $server_path, $HTTP_SERVER_VARS;
    $imgsize = GetImageSize(urldecode($path));
    $width = $imgsize[0];
    $height = $imgsize[1];