Example #1
0
function display_gallery_dir($galid, $picid = 0)
{
    global $config;
    global $strGalerieInconnue, $strCategories, $strSousCategories, $strImages, $strDescription;
    $galdir = $config['gallery_path'] . "/{$galid}";
    $dir = @opendir($galdir);
    $gals = array();
    while ($file = readdir($dir)) {
        // need management for unreadable dirs
        if ($file != "." && $file != ".." && is_dir("{$galdir}/{$file}")) {
            $gals[count($gals)] = $file;
        }
    }
    if (count($gals) > 0) {
        sort($gals);
    }
    $max = count($gals);
    $counter = 0;
    if ($galid || $max) {
        echo "<table border=0 cellpadding=0 cellspacing=0 class=bordure1 width=80%><tr><td>";
        echo "<table cellspacing=1 cellpadding=0 border=0 width=100%>";
        echo "<tr><td class=titlecategorie align=center>";
        if ($galid) {
            echo "<table><tr><td class=titlecategorie>{$strCategories} :</td>";
            echo "<td><a href=\"?page=galerie\"><img src=\"images/dir.gif\" border=0></a></td>";
            $arraygal = explode("/", $galid);
            $linkgal = "{$arraygal['0']}";
            for ($i = 0; $i < count($arraygal); $i++) {
                $labelgal = ereg_replace("_", " ", $arraygal[$i]);
                echo "<td><img src=\"images/next.gif\" align=absmidlle></td><td class=titlecategorie><a href=\"?page=galerie&g={$linkgal}\">{$labelgal}</a></td>";
                $linkgal .= "/" . $arraygal[$i + 1];
            }
            echo "</tr></table><br>";
        }
        if ($max && !$picid) {
            reset($gals);
            echo "{$strSousCategories} :<br>";
            echo "<table cellspacing=0 cellpadding=10 border=0>";
            while (list($key, $val) = each($gals)) {
                $file = $val;
                $gallery_name = ereg_replace("_", " ", $file);
                if ($galid == "") {
                    $sub_galid = $file;
                } else {
                    $sub_galid = $galid . "/" . $file;
                }
                $nbpics_info = count_pictures($sub_galid);
                $nb_pics = $nbpics_info[0];
                $nb_new_pics = $nbpics_info[1];
                $new_pictures = "";
                if ($nb_pics == $nb_new_pics && $nb_pics != 0) {
                    $new_pictures = "<img src=\"images/new.gif\" border=\"0\"> ";
                }
                if ($counter % $config['col_categories'] == 0) {
                    echo "<tr>";
                }
                echo "<td valign=\"top\">";
                echo "<table cellspacing=0 cellpadding=0 border=0><tr>";
                echo "<td valign=top><a href=\"?page=galerie&g={$sub_galid}\"><img src=\"images/dir.gif\" border=\"0\" align=\"top\"></a>&nbsp;</td>";
                echo "<td class=\"text2\" width=120>";
                echo "<a href=\"?page=galerie&g={$sub_galid}\"><b>{$gallery_name}</b></a> {$new_pictures}<br>";
                echo "<i>{$strImages}</i> : <b>{$nb_pics}</b><br>";
                $msg_file = "{$galdir}/{$file}/galerie.info";
                if (check_perms($msg_file)) {
                    echo "<i>{$strDescription}</i> :";
                    include_once $msg_file;
                }
                echo "</td>";
                echo "</tr></table>";
                echo "</td>";
                if ($counter % $config['col_categories'] == $config['col_categories'] - 1) {
                    echo "</tr>";
                }
                $counter++;
            }
            echo "</table>";
        }
        echo "</td></tr></table></td></tr></table>";
        closedir($dir);
    }
}
            // Add a new album
            $action_result = add_album($_POST['name'], $_POST['description'], $_POST['parent_collection']);
            break;
    }
    if (!empty($action_result['errors'])) {
        // If there are any errors from the actions above, display the errors for the user
        $output .= "\n\t" . '<p class="errors">' . $action_result['errors'] . '</p>' . "\n";
    } elseif (!empty($action_result['output'])) {
        // Else if no errors, display the successful output
        $output .= "\n\t" . '<p class="success">' . $action_result['output'] . '</p>' . "\n";
    }
}
if (!isset($edit_page)) {
    // Display the gallery statistics on the main page
    if ($level == 'collections') {
        $output .= "\n\t" . '<p class="stats"><strong>' . plog_tr('Gallery Stats:') . '</strong> ' . plog_tr('You have') . ' <strong>' . count_collections() . '</strong> ' . plog_tr('collections, which contain') . ' <strong>' . count_albums() . '</strong> ' . plog_tr('albums and') . ' <strong>' . count_pictures() . '</strong> ' . plog_tr('images. Users have posted') . ' <strong>' . count_comments() . '</strong> ' . plog_tr('comments to your gallery.') . '</p>' . "\n";
    }
    // Here we will generate an 'add collection/album' header form
    if ($level == 'collections') {
        $output .= plog_add_collection_form();
    } else {
        if ($level == 'albums') {
            $output .= plog_add_album_form($id);
        }
    }
    // Let's iterate through all the content and build a table
    // Set the default level if nothing is specified
    // Handle pagination
    // Let's determine the limit filter based on current page and number of results per page
    if (isset($_REQUEST['entries_per_page'])) {
        $_SESSION['entries_per_page'] = $_REQUEST['entries_per_page'];