Browse Source

Evoadmin-web is now a "public project".

wheezy
Benoît S. 5 years ago
commit
48eb1c16b1
55 changed files with 10530 additions and 0 deletions
  1. +3
    -0
      INSTALL
  2. +339
    -0
      LICENSE
  3. +72
    -0
      README-CLUSTER.md
  4. +3
    -0
      README.md
  5. +7
    -0
      TODO
  6. +34
    -0
      bin/add_server.php
  7. +28
    -0
      bin/init_cache.php
  8. +26
    -0
      bin/list_domains.php
  9. +18
    -0
      bin/prod
  10. +45
    -0
      conf/config.php
  11. +19
    -0
      conf/connect.php
  12. +998
    -0
      evolibs/Form.php
  13. +5
    -0
      htdocs/.htaccess
  14. +87
    -0
      htdocs/common.php
  15. +166
    -0
      htdocs/inc/css/main.css
  16. +27
    -0
      htdocs/inc/js/ftpadmin.js
  17. +4320
    -0
      htdocs/inc/js/lib/prototype-1.6.0.3.js
  18. +50
    -0
      htdocs/inc/js/webadmin.js
  19. +70
    -0
      htdocs/index.php
  20. BIN
     
  21. +380
    -0
      inc/accounts.php
  22. +57
    -0
      inc/auth.php
  23. +18
    -0
      inc/destroy.php
  24. +268
    -0
      inc/ftpadmin.php
  25. +19
    -0
      inc/home.php
  26. +172
    -0
      inc/webadmin-edit.php
  27. +83
    -0
      inc/webadmin.php
  28. +491
    -0
      lib/bdd.php
  29. +4
    -0
      scripts/awstats.XXX.conf
  30. +100
    -0
      scripts/check_cron_state.sh
  31. +9
    -0
      scripts/directorycheck.sh
  32. +174
    -0
      scripts/ftpadmin.sh
  33. +18
    -0
      scripts/get-domains.sh
  34. +100
    -0
      scripts/install-replication.sh
  35. +43
    -0
      scripts/mysql-add.sh
  36. +29
    -0
      scripts/pgsql-add.sh
  37. +23
    -0
      scripts/stats.sh
  38. +90
    -0
      scripts/sync-master-to-slave.sh
  39. +112
    -0
      scripts/sync-master-to-slave_mail.sh
  40. +72
    -0
      scripts/vhost
  41. +53
    -0
      scripts/vhost-default
  42. +658
    -0
      scripts/web-add-cluster.sh
  43. +643
    -0
      scripts/web-add.sh
  44. +86
    -0
      scripts/web-mail.tpl
  45. +47
    -0
      tpl/accounts.tpl.php
  46. +43
    -0
      tpl/auth.tpl.php
  47. +22
    -0
      tpl/footer.tpl.php
  48. +3
    -0
      tpl/ftpadmin-new-ok.tpl.php
  49. +74
    -0
      tpl/ftpadmin-new.tpl.php
  50. +77
    -0
      tpl/ftpadmin.tpl.php
  51. +43
    -0
      tpl/header.tpl.php
  52. +21
    -0
      tpl/home.tpl.php
  53. +31
    -0
      tpl/menu.tpl.php
  54. +64
    -0
      tpl/webadmin-edit.tpl.php
  55. +86
    -0
      tpl/webadmin.tpl.php

+ 3
- 0
INSTALL View File

@@ -0,0 +1,3 @@
* Ajouter l'utilisateur qui fait tourner l'application dans le groupe shadow
* Ajouter les autorisations sudo nécessaires
* Désactiver les magic quotes de PHP

+ 339
- 0
LICENSE View File

@@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991

Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

Preamble

The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.

When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.

We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.

Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.

Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.

The precise terms and conditions for copying, distribution and
modification follow.

GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".

Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.

1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.

You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.

2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:

a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.

b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.

c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.

In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.

3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:

a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,

b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,

c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.

If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.

4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.

5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.

6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.

7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.

It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.

This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.

8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.

9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.

Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.

10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.

NO WARRANTY

11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.

12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs

If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.

To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.

Copyright (C) 2013 Benoît.S

This program 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.

This program 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 this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

Also add information on how to contact you by electronic and paper mail.

If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:

Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.

You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:

Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.

{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice

This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

+ 72
- 0
README-CLUSTER.md View File

@@ -0,0 +1,72 @@
INSTALLATION & CONFIGURATION EVOADMIN EN MODE CLUSTER
=====================================================


1. Infra type à mettre en place
-------------------------------

.---.
| | adm
'-.-'
.------------+------------.
v v v
.---. .---. .---.
| | www00 | | www01 | | wwwnn
'---' '---' '---'

* adm : machine hébergeant evoadmin-cluster. Doit pouvoir se connecter en
root sur tous les frontaux ;

* wwwXX : frontaux configurés en tant que pack-web/pack-mail.


2. Configuration sur la machine d'admin
---------------------------------------

* Récupérer le code ;
* Créer le virtual host pointant dans htdocs/ ;
* Initialiser la base de données SQLite :
* copier le contenu de scripts/ du dépôt dans /usr/share/scripts/evoadmin/.

3. Configuration des frontaux
-----------------------------

* Configurer un pack-web et pack-mail+evoadmin-mail classique ;
* ouvrir l'accès SSH entre tous les frontaux (nécessaire pour les
réplications) ;
* Ouvrir l'accès SSH en root depuis la machine d'admin vers chaque frontal ;
* Copier les scripts scripts/sync-master-to-slave* du dépôt dans
/opt/evocluster/, puis `chmod -R 755 /opt/evocluster/`.

