[theme] - [apache] - [apache image downloader]
install downTHEMall! extension.
create new apache layer.
create layout-specific layer.
type: theme.
layout: apache-style directory indexing.
create new style.
template: (no base)
edit style.
name: apache image downloader.
layout: apache-style directory indexing
manage gals.
then use this php, running in a web server emulator on your computer (such as xitami), to append the correct filetype to each file. this script is intended to run within each folder.
create new apache layer.
create layout-specific layer.
type: theme.
layout: apache-style directory indexing.
layerinfo "type" = "theme";
layerinfo "name" = "apache image downloader";
layerinfo "source_viewable" = 1;
function GalleryPage::print_body (){
"<h1>Apache Image Downloader</h1>";
if (not $.pages.all_subitems_displayed) {
if ($.pages.url_prev != "") {
dir_item("left", $.pages.url_prev, "Previous Page", $.gallery.dateupdate, "", "Page " + ($.pages.current - 1) + " of $.pages.total");
}
if ($.pages.url_next != "") {
dir_item("right", $.pages.url_next, "Next Page", $.gallery.dateupdate, "", "Page " + ($.pages.current + 1) + " of $.pages.total");
}
}
"</pre>";
if ((size $.pictures) == 0) { return; }
"<hr noshade align=\"left\" width=\"80%\" />";
"<table cellpadding='2'>";
var bool tr = false;
var int td = 0;
var string desrow;
var int rows = 0;
foreach var Picture p ($.pictures) {
if (not $tr) {
"<tr align='center' valign='bottom'>\n";
$rows++;
$tr = true;
}
var Image i = $p.thumbnails{"norm"};
"<td>";
$i->print({
"tint" => $*tint,
"href" => $p.fullimage.url,
"alt" => $p.title,
});
"</td>\n";
$desrow = $desrow + "<td>$p.title</td>";
$td++;
if ($td == $*cols) {
"</tr>\n";
if ($*show_titles) {
"<tr valign='top'>$desrow</tr>\n";
}
$td = 0;
$tr = false;
$desrow = "";
}
}
if ($tr) {
"</tr>\n";
if ($*show_titles) {
"<tr valign='top' align='center'>$desrow</tr>\n";
}
}
"</table>";
}create new style.
template: (no base)
edit style.
name: apache image downloader.
layout: apache-style directory indexing
manage gals.
foreach $gal ($gals) {
choose a gal to download images from.
if (size($images) > 0) {
change style to "apache image downloader."
save gallery.
click on "view all pictures" link on right.
select & copy gal title.
right click -> downTHEMall!
select "links in the page" tab.
filter by "all files."
if (size($pages) > 1) {
deselect any links to other pages.
}
set dir to download to. (if you copied the gal title,
you can use that to create a dir with that name)
click "start downloads!" and watch them be grabbed. and stuff.
if (size($pages) > 1) {
go to next page and perform above process for remaining pages.
}
hit the back button until you reach the manage gal page.
change style back to what it was before you changed it to:
"apache image downloader."
save changes.
}
if (size($images) == 0) {
choose a subgal.
perform above process.
}
if (size($remaining_subgals) == 0) {
go to parent gal.
perform above process.
}
}then use this php, running in a web server emulator on your computer (such as xitami), to append the correct filetype to each file. this script is intended to run within each folder.
<?php
function image_type_to_extension($imagetype) {
if(empty($imagetype)) return false;
switch($imagetype) {
case IMAGETYPE_GIF : return 'gif';
case IMAGETYPE_JPEG : return 'jpg';
case IMAGETYPE_PNG : return 'png';
case IMAGETYPE_SWF : return 'swf';
case IMAGETYPE_PSD : return 'psd';
case IMAGETYPE_BMP : return 'bmp';
case IMAGETYPE_TIFF_II : return 'tiff';
case IMAGETYPE_TIFF_MM : return 'tiff';
case IMAGETYPE_JPC : return 'jpc';
case IMAGETYPE_JP2 : return 'jp2';
case IMAGETYPE_JPX : return 'jpf';
case IMAGETYPE_JB2 : return 'jb2';
case IMAGETYPE_SWC : return 'swc';
case IMAGETYPE_IFF : return 'aiff';
case IMAGETYPE_WBMP : return 'wbmp';
case IMAGETYPE_XBM : return 'xbm';
default : return false;
}
}
$dir = ".";
$files = array();
$dir = opendir($dir);
while($file = readdir($dir)) {
$files[] = $file;
}
foreach ($files as $file) {
if(is_file($file)) {
if(count(explode(".", $file)) == 1) {
list($width, $height, $type, $attr) = getimagesize($file);
$newfile = $file . "." . image_type_to_extension($type);
if(rename($file, $newfile)) {
echo $file . " -> " . $newfile . "<br />";
}
}
}
}
?> 