Template-GLPI-Plugin/tools/modify_headers.pl
moyooo 7e733f2322 update headers
git-svn-id: https://forge.glpi-project.org/svn/example/trunk@182 349b9182-4a13-0410-896f-e5e9767dd1b3
2012-01-24 11:15:55 +00:00

103 lines
2.3 KiB
Perl
Executable File

#!/usr/bin/perl
#!/usr/bin/perl -w
# ----------------------------------------------------------------------
# GLPI - Gestionnaire Libre de Parc Informatique
# Copyright (C) 2003-2006 by the INDEPNET Development Team.
#
# http://indepnet.net/ http://glpi-project.org
# ----------------------------------------------------------------------
#
# LICENSE
#
# This file is part of GLPI.
#
# GLPI is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# GLPI is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with GLPI; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# ------------------------------------------------------------------------
do_dir("..");
sub do_dir{
local ($dir)=@_;
print "Entering $dir\n";
opendir(DIRHANDLE,$dir)||die "ERROR: can not read current directory\n";
foreach (readdir(DIRHANDLE)){
if ($_ ne '..' && $_ ne '.'){
if (-d "$dir/$_"){
if ($_ !~ m/.svn/i && $_ !~ m/CVS/i && $_ !~ m/lib/i){
do_dir("$dir/$_");
}
} else {
if(!(-l "$dir/$_")){
if ((index($_,".php",0)!=-1)||(index($_,".txt",0)!=-1)||(index($_,".css",0)!=-1)){
do_file("$dir/$_");
}
}
}
}
}
closedir DIRHANDLE;
}
sub do_file{
local ($file)=@_;
print $file."\n";
### DELETE HEADERS
open(INIT_FILE,$file);
@lines=<INIT_FILE>;
close(INIT_FILE);
open(TMP_FILE,">/tmp/tmp_glpi.txt");
$status='';
foreach (@lines){
if ($_ =~ m/\*\//){
$status="END";
}
if ($status =~ m/END/||$status !~ m/BEGIN/){
print TMP_FILE $_;
}
if ($status !~ m/END/){
if ($_ =~ m/\/\*/){
$status="BEGIN";
##### ADD NEW HEADERS
open(HEADER_FILE,"HEADER");
@headers=<HEADER_FILE>;
foreach (@headers){
print TMP_FILE $_;
}
close(HEADER_FILE) ;
}
}
}
close(TMP_FILE);
system("cp -f /tmp/tmp_glpi.txt $file");
}