Cas de la réplication MySQL :
* Configurer la réplication MySQL de manière standard (comme décrit ici [1]) ;
* Rajouter sur la machine slave dans le my.cnf la directive replicate-do-db,
qui contiendra la liste des bases des comptes à répliquer.

[1] http://trac.evolix.net/infogerance/wiki/HowtoMySQL#R%C3%A9plicationMySQL

4. Configuration d'Evoadmin
---------------------------

Afin d'activer Evoadmin en mode Cluster, remplir les variables suivantes dans
/home/evoadmin/www/conf/config.local.php :

$localconf['cluster'] = TRUE;
$localconf['cache'] = '/home/evoadmin/www/cache.sqlite'; // cache sqlite
$localconf['servers'] = array('www00', 'www01', ..., 'wwwnn');

Créer le cache après avoir renseigner le fichier de conf :
# cd /home/evoadmin/www/bin && php init_cache.php
www00 added in cache
[...]
Cache initialisé
# chown www-evoadmin:evoadmin /home/evoadmin/www/cache.sqlite
# chmod ug+rx /home/evoadmin/www/cache.sqlite

S'assurer que /home/evoadmin/www appartient bien à www-evoadmin:evoadmin.

Il est possible de dumper le cache grâce à au script list_domain.php et de
rajouter des serveurs dans le cache grâce au script add_server.php :
# php add_server.php www42



+ 3
- 0
README.md View File

@@ -0,0 +1,3 @@
evoadmin-web
============
Panel d'administration de serveur web.

+ 7
- 0
TODO View File

@@ -0,0 +1,7 @@
* Verification des paramètres passés dans le script ftpadmin.sh
* Vérifier lors de la suppression que c'est bien la personne a qui appartient le compte qui lance la commande
* Tableau "sortable" (TableKit ?)
* Mettre en place EvoLog et logger la sortie des scripts
* Validation plus (très) stricte sur les entrées de formulaire
* Listage des comptes utilisateurs
* Total espace disque FTP

+ 34
- 0
bin/add_server.php View File

@@ -0,0 +1,34 @@
<?php

require '../lib/bdd.php';
require_once '../conf/config.php';
require_once '../conf/config.local.php';


if ($argc==1) {
echo "Specify a server name";
exit(1);
}

$conf = array_merge($oriconf, $localconf);

$bdd = new bdd();

$file=$conf['cache'];

if (!file_exists($file)) {
echo "$file doesn't exist\n";
exit(1);
}

$bdd->open($file);

$server = array("name" => $argv[1]);

$bdd->add_server(array("name" => "$server"));
exec('ssh -o "UserKnownHostsFile '.$conf['known_host'].'" '.$argv[1].' /bin/true');

echo "$server added in cache\n";
exit(0);
?>


+ 28
- 0
bin/init_cache.php View File

@@ -0,0 +1,28 @@
<?php

require '../lib/bdd.php';
require_once '../conf/config.php';
require_once '../conf/config.local.php';

$conf = array_merge($oriconf, $localconf);


$bdd = new bdd();

$file=$conf['cache'];

if (!file_exists($file))
$bdd->create($file);
else {
echo "$file is already created";
exit(1);
}

foreach ($conf['servers'] as $server) {
echo "$server added in cache\n";
$bdd->add_server(array("name" => "$server"));
}

echo "Cache initialisé\n";
exit(0);
?>

+ 26
- 0
bin/list_domains.php View File

@@ -0,0 +1,26 @@
<?php

require '../lib/bdd.php';
require_once '../conf/config.php';
require_once '../conf/config.local.php';

$conf = array_merge($oriconf, $localconf);


$bdd = new bdd();

$file=$conf['cache'];

if (!file_exists($file)) {
echo "$file is not created\n";
exit(1);
}

$bdd->open($file);

$domains = $bdd->list_domains();
print_r($domains);

exit(0);

?>

+ 18
- 0
bin/prod View File

@@ -0,0 +1,18 @@
#!/bin/sh

# Pré-requis pour utiliser ce script :
# * Evoadmin-web est installé dans /home/evoadmin/www
# * Etre loggué avec le compte evoadmin (sudo su evoadmin)

# Note : Ce script utilise une connexion SVN anonyme pour récupérer le code source
# Note : Ce script ne met *pas* en prod les scripts dans /usr/share/scripts

SVNREPO="svn://svn.evolix.org/svn/packweb/trunk/evoadmin"

tmpdir=`mktemp -d $HOME/tmp.XXXXXX`
svn export --force $SVNREPO $tmpdir
svn info $SVNREPO >$tmpdir/svn.txt
rsync -rlvt --delete --exclude config.local.php $tmpdir/ /home/evoadmin/www
rm -rf $tmpdir
svn info $SVNREPO | mail -s "Mise en prod Evoadmin ($HOSTNAME)" root


+ 45
- 0
conf/config.php View File

@@ -0,0 +1,45 @@
<?php

/**
* Configuration page
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* $Id: config.php 273 2009-05-12 13:54:50Z tmartin $
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0
*/


// Email pour les notifications
$oriconf['admin']['mail'] = 'admin@example.com';
$oriconf['techmail'] = 'jdoe@example.com';
$oriconf['debug'] = FALSE;
$oriconf['superadmin'] = array('superadmin');
$oriconf['script_path'] = '/usr/share/scripts/evoadmin';
$oriconf['cluster'] = FALSE;
$oriconf['servers'] = array('servers');
$oriconf['cache'] = '/home/evoadmin/www/cache.sqlite';
$localconf['known_host'] = '/home/evoadmin/www/known_host';
$oriconf['ftpadmin'] = TRUE;

/* cluster mode
* $oriconf['noreplication'] = array('www00');
* $oriconf['postponedreplication'] = array('www00', 'www01');
* $oriconf['immediatereplication'] = array('www00', 'www01');
* $oriconf['postponedreplication_mode'] = array('3 fois/jour', '1 fois/jour', '1 fois/heure');
*/

