#!/usr/bin/perl ## _ ## /"\ ## G E C K O W Webinterface /o o\ ## _\/ \ / \/_ ## created by Geckow for the \\._/ /_.// ## DGS Relook 400S Satellite tuner `--, ,----' ## / / ## This software is provided "as ^ / \ ## is" without express or implied /| ( ) ## warranty. / | ,__\ /__, ## \ \ _//---, ,--\\_ ## Copyright (c) 2007 \ \ /\ / / /\ ## LaneThe2nd (Neumo-Team) \ \.___,/ / ## http://www.neumoteam.org \.______,/ ## ##============================================================================ # This php file provided update service for geckow webinterface #============================================================================ # # This file has to be copied to the directory where all the geckow versions are saved. # The update packages had to be named geckow-*version*.tar.gz (eg. geckow-1.03.tar.gz) # The changelog can be saved in .txt file geckow-*version*.txt (eg. geckow-1.03.txt) # So your directory could be: # geckow-1.03.tar.gz # geckow-1.03.txt # geckow-1.031.tar.gz # geckow-1.031.txt # geckow-1.04.tar.gz # geckow-1.04.tar.gz # getversion ## use strict; use CGI::Carp qw(fatalsToBrowser); # print header and set parameter print "Content-type: text/xml\r\n\r\n"; $ARGV[0] =~ /(.*)_(.*)/; my $param1 = $1; my $param2 = $2; ## check for update & return newest version and changelog if ($param1 eq 'checkupd') { # declare some variables my $cur_user_version = $param2; my $cur_server_version; my $succ; my $i; # search for files in directory and check if a higher version exists - start #=========================================================================== my $newest_version = "0"; my @array_of_changes; my $count_new_versions = 0; $0 =~ /(.*)\/getversion/; my $dir = $1; # get directory name local *DH; my $file; my @file_content; my $line; # open directory unless (opendir(DH, $dir)) { exit; } # get each file from directory while (defined ($file = readdir(DH))) { # only search for geckow-*version*.tar.gz next if(($file eq "." or $file eq "..") or index($file,"geckow-") < 0 or index($file,".tar.gz") < 0); # get version number $file =~ /geckow-(.*).tar.gz/; $cur_server_version = $1; # if there is a new version on server... if ($cur_server_version > $cur_user_version) { # try to open the changelog (geckow-*version*.txt) $succ = 1; # succeed? 1 = yes; 0 = no open DAT,"; # insert file content to 'array_of_changes' $i = 0; foreach $line (@file_content) { chomp($line); if ($line =~ /^\s*$/) {} # if line is empty do nothing ### TODO: only for last line ### else { # if line is not empty add line to 'array_of_changes' if ($i > 0) { @array_of_changes[$count_new_versions] .= "##_br_##"; } @array_of_changes[$count_new_versions] .= $line; $i++; } } } else { # geckow-*version*.txt not exists # add 'no changelog available...' push(@array_of_changes,"$cur_server_version (cur_server_version)##_em_##no changelog available...##_em_end_##"); } # close file close (DAT); # check for newest version if ($cur_server_version > $newest_version) { $newest_version = $cur_server_version; } $count_new_versions++; } } # close dir closedir(DH); # search for files in directory and check if a higher version exists - end #========================================================================= # create changes text # sort (from older versions to newer versions) @array_of_changes = reverse sort { $a cmp $b } @array_of_changes; # prepare each changelog for each newer version my $changes = ""; foreach my $change (@array_of_changes) { $change =~ /(.*) \(cur_server_version\)(.*)/; $changes .= "##_tr_####_td_top_##v$1:##_td_end_####_td_width_##$2##_br_####_td_end_####_tr_end_##"; } # retrun xml code print "\r\n"; print "$newest_version$changes\r\n"; } ## ???? else { ## return error print "Error: wrong parameter: '$ARGV[0]'"; }