Gheek.net

February 14, 2008

cpg2xml_pl.txt

Filed under: perl, xml — Tags: , , , — lancevermilion @ 2:51 pm

This may not be perfect as I didn’t work on it all that long. Hopefully it helps someone.

#!/usr/bin/perl -w
#Author: Lance Vermilion
#Purpose: Convert Coppermine directory/pictures into
#         a xml document just like picasa makes.
####################################################

#
# Define some variables
#
my $ablumname="Test";
my $localpath='/var/www/vhosts/gheek.net/httpdocs';
my $webpath='/cpg/albums/uploads/WinchesterMansion';
my @filesnormal;
my @files;


#
# We need to get a list of all the normal_[abc].jpg files
#
opendir(DIR, $localpath . $webpath);
@filesnormal = grep(/normal_.*\.jpg$/i,readdir(DIR));
closedir(DIR);

#
# Need to figure out how many pictures there are.
#
my $maxcount = scalar(@filesnormal);

foreach $file (@filesnormal) {
   $file =~ s/normal_//g;
   print "$file\n";
   push(@files, $file);
}

print "
  
- 
    $ablumname
    $maxcount
    
  - 
\n";

$maxcount--;
for ( $count=0; $count<=$maxcount; $count++ )
{
  print '    - ' . "\n";
  print "        true\n" if $count eq 1;
  print "        false\n"  if $count eq 1;
  print "        true\n"  if $count gt 1;
  print "        false\n" if $count gt 1;
  print "        true\n" if $maxcount eq $count;
  print "        false\n" if $maxcount gt $count;
  print "        true\n" if $maxcount gt $count;
  print "        false\n" if $maxcount eq $count;
  print "        \n" if $count eq 1;
  print "        \n" if $count gt 1;
  print "        normal_$files[0]\n";
  print "        $files[0]\n";
  print "        normal_$files[$count+1]\n" if $maxcount gt $count;
  print "        \n" if $maxcount eq $count;
  print "        thumb_$files[$count+1]\n" if $maxcount gt $count;;
  print "        \n" if $maxcount eq $count;
  print "        \n" if $count eq 1;
  print "        \n" if $count gt 1;
  print "        normal_$files[$maxcount-1]\n";
  print "        thumb_$files[$maxcount-1]\n";
  print "        400\n";
  print "        300\n";
  print "        thumb_$files[$count]\n";
  print "        100\n";
  print "        75\n";
  print "        normal_$files[$count]\n";
  print "        " . ($count + 1) . "\n";
  print "        $webpath/normal_$files[$count]\n";
  print "        itemNameOnly UNDEFINED (9)\n";
  print "        normal_$files[$count]\n";
  print "        itemSize UNDEFINED (9)\n";
  print '      ' . "\n";
}
  print '    ' . "\n";
  print '  
';
Advertisement

January 28, 2008

IP Plan xml template

Filed under: ipplan, switchmap, xml — Tags: , , , , — lancevermilion @ 12:47 am

This is a xml template that is used with IP Plan to allow you to have custom fields. The fields are filled by a script that impoprt information from a program called Switchmap.

  
- 
- 
  
  
- 
  
  
- 
  
  
- 
  
  
- 
  
  
  

Blog at WordPress.com.