/* Il est possible de définir pour chaque mode de
* postponedreplication_mode une liste de serveurs,
* qui seront utilisés à la place des serveurs du
* tableau postponedreplication.
*
* $localconf['1 fois/jour'] = array('www00', 'www01');
* $localconf['1 fois/heure'] = array('www01', 'www00');
*/


+ 19
- 0
conf/connect.php View File

@@ -0,0 +1,19 @@
<?php

/**
* Secrete parameters
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0
*/

define("SUDOBIN","/usr/bin/sudo");
define("SUDOSCRIPT","/usr/share/scripts/evoadmin.sh");
define("SUDOPASS","xxxxxx");


+ 998
- 0
evolibs/Form.php View File

@@ -0,0 +1,998 @@
<?php

/**
* Bibliotheques FORM (PHP5)
*
* Copyright (c) 2004-2009 Evolix - Tous droits reserves
*
* $Id: Form.php 168 2009-08-14 14:41:42Z tmartin $
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
*
* Fonctions utiles pour la creation de formulaires
*
* v 1.0
*/

class FormPageController {
private $pages = array();
private $current_page = NULL;

/* Affiche la page de formulaire in-line */
public function __toString() {
$out = '';
$out = $this->pages[$this->current_page];
$out .= "\n\n";
return $out;
}

/* Vérifie les champs et redirige vers la dernière page valide.
Retourne TRUE si le formulaire est entièrement valide.
Retourne FALSE en cas d'erreur sur la page courante. */
public function verify($set_error=TRUE) {
$valid = TRUE;
foreach($this->pages as $pagenum => $page) {
if(!$page->verify($set_error)) {
$valid = FALSE;
}
}
if($valid) {
return TRUE;
} else {
return FALSE;
}
}

public function setCurrentPage($current_page) {
$this->current_page = $current_page;
$this->pages[$current_page]->isCurrentPage(TRUE);
}

public function getCurrentPage() {
return $this->pages[$this->current_page];
}

public function addPage($pagenum, $obj) {
$this->pages[$pagenum] = $obj;
}

/* Doit être appelé après les addField() */
public function init() {
foreach($this->pages as $pagenum=>$page) {
$page->initFields();
}
}

/* Retourne le numéro de page suivant, ou FALSE si on est à la fin */
public function getNextPage() {
$numpage = count($this->pages);
if($this->current_page == $numpage) {
return FALSE;
} else {
return $this->current_page+1;
}
}

/* Retourne des infos sur les pages du formulaire, pour construire un fil
d'ariane par exemple */
public function getPagesList() {
return $this->pages;
}

public function getPage($num = null) {
if($num) {
return $this->pages[$num];
} else {
return $this->pages[$this->current_page];
}
}

/* Renvoie une collection d'objets "Field" */
public function getFieldsList() {
$fields = array();
foreach($this->pages as $page) {
foreach($page->getFieldsList() as $field) {
$fields[$field[0]] = $field[1];
}
}
return $fields;
}

/* Renvoie une structure de données injectable dans ldap_add() ou
ldap_modify() */
public function toLDAP() {

$info = array();

foreach($this->getFieldsList() as $name=>$obj) {
if(is_array($obj->getValue()) && count($obj->getValue()) == 1) {
$tmp = $obj->getValue();
$value = $tmp[0];
} else {
$value = $obj->getValue();
}

if(!empty($value)) {
$info[strtolower($name)] = $value;
}
}

return $info;
}

/* Permet de définir à posteriori une liste de champs obligatoires */
public function setMandatoryFields($list) {
foreach($this->getFieldsList() as $fname=>$fobj) {
if(in_array($fname, $list)) {
$fobj->setMandatory(TRUE);
}
}
}

/* Permet d'utiliser un stockage différent de celui par défaut
* ($_SESSION) pour tous les FormFields déjà ajouté au controlleur. Prend
* en paramètre la référence d'un tableau
*/
public function setSessionStorage(& $storage) {
foreach($this->getFieldsList() as $fname=>$fobj) {
$fobj->setSessionStorage($storage);
}
}
}

class FormPage {
private $fields = array();
private $label = NULL;
private $is_current_page = FALSE;
private $use_session = NULL;

public function __construct($label, $use_session=TRUE) {
$this->label = $label;
$this->use_session = $use_session;
}

public function __toString() {
$out = '';
foreach($this->fields as $field) {
$obj = $field[1];
$out .= "$obj\n\n";
}
return $out;
}

public function getLabel() {
return $this->label;
}

public function verify($set_error) {
$num_error = 0;

foreach($this->fields as $field) {
$obj = $field[1];
if($obj->verify($set_error)) {
$this->use_session && $obj->storeSession();
} else {
$num_error++;
$this->use_session && $obj->deleteSession();
}
}

if($num_error > 0) {
return FALSE;
} else {
return TRUE;
}
}

public function addField($name, $obj) {
$obj->setName($name);
array_push($this->fields, array($name, $obj));
}

public function addFieldsArray($array) {
foreach($array as $name=>$obj) {
$this->addField($name, $obj);
}
}

/* Petit hack : la page doit savoir si c'est elle qui est affiché, pour
gérer le cas des checkbox */
public function initFields($is_current_page=FALSE) {
foreach($this->fields as $field) {
$name = $field[0];
$obj = $field[1];

if((is_a($obj, 'CheckBoxInputFormField')
|| is_a($obj, 'MultipleCheckBoxInputFormField'))
&& $this->is_current_page
&& !empty($_POST) && !array_key_exists($name, $_POST)) {
$obj->setValue(0);
} else if(is_a($obj, 'UploadFileInputFormField')
&& $this->is_current_page
&& array_key_exists($name, $_FILES) && $_FILES[$name]['error']==0) {
$obj->saveTmpFile($_FILES[$name]);
} else if(array_key_exists($name, $_POST)) {
$obj->setValue($_POST[$name]);
} else if($this->use_session && $obj->sessionKeyExist($name)) {
$obj->setSessionValue($name);
}
}
}

public function isCurrentPage($is=NULL) {
if(is_bool($is)) {
$this->is_current_page = $is;
}
return $this->is_current_page;
}


/* Renvoie la liste des objets Fields de la page */
public function getFieldsList() {
return $this->fields;
}

/* Renvoie la liste des objets Fields de la page */
public function getFieldsName() {
$ret = array();
foreach($this->fields as $field) {
$ret[] = $field[0];
}
return $ret;
}

public function getField($name) {
foreach($this->fields as $f) {
if($f[0] == $name) {
return $f[1];
}
}
}
}

