예제 #1
0
    function PrintThumbs()
    {
        global $config, $title, $i, $id;
        if (!$id) {
            header("location:?xl=Gallery&ID=1");
        }
        if ($id >= $i) {
            $msg = "Thể loại này không có thực<br>- Xin chọn thể loại từ danh mục có sẵn.";
            $page = "?xl=Home";
            page_load2($msg, $page);
            return false;
        }
        if (!file_exists($config['fulls'])) {
            $msg = "Thư mục chứa dữ liệu của <b>{$title}</b> chưa được tạo.";
            $page = "?xl=Home";
            page_load2($msg, $page);
            return false;
        }
        if (!file_exists($config['thumbs'])) {
            if (!@mkdir($config['thumbs'], 0755)) {
                $msg = "Không thể tạo được thư mục Thumbnail cho <b>{$title}</b>.<br>- Kiểm tra lại quyền truy xuất cho thư mục này.";
                $page = "?xl=Home";
                page_load2($msg, $page);
                return false;
            }
        }
        $imagelist = GetFileList($config['fulls']);
        $config['start'] = $config['page'] * $config['cols'] * $config['rows'];
        $config['max'] = $config['page'] * $config['cols'] * $config['rows'] + $config['cols'] * $config['rows'];
        if ($config['max'] > count($imagelist)) {
            $config['max'] = count($imagelist);
        }
        if ($config['start'] > count($imagelist)) {
            $config['start'] = 0;
        }
        echo '<table border="0" cellpadding="0" cellspacing="0" align="center" width="95%">';
        echo "<tr>\n<td colspan=\"{$config['cols']}\" class=\"entries\"></td></tr>";
        echo "<tr><td colspan=\"{$config['cols']}\" width=\"100%\"><br></td></tr>";
        $column_counter = 1;
        echo "<tr>\n";
        for ($i = $config['start']; $i < $config['max']; $i++) {
            $thumb_image = $config['thumbs'] . $imagelist[$i];
            $thumb_exists = file_exists($thumb_image);
            if (!$thumb_exists) {
                set_time_limit(30);
                if (!($thumb_exists = ResizeImageUsingGD("{$config['fulls']}{$imagelist[$i]}", $thumb_image, $config['size']))) {
                    $msg = "Không thể tạo Thumbnail cho <b>{$title}</b>.<br>- Kiểm tra lại quyền truy xuất cho thư mục này.";
                    $page = "?xl=Home";
                    page_load2($msg, $page);
                    return false;
                }
            }
            $imagelist[$i] = rawurlencode($imagelist[$i]);
            echo '<td align=center>';
            echo '<br><a href="' . $config['fulls'] . $imagelist[$i] . '" title="[ xGallery ]-> ' . $title . ' -> ' . $imagelist[$i] . '" rel="lightbox[roadtrip]">';
            echo '<img src="' . $config['thumbs'] . $imagelist[$i] . '" title="[ Xem ảnh ]" style="border: 2px dotted #aebbc7;">';
            echo "</a><br><a title=\"Xoá : {$imagelist[$i]}\" href='?xl=Gallery&ID={$id}&act=Del&Filename={$imagelist[$i]}'>[ Xóa ]</a>&nbsp;";
            echo '</td>' . "\n";
            if ($column_counter == $config['cols'] && $i + 1 != $config['max']) {
                echo "</tr>\n\n<tr>";
                echo "<tr><td colspan=\"{$config['cols']}\" width=\"100%\"><hr width=\"90%\"></td></tr>";
                echo "<td colspan=\"{$config['cols']}\" class=\"spacer\"></td></tr>\n\n<tr>\n";
                $column_counter = 0;
            }
            $column_counter++;
        }
        if ($config['start'] == $config['max']) {
            echo "<td colspan=\"{$config['cols']}\" class=\"entries\" align=center><br>Chưa có dữ liệu<br><br></td>\n";
        } elseif ($column_counter != $config['cols'] + 1) {
            echo "<td colspan=\"" . ($config['cols'] - $column_counter + 1) . "\">&nbsp;</td>\n";
        }
        echo "</tr>\n\n";
        echo "<tr><td colspan=\"{$config['cols']}\" width=\"100%\"><hr width=\"90%\"></td></tr>";
        echo "<tr>\n<td colspan=\"{$config['cols']}\" class=\"pagenumbers\">\n";
        echo "</td>\n</tr>\n\n";
        echo "</td></tr></table>\n";
        echo '<table border="0" cellpadding="0" cellspacing="0">
				<tr><td align=\\"left\\"><br><b>';
        GetPageNumbers(count($imagelist));
        echo '<br><br>	</td></tr>
			</table>';
    }
