Commit c5b077ca authored by Clément OUDOT's avatar Clément OUDOT

Initial import from SF and other sources



git-svn-id: svn://svn.forge.objectweb.org/svnroot/lemonldap/trunk@1 1dbb9719-a921-0410-b57f-c3a383c2c641
parents
#!/usr/bin/perl -w
#use strict;
###################################################################
#
sub getStyle {
my $style = $_[0];
if ($style =~ /map/i) {
$_[1] = 0;
return "conf_style";
}
if ($style =~ /lectro/i) {
$_[1] = 1;
return "simpage";
}
if ($style =~ /golf/i) {
$_[1] = 2;
return "golf_style";
}
}
###################################################################
#
sub main {
my $icheck = -1;
$ch = getStyle("electro", $icheck);
print( "Resultat:\n" );
print( "-- style = $ch\n" );
print( "-- check = $icheck\n" );
}
###################################################################
#
main;
#
###################################################################
#!/usr/bin/perl -w
#use strict;
###################################################################
#
sub getStyle {
if ($_[0] =~ /map/i) {
return ("conf_style", 0);
}
if ($_[0] =~ /lectro/i) {
return ("simpage", 1);
}
if ($_[0] =~ /golf/i) {
return ("golf_style", 2);
}
}
###################################################################
#
sub main {
($ch, $icheck) = getStyle("electro");
print( "Resultat:\n" );
print( "-- style = $ch\n" );
print( "-- check = $icheck\n" );
}
###################################################################
#
main;
#
###################################################################
#!/usr/bin/perl -w
#use strict;
use Template;
use CGI;
use Data::Dumper;
require './lemonldap-lib.pl';
my $tt = Template->new( {# ABSOLUTE => 1,
PREC_CHOMP =>1,
POST_CHOMP =>1, } );
##########################################
# chargement des infos de la page #
##########################################
my $message = 0;
my $dump1;
if (defined (CGI::param ('submitAddCluster')) ) { ## traitement d un nouveau node
my $new_clexml = CGI::param('idn');
if( !length($new_clexml)){
$message = $text{ 'lab_error_8' };
} else {
my $location = CGI::param('Locationn') ;
my $address = CGI::param('Addressn') ;
my $hash = {} ;
$hash->{'location'} = $location if $location;
$hash->{'address'} = $address if $address;
my $xmlemon = getXML( $config{'XML_file'} );
my $chapter = getChapterXML( $xmlemon, 'cluster' );
my $id = CGI::param('id');
my $clust = $chapter->{ $id } ;
if( defined( $clust->{ 'node' }->{ $new_clexml } ) ){
$message = $text{ 'lab_error_9' };
}else {
$clust->{ 'node' }->{ $new_clexml } = $hash;
###### ecriture par XMLOUT #############
&writeXML( $xmlemon, $config{'XML_file'});
}
}
}
## vars pour affichage de caract. du node selectionn / supprim
my $nodeID = 0;
my $nodeSimple = 0;
my $nodeLoc = 0;
if (defined (CGI::param ('RemoveNode')) ) { ## SUPPRESSION d un node
my $clenode = CGI::param('idn');
$nodeID = $clenode;
$nodeSimple = CGI::param('Addressn') ;
$nodeLoc = CGI::param('Locationn') ;
my $xmlemon = getXML( $config{'XML_file'} );
my $chapter = getChapterXML( $xmlemon, 'cluster' );
my $id = CGI::param('id');
my $clust = $chapter->{ $id } ;
my @knodes = keys( %{$clust->{'node'}} );
$dump1 = Dumper( @knodes );
delete( $clust->{ 'node' }->{ $clenode } );
if( @knodes == 1 ){
delete( $clust->{ 'node' } );
}
###### ecriture par XMLOUT #############
&writeXML( $xmlemon, $config{'XML_file'});
}
if (! defined (CGI::param ("submitCluster")) ) {
my $conf = &getXmlPage( "cluster" );
my $filethtml = $conf->{template};
my $title = $text{ &dePourCent( $conf->{title} ) };
my $_style = CGI::param('style')||$config{Style};
my $tabular = [];
$mode = 'Expert' ;
$tabular = &getTab( $conf->{tabs}->{expert} );
$tabular = &polyGlotTab( $tabular, \%text );
$tabular = &ajustLink ($tabular,$mode,$_style);
$flipflop = 'Normal';
$styl = $config{'Style'};
my $composs = &getAllComposants( $conf->{composants}->{expert} );
$composs = &polyGlotTab( $composs, \%text );
my $xmlemon = getXML( $config{'XML_file'} );
my $chapter = getChapterXML( $xmlemon, "cluster" );
my @f = keys %{$chapter};
my $first = $f[0];
&TransformVars( $composs, $chapter );
############### I collect node info #####
my @combonodes;
if($chapter->{$first}->{node} ) {
my $node = $chapter->{$first}->{ "node" };
my @nodes = keys( %{$node} );
@nodes = sort( @nodes );
for( @nodes ) {
my $item = { "labOption" => $_, "idValue" => $_ };
push( @combonodes, $_ );
}
# list of node
# just label and add bouton
} else {
# just label and add bouton
}
my $flagShowRemo = 0;
if( defined (CGI::param('listNodes') )){
$nodeID = CGI::param('listNodes');
$nodeSimple = $chapter->{ $first }->{ 'node' }->{$nodeID}->{ 'address' };
$nodeLoc = $chapter->{ $first }->{ 'node' }->{$nodeID}->{ 'location' };
$flagShowRemo= 1;
}
$vars= { style => $styl,
title => $title,
mode => $mode,
css => $_style,
label => $flipflop,
parent => $0,
tab_about => $tabular,
langa => \%text,
composall => $composs,
combonodes => \@combonodes,
message => $message,
nodeID => $nodeID,
nodeSimple => $nodeSimple,
nodeLoc => $nodeLoc,
flagShowRemo => $flagShowRemo
};
$vars->{style} = &getStyle($styl, $vars->{checked});
print "Content-type: text/html\n";
$tt->process($filethtml,$vars) || die $tt->error();
print( "<HR> $dump1 <HR>" );
} else { ## Traitement du "SUBMIT"
##########################################################
# print "Content-type: text/html\n";
# print( "\n" );
# my @lo =CGI::param();
# my $l =Dumper(@lo);
# print "$l";
# print( "<BR>" );
my $_style = CGI::param('style');
my $mode = CGI::param('mode');
my $old_clexml = CGI::param('_id');
my $new_clexml = CGI::param('id');
my $location = CGI::param('Location') ;
my $address = CGI::param('Address') ;
my $hash = {} ;
$hash->{'location'} = $location if $location;
$hash->{'address'} = $address if $address;
$hash->{'node'} = $node if $node;
my $xmlemon = getXML( $config{'XML_file'} );
my $chapter = getChapterXML( $xmlemon, "cluster" );
my $l= Dumper ($chapter);
delete $chapter->{$old_clexml};
if($new_clexml ) {
$xmlemon->{cluster}->{$new_clexml}= $hash;
}
else {
delete $xmlemon->{cluster} ;
}
###### ecriture par XMLOUT #############
&writeXML( $xmlemon, $config{'XML_file'});
#### affichage de la page ttconfig sur param
# $l= Dumper ($xmlemon);
# print "final $l";
&redirect( "index.cgi?mode=$mode&style=$_style" );
}
#
############ C FINI
This diff is collapsed.
XML_file=/opt/apache/conf/application_new.xml
httpd_conf=/opt/apache/conf/lemon.conf
XML_DTD=/opt/apache/conf/lemonldap.dtd
XML_file=/opt/apache/conf/application_new.xml
httpd_conf=/opt/apache/conf/lemon.conf
XML_DTD=/opt/apache/conf/lemonldap.dtd
XML_file=/opt/apache/conf/application_new.xml
httpd_conf=/opt/apache/conf/lemon.conf
XML_DTD=/opt/apache/conf/lemonldap.dtd
line1=Configurable options,11
XML_file=Full path to XML config file,0
httpd_conf=Full path to conf.d,0
Style= Style of GUI,1,maps-Old Maps,Electro-Electro,Golf-Golf
pid_file=Path to Apache PID file,0
start_cmd=Command to start apache,0
stop_cmd=Command to stop apache,0
restart_cmd=Command to restart apache,0
#!/usr/bin/perl
# configcache.cgi
# Display the icons for various types of lemonldapconfig options
use Data::Dumper;
require './lemonldap-lib.pl';
# Check if lemonlap is installed
&header($text{'index_title'}, "", undef, 1, 1, 0,
&help_search_link("lemonldap", "man", "doc", "google"));
print "<hr>\n";
$exp1 = &get_configcache();
my %exp =%$exp1;
# Display global category icons
print "<h3>$text{'index_config'}</h3>\n";
@attr = @{&get_config_attr()} ;
print "<table border=1 bgcolor='grey'>";
my $ligne=&formcolonne(\@attr,'name') ;
print "$ligne";
foreach (keys %exp) {
my @a;
push @a,"<a href=/lemonldap/modif_exp.cgi?exp=$_>$_</a>" ;
my $ctr=$_;
foreach (@attr) {
next if $_->{name}=~/^id/i;
push @a,$exp{$ctr}->{$_->{name}}||"&nbsp";
}
my $ligne=&formline(\@a,) ;
print "$ligne";
}
print "</table>";
print "<hr>";
my $table = tablemaj(@attr) ;
print "<h3>$text{'create_line'}</h3>\n";
print "<form method=get target= config_create.cgi>";
print $table ;
print "<p><input type=submit>";
print "</form>";
&footer("/lemonldap", $text{'index'});
#!/usr/bin/perl
# create_domain.cgi
# Display the icons for various types of lemonldapconfig options
use Data::Dumper;
require './lemonldap-lib.pl';
&ReadParse();
my $domain = $in{'domain'};
my $c = &get_config;
my $all_domain = $c->{domain};
# Display global category icons
my @tab= @{&get_domain_attr()} ;
my %tmp;
foreach (@tab) {
undef ($in{$_->{name}}) if $in{$_->{name}} eq '';
$tmp{$_->{name}}= $in{$_->{name}} if defined ($in{$_->{name}});
}
my $cle =$tmp{id};
delete $tmp{id};
$all_domain->{$cle} = \%tmp;
my $l =Dumper($all_domain);
$c->{domain} = $all_domain ;
### write xml ###
my $res =&writexml($config{XML_file},$c);
unless ($res) {
system ("mv $config{XML_file} $config{XML_file}.bak");
system ("mv $config{XML_file}.tmp $config{XML_file} ");
}
&redirect("domain.cgi");
#!/usr/bin/perl
# create_handler.cgi
use Data::Dumper;
require './lemonldap-lib.pl';
&ReadParse();
my $domain = $in{'domain'};
my $c = &get_config;
my $all_domain = $c->{domain};
# Display global category icons
my @tab= @{&get_handler_attr()} ;
my %tmp;
foreach (@tab) {
undef ($in{$_->{name}}) if $in{$_->{name}} eq '';
$tmp{$_->{name}}= $in{$_->{name}} if defined ($in{$_->{name}});
}
my $cle =$tmp{id};
delete $tmp{id};
$all_domain->{$domain}->{handler}->{$cle} = \%tmp;
my $l =Dumper($all_domain);
$c->{domain} = $all_domain ;
### write xml ###
my $res =&writexml($config{XML_file},$c);
unless ($res) {
system ("mv $config{XML_file} $config{XML_file}.bak");
system ("mv $config{XML_file}.tmp $config{XML_file} ");
}
### process at httpd.conf
if ($in{'virtualhost_line'}) {
my $ligne="<virtualhost $in{'virtualhost_line'} >\n";
$ligne.= "ServerName $in{'servername'}\n" if $in{'servername'};
$ligne.= "perltranshandler $in{'perltranshandler'}\n" if $in{'perltranshandler'};
$ligne.="PerlSetVar lemonldapHandlerID $cle\n" if $in{lemonldaphandlerid} eq 'yes' ;
$ligne.="</virtualhost>\n" ;
open ENTRE ,">>$config{httpd_conf}" ;
print ENTRE $ligne;
close ENTRE ;
}
&redirect("un_domain.cgi?domain=$domain");
<!--
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
/* ************************************ */
/* mise en forme de diffrentes balises */
/* ************************************ */
TITLE {
font: 36px Arial;
font-weight: bold;
color=green;
}
BODY {
background-color: #EDF0BA ;
background-image: url("/lemongui4webmin/images/map_conf.jpg") ;
background-attachment: fixed ;
font-size: 0.80em;
margin: 0.7cm 0.7cm 0.7cm 0.7cm;
}
H1 {
font-family: arial, verdana, sans-serif ;
background-image: url("/lemongui4webmin/images/back2_h1.jpg") ;
backgroud-repeat: repeat-x;
font: Arial;
font-size: 4em;
font-weight: bold;
color: #6f4a2e;
border: 2px double #007;
text-align: center;
}
H2 {
font-family: arial, verdana, sans-serif ;
font: Arial;
font-size: 3em;
font-weight: bold;
color: #236;
background-image: url("/lemongui4webmin/images/back2_h2.jpg") ;
backgroud-repeat: repeat-x;
text-align: center;
border: 2px double #336;
}
H3 {
font-family: arial, verdana, sans-serif ;
font: Arial;
font-size: 2.5em;
font-weight: bold;
color: #236;
}
H4 {
font-family: arial, verdana, sans-serif ;
font: Arial;
font-size: 2em;
font-weight: bold;
color: #236;
}
H5 {
font-family: arial, verdana, sans-serif ;
font: Arial;
font-size: 1em;
font-weight: bold;
color: #236;
}
I {
font-family: arial, verdana, sans-serif ;
font: Arial;
font-size: 0.9em;
font-weight: bold;
color: #236;
}
B {
font-family: arial, verdana, sans-serif ;
font: Arial;
font-size: 1.2em;
font-weight: bold;
color: #236;
}
.alive {
color: #0F0 ;
background-color: #000000 ;
font-style : bold;
letter-spacing : 6px;
word-spacing : 12px;
text-decoration: blink ;
text-align: center;
}
.dead {
color: #f00 ;
background-color: #000000 ;
font-style : bold;
letter-spacing : 6px;
word-spacing : 12px;
text-decoration: blink ;
text-align: center;
}
.ConfStyle {
background-image: url("/lemongui4webmin/images/boat2_conf.jpg") ;
background-attachment: fixed ;
background-color: #E4EBF5 ;
margin: 0cm 5.0cm 0.7cm 0.7cm;
border: 2px solid #070;
font-family: courier, prestige, monospace;
font-size: 0.9em;
line-height: 1.0em;
color: #450;
}
.ExpertStyle {
background-image: url("/lemongui4webmin/images/expert22.jpg") ;
background-attachment: fixed ;
background-color: #E4EBF5 ;
margin: 0cm 0.1cm 0.3cm 0.1cm;
border: 2px double #007;
font-family: courier, prestige, monospace;
font-size: 1.1em;
color: #040B15;
line-height: 1.0em;
}
.PetiFont {
font-family: courier, prestige, monospace;
font-size: 0.7em;
}
pre {
margin: 0.7cm 0.7cm 0.7cm 0.7cm;
}
LABEL {
background: transparent;
DISPLAY: inline ;
FLOAT: left ;
WIDTH: 150px ;
font-weight: bold ;
font-family: Arial, Helvetica, sans-serif ;
text-align: right ;
margin-left: 2px ;
margin-right: 35px ;
color: #236;
}
.LABG {
background: transparent;
DISPLAY: inline ;
FLOAT: left ;
font-weight: bold ;
font-family: Arial, Helvetica, sans-serif ;
text-align: right ;
color: #236;
}
.OPTION {
background: transparent;
/*background-color: #E7F0CE ; */
font-family: Arial, Helvetica, sans-serif ;
font-weight: bold;
color: #236;
}