class FormField {
protected $value = null;
protected $error = null;
protected $label = null;
protected $name = null;
protected $css_class = null;
protected $read_only = null;
protected $disabled = null;
private $storage = NULL;

protected function __construct($label) {
$this->storage = & $_SESSION;
$this->label = $label;
}

public function storeSession() {
if(strlen($this->value) > 0) {
$this->storage[$this->name] = $this->value;
}
}

public function deleteSession() {
unset($this->storage[$this->name]);
}

public function setSessionValue($name) {
$this->setValue($this->storage[$name]);
}

public function sessionKeyExist($name) {
#echo "$name ".$this->storage[$name]." ";
return array_key_exists($name, $this->storage);
}

public function setSessionStorage(& $storage) {
$this->storage = & $storage;
}

protected function verify($set_error) {
if(empty($this->error)) {
return TRUE;
}
}

public function getError() {
if(isset($this->value) && !$this->verify(FALSE)) {
return $this->error;
}
}

public function getErrorHTML() {
return '<span class="form-error">'.$this->error.'</span>';
}

public function setError($error) {
$this->error = $error;
}

public function getLabel() {
return $this->label;
}

public function setName($name) {
$this->name = $name;
}

public function getName() {
return $this->name;
}

public function setValue($value) {
$this->value = $value;
}

public function getValue() {
return $this->value;
}

public function getReadableValue() {
return $this->getValue();
}

public function getLabelHTML() {
$label = '';
$label .= '<label for="'.$this->name.'">';
$label .= $this->label.'&nbsp;';
if ($this->mandatory) {
if($this->verify(false)) {
$label .= '<span class="form-mandatory-ok">[*]</span>&nbsp;';
} else {
$label .= '<span class="form-mandatory">[*]</span>&nbsp;';
}
}
$label .= ': ';
$label .= "</label>\n";
return $label;
}

public function setCSSClass($name) {
$this->css_class = $name;
}

public function setReadOnly() {
$this->read_only = true;
}

public function setDisabled($state = TRUE) {
$this->disabled = $state;
}

public function setMandatory($bool) {
$this->mandatory = $bool;
}
}

/* $textsize = array( size, maxlength ) */
class TextInputFormField extends FormField {
protected $mandatory = NULL;
protected $textsize = NULL;

public function __construct($label, $mandatory=TRUE, $textsize=array(20, 40)) {
parent::__construct($label);
$this->mandatory = $mandatory;
$this->textsize = $textsize;
}

public function verify($set_error) {
if($this->mandatory && (!strlen($this->value))) {
if($set_error) $this->error = 'Champ obligatoire';
return FALSE;
}
return TRUE;
}

public function getInputHTML() {
$input = '';
$input .= '<input type="text" id="'.$this->name.'"';
$input .= ' name="'.$this->name.'" value="'.htmlspecialchars($this->value,ENT_QUOTES).'"';
#$input .= sprintf(' name="%s" value="%s"', $this->name, htmlspecialchars($this->value, ENT_QUOTES));
$input .= ' maxlength="'.$this->textsize[1].'" size="'.$this->textsize[0].'" ';
if($this->read_only) { $input .= 'readonly="readonly="'; }
if($this->disabled) { $input .= 'disabled="disabled="'; }
$input .= '/>';
return $input;
}

public function __toString() {
$out = '';
$out .= "<p>\n";
$out .= $this->getLabelHTML();
$out .= $this->getInputHTML();
$out .= $this->getErrorHTML();
$out .= "</p>\n\n";
return $out;
}
}

class DateInputFormField extends TextInputFormField {
public function __construct($label, $mandatory=TRUE) {
parent::__construct($label, $mandatory, array(7, 10));
}

public function verify($set_error) {
if(!parent::verify($set_error)) return FALSE;
if(!empty($this->value) &&
!preg_match('#^\d{2}/\d{2}/\d{4}$#', $this->value)) {
if($set_error) $this->error = 'Format de date non valide';
return FALSE;
}
$arr_date = split('/', $this->value);
if(!empty($this->value) &&
!checkdate($arr_date[1],$arr_date[0],$arr_date[2])) {
if($set_error) $this->error = "La date saisie n'existe pas";
return FALSE;
}
return TRUE;
}
}

class YearDateInputFormField extends TextInputFormField {
public function __construct($label, $mandatory=TRUE) {
parent::__construct($label, $mandatory, array(4, 4));
}

public function verify($set_error) {
if(!parent::verify($set_error)) return FALSE;
if(!empty($this->value) && (!ctype_digit($this->value) || $this->value < 1900)) {
if($set_error) $this->error = 'Vous devez saisir une année valide';
return FALSE;
}
return TRUE;
}
}

class TelephoneInputFormField extends TextInputFormField {
public function setValue($value) {
$value = preg_replace('/[^\d -\.\(\)\+]/', '-', $value);
parent::setValue($value);
}
}