예제 #2
0
function PrintThumbs()
{
    global $config;
    // full directory error check
    if (!file_exists($config['fulls'])) {
        Oops("Fullsize image directory <b>{$config['fulls']}</b> does not exist.");
    }
    // thumb directory error check
    if (!file_exists($config['thumbs'])) {
        if (!@mkdir($config['thumbs'], 0755)) {
            Oops("Thumbnail image directory <b>{$config['thumbs']}</b> does not exist and can not be created. Check directory write permissions.");
        }
    }
    // get the list of all the fullsize images
    $imagelist = GetFileList($config['fulls']);
    // number of and which images on current page
    $config['start'] = $config['page'] * $config['cols'] * $config['rows'];
    $config['max'] = $config['page'] * $config['cols'] * $config['rows'] + $config['cols'] * $config['rows'];
    if ($config['max'] > count($imagelist)) {
        $config['max'] = count($imagelist);
    }
    if ($config['start'] > count($imagelist)) {
        $config['start'] = 0;
    }
    // start table
    echo '<table border="0" cellpadding="0" cellspacing="0" align="center" class="gallery">';
    echo "<tr>\n<td colspan=\"{$config['cols']}\" class=\"entries\">";
    // "showing results"
    if ($config['max'] == "0") {
        echo "Showing results <b>0 - 0</b> of <b>0</b></td></tr>\n";
    } else {
        echo "Showing results <b>" . ($config['start'] + 1) . " - {$config['max']}</b> of <b>" . count($imagelist) . "</b> entries</td>\n</tr>\n\n";
    }
    $column_counter = 1;
    // start row
    echo "<tr>\n";
    // for the images on the page
    for ($i = $config['start']; $i < $config['max']; $i++) {
        $thumb_image = $config['thumbs'] . $imagelist[$i];
        $thumb_exists = file_exists($thumb_image);
        // create thumb if not exist
        if (!$thumb_exists) {
            set_time_limit(30);
            if (!($thumb_exists = ResizeImageUsingGD("{$config['fulls']}{$imagelist[$i]}", $thumb_image, $config['size']))) {
                Oops("Creating Thumbnail image of <strong>{$config['fulls']}{$imagelist[$i]}</strong> failed. Possible directory write permission errors.");
            }
        }
        $imagelist[$i] = rawurlencode($imagelist[$i]);
        #########################################################
        # print out the image and link to the page
        #########################################################
        echo '<td>';
        echo '<a href="' . $config['fulls'] . $imagelist[$i] . '" title="' . $imagelist[$i] . ' rel="lightbox" " target="_blank">';
        echo '<img src="' . $config['thumbs'] . $imagelist[$i] . '" alt="' . $imagelist[$i] . '">';
        echo '</a>';
        echo '</td>' . "\n";
        #########################################################
        //if the max columns is reached, start new col
        if ($column_counter == $config['cols'] && $i + 1 != $config['max']) {
            echo "</tr>\n\n<tr><td colspan=\"{$config['cols']}\" class=\"spacer\"></td></tr>\n\n<tr>\n";
            $column_counter = 0;
        }
        $column_counter++;
    }
    //for(images on the page)
    // if there are no images found
    if ($config['start'] == $config['max']) {
        echo "<td colspan=\"{$config['cols']}\" class=\"entries\">No Entries found</td>\n";
    } elseif ($column_counter != $config['cols'] + 1) {
        echo "<td colspan=\"" . ($config['cols'] - $column_counter + 1) . "\">&nbsp;</td>\n";
    }
    // end row
    echo "</tr>\n\n";
    // print out page number list
    echo "<tr>\n<td colspan=\"{$config['cols']}\" class=\"pagenumbers\">\n";
    GetPageNumbers(count($imagelist));
    echo "</td>\n</tr>\n\n";
    // end table
    echo "</td></tr></table>\n";
}