class IntegerInputFormField extends TextInputFormField {
public function verify($set_error) {
if(!parent::verify($set_error)) return FALSE;
if(!empty($this->value) && !is_numeric($this->value)) {
if($set_error) $this->error = 'Vous devez saisir un chiffre';
return FALSE;
}
return TRUE;
}
}

class FloatInputFormField extends TextInputFormField {
public function verify($set_error) {
if(!parent::verify($set_error)) return FALSE;
if(!empty($this->value) && !is_numeric($this->value)) {
if($set_error) $this->error = 'Vous devez saisir un chiffre';
return FALSE;
}
return TRUE;
}
}

class EmailInputFormField extends TextInputFormField {

public function verify($set_error) {
if(!parent::verify($set_error)) {
return FALSE;
}

if(!empty($this->value) && !eregi('^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$',$this->value)){
if($set_error) $this->error = 'Adresse email invalide';
return FALSE;
}

return TRUE;
}
}

class TextareaFormField extends FormField {
protected $mandatory = NULL;
protected $cols = NULL;
protected $rows = NULL;

public function __construct($label, $mandatory=TRUE, $cols=45, $rows=5) {
parent::__construct($label);
$this->mandatory = $mandatory;
$this->rows = $rows;
$this->cols = $cols;
}

public function verify($set_error) {
if($this->mandatory && empty($this->value)) {
if($set_error) $this->error = 'Champ obligatoire';
return FALSE;
}

return TRUE;
}

public function getInputHTML() {
$input = '';
$input .= '<textarea cols="'.$this->cols.'" rows="'.$this->rows.'" id="'.$this->name.'"';
$input .= ' name="'.$this->name.'">'.htmlspecialchars($this->value,ENT_QUOTES).'</textarea>';
return $input;
}

public function __toString() {
$out = '';
$out .= "<p class='form-textarea'>\n";
$out .= $this->getLabelHTML();
$out .= $this->getInputHTML();
$out .= $this->getErrorHTML();
$out .= "</p>\n\n";
return $out;
}
}


class PasswordInputFormField extends FormField {
protected $mandatory = NULL;

public function __construct($label, $mandatory=TRUE) {
parent::__construct($label);
$this->mandatory = $mandatory;
}

public function verify($set_error) {
if(empty($this->value)) {
if($this->mandatory) {
if($set_error) $this->error = 'Champ obligatoire';
return FALSE;
} else {
return TRUE;
}
}

if(strlen($this->value) < 8) {
if($set_error) $this->error = '8 caracteres minimum';
return FALSE;
}

#if(preg_match('#.*[A-Z]+.*$#',$this->value)==0){
# if($set_error) $this->error = 'Votre mot de passe doit contenir au moins une majuscule';
# return FALSE;
# }

if(preg_match('#.*[0-9]+.*#',$this->value)==0){
if($set_error) $this->error = 'Votre mot de passe doit contenir au moins un chiffre';
return FALSE;
}

return TRUE;
}


public function getInputHTML() {
$input = sprintf('<input type="password" id="%s" name="%s" value="%s"',
$this->name, $this->name,
htmlspecialchars($this->value, ENT_QUOTES));
if($this->read_only) $input .= ' readonly="readonly"';
if($this->disabled) { $input .= 'disabled="disabled="'; }
$input .= '/>';
return $input;
}

public function __toString() {
$out = '';
$out .= "<p>\n";
$out .= $this->getLabelHTML();
$out .= $this->getInputHTML();
$out .= $this->getErrorHTML();
$out .= "</p>\n\n";
return $out;
}
}


class CheckBoxInputFormField extends FormField {
protected $mandatory = NULL;

public function __construct($label, $mandatory=TRUE) {
parent::__construct($label);
$this->mandatory = $mandatory;
}

public function verify($set_error) {
if(!parent::verify($set_error)) return FALSE;
if($this->mandatory && empty($this->value)) {
if($set_error) $this->error = 'Champ obligatoire';
return FALSE;
}

return TRUE;
}


public function getInputHTML() {
$input = sprintf('<input type="checkbox" id="%s" name="%s"',
$this->name, $this->name);
if($this->value) $input .= ' checked="checked"';
if($this->disabled) $input .= ' disabled="disabled"';
$input .= ' value="1" />';
return $input;
}

public function __toString() {
$out = '';
$out .= "<p>\n";
$out .= $this->getLabelHTML();
$out .= $this->getInputHTML();
$out .= $this->getErrorHTML();
$out .= "</p>\n\n";
return $out;
}
}

class MultipleCheckBoxInputFormField extends FormField {
protected $mandatory = NULL;
protected $list = array();

public function __construct($label, $mandatory=TRUE, $list) {
parent::__construct($label);
$this->mandatory = $mandatory;
$this->list = $list;
}

public function verify($set_error) {
if($this->mandatory && empty($this->value)) {
if($set_error) $this->error = 'Vous devez faire au moins un choix';
return FALSE;
}

return TRUE;
}

public function getInputHTML() {
$input = '';
$n = 0;
foreach ($this->list as $value => $label) {
$input .= '<input type="checkbox" name="'.$this->name.'[]" value="'.htmlspecialchars($value,ENT_QUOTES).'"';
if (is_array($this->value) && in_array($value, $this->value)) {
$input.=' checked="checked"';
}
if($this->read_only) { $input .= 'readonly="readonly="'; }
$input .= "/>$label";
$n++;
if($n < count($this->list)) $input .= "<br/>\n";
}
return $input;
}

public function getErrorHTML() {
if($this->error) {
return "<br/><span class='form-error form-incolumn-error'>{$this->error}</span>";
} else {
return "";
}
}

public function __toString() {
$out = '';
$out .= "<p>\n";
$out .= $this->getLabelHTML();
$out .= $this->getInputHTML();
$out .= $this->getErrorHTML();
$out .= "</p>\n\n";
return $out;
}

public function getValue() {
$out = array();
foreach($this->value as $index) {
#$out[] = $this->list[$index];
$out[] = $index;
}
return $out;
}

public function getReadableValue() {
$n = 1;
$out = '';
foreach($this->value as $index) {
$out .= $this->list[$index];
if($n < count($this->value)) $out .= ', ';
$n++;
}
return $out;
}

public function setValue($value) {
if(!is_array($value)) {
$this->value = array($value);
} else {
parent::setValue($value);
}
}
}


class SelectFormField extends FormField {
protected $mandatory = NULL;
protected $list = array();

public function __construct($label, $mandatory=TRUE, $list) {
parent::__construct($label);
$this->mandatory = $mandatory;
$this->list = $list;
}

public function verify($set_error) {
if($this->mandatory && empty($this->value)) {
if($set_error) $this->error = 'Champ obligatoire';
return FALSE;
}

return TRUE;
}


public function getInputHTML() {
$input = '';
$input .= '<select id="'.$this->name.'" name="'.$this->name.'">'."\n";
$input .= ' <option value="">-- Choisissez --</option>'."\n";
foreach ($this->list as $value => $label) {
$input .= ' <option value="'.htmlspecialchars($value,ENT_QUOTES).'"';
if ($this->value == $value) $input.=' selected="selected"';
$input .= '>'.$label.'</option>'."\n";
}
$input .= "</select>\n";
return $input;
}

public function __toString() {
$out = '';
$out .= "<p>\n";
$out .= $this->getLabelHTML();
$out .= $this->getInputHTML();
$out .= $this->getErrorHTML();
$out .= "</p>\n\n";
return $out;
}

public function getValue() {
return $this->value;
}

public function getReadableValue() {
if(array_key_exists($this->value, $this->list)) {
return $this->list[$this->value];
} else {
return null;
}
}
}

class RadioFormField extends FormField {
protected $mandatory = NULL;
protected $list = array();

public function __construct($label, $mandatory=TRUE, $list, $default = null) {
parent::__construct($label);
$this->mandatory = $mandatory;
$this->list = $list;
if($default) {
$this->value = $default;
}
}

public function verify($set_error) {
if($this->mandatory && empty($this->value)) {
if($set_error) $this->error = 'Champ obligatoire';
return FALSE;
}

return TRUE;
}

public function getInputHTML() {
$input = '';
$input .= '<span class="form-radio">';
foreach ($this->list as $value => $label) {
$input .= '<input type="radio" name="'.$this->name.'" value="'.htmlspecialchars($value,ENT_QUOTES).'"';
if ($this->value == $value) $input.=' checked="checked"';
$input .= "/>$label<br/>";
}
$input .= '</span>';
return $input;
}

public function getErrorHTML() {
return "<span class='form-error form-incolumn-error'>{$this->error}</span>";
}

public function __toString() {
$out = '';
$out .= "<p>\n";
$out .= $this->getLabelHTML();
$out .= $this->getInputHTML();
$out .= $this->getErrorHTML();
$out .= "</p>\n\n";
return $out;
}

public function getValue() {
return $this->value;
}

public function getReadableValue() {
if(array_key_exists($this->value, $this->list)) {
return $this->list[$this->value];
} else {
return null;
}
}
}

class ButtonInputFormField extends FormField {
protected $mandatory = NULL;
protected $event = NULL;
protected $action = NULL;

public function __construct($label,$mandatory=FALSE, $event, $action) {
parent::__construct($label);
$this->mandatory = $mandatory;
$this->event = $event;
$this->action = $action;
}

public function verify($set_error) {
return TRUE;
}


public function getInputHTML() {
$input = '';
$input .= '<input type="button" name="'.$this->name.'" ';
if (!empty($this->event) && !empty($this->action)) {
$input .= $this->event.'='.$this->action.' ';
}
$input .= 'value="'.htmlspecialchars($this->label,ENT_QUOTES).'" />';
return $input;
}

public function __toString() {
$out = '';
$out .= "<p>\n";
$out .= $this->getInputHTML();
$out .= $this->getErrorHTML();
$out .= "</p>\n\n";
return $out;
}
}


class SubmitInputFormField extends FormField {
protected $mandatory = NULL;
protected $event = NULL;
protected $action = NULL;

public function __construct($label,$mandatory=FALSE) {
parent::__construct($label);
$this->mandatory = $mandatory;
}

public function verify($set_error) {
return TRUE;
}


public function getInputHTML() {
$input = '';
$input .= '<input type="submit" name="'.$this->name.'" ';
$input .= 'class="'.$this->css_class.'" value="'.htmlspecialchars($this->label,ENT_QUOTES).'" />';
return $input;
}

public function __toString() {
$out = '';
$out .= "<p>\n";
$out .= $this->getInputHTML();
$out .= $this->getErrorHTML();
$out .= "</p>\n\n";
return $out;
}
}

class UploadFileInputFormField extends FormField {
protected $mandatory = NULL;
protected $delete_url = NULL;

public function __construct($label,$mandatory=FALSE) {
parent::__construct($label);
$this->mandatory = $mandatory;
}

public function verify($set_error) {
return TRUE;
}

public function setDeleteUrl($url) {
$this->delete_url = $url;
}


public function deleteUploadedFile() {
if(!is_array($this->value)) {
return "Value is not an array";
}

if(file_exists('/tmp/'.$this->value['tempname'])) {
unlink('/tmp/'.$this->value['tempname']);
}

$this->value = NULL;

return true;
}

public function saveTmpFile($upload_array) {
$this->value['filename'] = $upload_array['name'];
$this->value['file_ext'] = end(explode(".", $this->value['filename']));
$this->value['tempname'] = 'tmp_'.time().'.'.$this->value['file_ext'];
$up_filename = $upload_array['tmp_name'];

if(!move_uploaded_file($up_filename, '/tmp/'.$this->value['tempname'])) {
$this->error = $this->value['error'];
}
}

public function moveTmpFile($filename, $dest_path) {
$this->value['filename'] = $filename.'.'.$this->value['file_ext'];

if(!file_exists('/tmp/'.$this->value['tempname'])) {
$this->error = "Impossible de trouver le fichier /tmp/{$this->value['tempname']}";
return "";
}

if((rename('/tmp/'.$this->value['tempname'],$dest_path.$this->value['filename']))===FALSE) {
$this->error = "Impossible de déplacer le fichier vers $dest_path{$this->value['filename']}";
return "";
}
return $dest_path.$this->value['filename'];

}

public function getInputHTML($delete_url='') {
$input = '';
$input .= '<input type="file" name="'.$this->name.'" id="'.$this->name.'" />';
if(is_array($this->value)) {
$filename = $this->value['filename'];
} elseif (!empty($this->value)){
$filename = $this->value;
}

if (!empty($filename)) {
$input .= "<br/><div class='form-comment'>Fichier uploadé : ";
$input .= "<a href=\"/inscription/viewcv/$filename\">$filename</a>";
if(!empty($this->delete_url)) {
$input .= '&nbsp;<a href="'.$this->delete_url.'" target="_blank" style="text-decoration:none"><font color="red"><b>X</b></font></a>';
}
$input .= "</div>";
}

return $input;
}

public function __toString() {
$out = '';
$out .= "<p>\n";
$out .= $this->getLabelHTML();
$out .= $this->getInputHTML();
$out .= $this->getErrorHTML();
$out .= "</p>\n\n";
return $out;
}

public function getReadableValue() {
return $this->value['filename'];
}
}

?>

+ 5
- 0
htdocs/.htaccess View File

@@ -0,0 +1,5 @@
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]


+ 87
- 0
htdocs/common.php View File

@@ -0,0 +1,87 @@
<?php

/**
* file included in every PHP file
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0
*/


/**
* Functions
*/
function test_exist($file) {
if(!file_exists($file)) {
die("Erreur, vous devez mettre en place le fichier $file !\n");
}
if(!is_readable($file)) {
die("Erreur, le fichier $file n'est pas accessible en lecture !\n");
}
}

function http_redirect($path) {
header('Location: http://'.$_SERVER['HTTP_HOST'].$path);
exit(0);
}

function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}

function is_superadmin() {
global $conf;
if(!empty($_SESSION['user']) && in_array($_SESSION['user'], $conf['superadmin'])) {
return 1;
} else {
return 0;
}
}

function sudoexec($cmd, &$output, &$return_var) {
global $conf;

/* -H The -H (HOME) option sets the HOME environment variable to the
* homedir of the target user */
/* => Nécessaire pour l'utilisation du .my.cnf de root */
$cmd = sprintf('sudo -H %s/%s', $conf['script_path'], $cmd);

exec($cmd, $output, $return_var);
}

/**
* Includes
*/

// PEAR libs
if (!(ini_set('include_path', ini_get('include_path')))) {
die('bibliotheques PEAR non presentes');
} else {

require_once 'PEAR.php';
require_once 'Log.php';

// config files
// (here because need Log PEAR lib)
test_exist('../conf/connect.php');
require_once('../conf/connect.php');
test_exist('../conf/config.php');
require_once('../conf/config.php');
test_exist('../conf/config.local.php');
require_once('../conf/config.local.php');
# il faut un acces en lecture au fichier shadow pour pam_auth()
test_exist('/etc/shadow');
$conf = array_merge($oriconf, $localconf);
}


+ 166
- 0
htdocs/inc/css/main.css View File

@@ -0,0 +1,166 @@

/**
* Feuille de style
*
* copyright (c) 2009 evolix - tous droits reserves
*
* $id: index.php 3 2009-04-28 08:43:39z tmartin $
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Thomas Martin <tmartin@evolix.fr>
* @version 1.0
*/

body {
background-color: white;
color: black;
font-size: small;
font-family: "Lucida Grande", Helvetica, Arial, Verdana, sans-serif;
margin: 0;
}

div#main {
text-align: center;
}

h1#top {
background-color: blue;
margin: 0;
color: white;
margin-bottom: 10px;
}

div#disclaimer {
margin-top: 30px;
}

ul#menu li {
list-style-type: none;
float: left;
margin-right: 10px;
}

ul#menu {
margin: auto;
margin-bottom: 30px;
}

a {
color: blue;
text-decoration: underline;
}

/* Tableaux "liste" */

table#tab-list {
border-collapse: collapse;
margin: auto;
width: 70%;
}

table#tab-list tr:hover {
background-color: blue;
color: white;
}

table#tab-list tr:hover a {
background-color: blue;
color: white;
}


table#tab-list th {
border: 1px black solid;
background-color: blue;
color: white;
}

table#tab-list td {
border: 1px black solid;
}

div#disclaimer {
border-top: 1px blue solid;
padding-top: 5px;
}

td.auth-error {
color: red;
}

p.form-error {
color: red;
}

fieldset {
width: 50%;
margin: auto;
border: 1px blue solid;
}

fieldset dl {
}

fieldset dt {
text-align: right;
float: left;
width: 45%;
padding-right: 10px;
}

fieldset dd {
text-align: left;
}

p label {
position: absolute;
text-align:right;
width:300px;
}

p input {
margin-left: 310px;
}

p select {
margin-left: 310px;
}

p textarea {
margin-left: 310px;
}

span.form-error {
color: red;
margin-left: 4px;
}

span.form-mandatory {
color: red;
}

span.form-mandatory-ok {
color: #900000;
}

/* Formulaires d'ajout d'objets */

form#form-add {
margin: auto;
}

form#form-add fieldset {
width: 69%;
border: 1px black solid;
}

form#form-add legend {
border: 1px black solid;
background-color: blue;
color: white;
}

form#form-add p {
text-align: left;
}


+ 27
- 0
htdocs/inc/js/ftpadmin.js View File

@@ -0,0 +1,27 @@

// vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2

function fill_directory_field(value) {
if(document.forms['addftp'].path.value == '') {
document.forms['addftp'].path.value = value;
}
}

function check_form_ftp_add() {
field_passwd = document.getElementById('passwd').value;
if(field_passwd.length < 6) {
alert('Le mot de passe doit contenir au moins 6 caractères ');
return false;
}
return true;
}

document.observe("dom:loaded", function() {
document.getElementById('login').onblur = function() {
path = document.getElementById('path');
if(!path.value) {
path.value = document.getElementById('login').value;
}
}
});


+ 4320
- 0
htdocs/inc/js/lib/prototype-1.6.0.3.js View File

@@ -0,0 +1,4320 @@
/* Prototype JavaScript framework, version 1.6.0.3
* (c) 2005-2008 Sam Stephenson
*
* Prototype is freely distributable under the terms of an MIT-style license.
* For details, see the Prototype web site: http://www.prototypejs.org/
*
*--------------------------------------------------------------------------*/

var Prototype = {
Version: '1.6.0.3',

Browser: {
IE: !!(window.attachEvent &&
navigator.userAgent.indexOf('Opera') === -1),
Opera: navigator.userAgent.indexOf('Opera') > -1,
WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
Gecko: navigator.userAgent.indexOf('Gecko') > -1 &&
navigator.userAgent.indexOf('KHTML') === -1,
MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
},

BrowserFeatures: {
XPath: !!document.evaluate,
SelectorsAPI: !!document.querySelector,
ElementExtensions: !!window.HTMLElement,
SpecificElementExtensions:
document.createElement('div')['__proto__'] &&
document.createElement('div')['__proto__'] !==
document.createElement('form')['__proto__']
},

ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,

emptyFunction: function() { },
K: function(x) { return x }
};

if (Prototype.Browser.MobileSafari)
Prototype.BrowserFeatures.SpecificElementExtensions = false;


/* Based on Alex Arnell's inheritance implementation. */
var Class = {
create: function() {
var parent = null, properties = $A(arguments);
if (Object.isFunction(properties[0]))
parent = properties.shift();

function klass() {
this.initialize.apply(this, arguments);
}

Object.extend(klass, Class.Methods);
klass.superclass = parent;
klass.subclasses = [];

if (parent) {
var subclass = function() { };
subclass.prototype = parent.prototype;
klass.prototype = new subclass;
parent.subclasses.push(klass);
}

for (var i = 0; i < properties.length; i++)
klass.addMethods(properties[i]);

if (!klass.prototype.initialize)
klass.prototype.initialize = Prototype.emptyFunction;

klass.prototype.constructor = klass;

return klass;
}
};

Class.Methods = {
addMethods: function(source) {
var ancestor = this.superclass && this.superclass.prototype;
var properties = Object.keys(source);

if (!Object.keys({ toString: true }).length)
properties.push("toString", "valueOf");

for (var i = 0, length = properties.length; i < length; i++) {
var property = properties[i], value = source[property];
if (ancestor && Object.isFunction(value) &&
value.argumentNames().first() == "$super") {
var method = value;
value = (function(m) {
return function() { return ancestor[m].apply(this, arguments) };
})(property).wrap(method);

value.valueOf = method.valueOf.bind(method);
value.toString = method.toString.bind(method);
}
this.prototype[property] = value;
}

return this;
}
};

var Abstract = { };

Object.extend = function(destination, source) {
for (var property in source)
destination[property] = source[property];
return destination;
};

Object.extend(Object, {
inspect: function(object) {
try {
if (Object.isUndefined(object)) return 'undefined';
if (object === null) return 'null';
return object.inspect ? object.inspect() : String(object);
} catch (e) {
if (e instanceof RangeError) return '...';
throw e;
}
},

toJSON: function(object) {
var type = typeof object;
switch (type) {
case 'undefined':
case 'function':
case 'unknown': return;
case 'boolean': return object.toString();
}

if (object === null) return 'null';
if (object.toJSON) return object.toJSON();
if (Object.isElement(object)) return;

var results = [];
for (var property in object) {
var value = Object.toJSON(object[property]);
if (!Object.isUndefined(value))
results.push(property.toJSON() + ': ' + value);
}

return '{' + results.join(', ') + '}';
},

toQueryString: function(object) {
return $H(object).toQueryString();
},

toHTML: function(object) {
return object && object.toHTML ? object.toHTML() : String.interpret(object);
},

keys: function(object) {
var keys = [];
for (var property in object)
keys.push(property);
return keys;
},

values: function(object) {
var values = [];
for (var property in object)
values.push(object[property]);
return values;
},

clone: function(object) {
return Object.extend({ }, object);
},

isElement: function(object) {
return !!(object && object.nodeType == 1);
},

isArray: function(object) {
return object != null && typeof object == "object" &&
'splice' in object && 'join' in object;
},

isHash: function(object) {
return object instanceof Hash;
},

isFunction: function(object) {
return typeof object == "function";
},

isString: function(object) {
return typeof object == "string";
},

isNumber: function(object) {
return typeof object == "number";