|
@@ -0,0 +1,186 @@
|
|
|
+<?php
|
|
|
+/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
|
|
+ * Copyright (C) 2016 Guillaume <guillaume@franciliens.net>
|
|
|
+ *
|
|
|
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
|
|
|
+ */
|
|
|
+
|
|
|
+/**
|
|
|
+ * \file dev/skeletons/skeleton_page.php
|
|
|
+ * \ingroup mymodule othermodule1 othermodule2
|
|
|
+ * \brief This file is an example of a php page
|
|
|
+ * Put here some comments
|
|
|
+ */
|
|
|
+
|
|
|
+//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
|
|
|
+//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
|
|
|
+//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
|
|
+//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
|
|
+//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
|
|
|
+//if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
|
|
|
+//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
|
|
|
+//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
|
|
|
+//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
|
|
|
+//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
|
|
+if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
|
|
|
+
|
|
|
+// Change this following line to use the correct relative path (../, ../../, etc)
|
|
|
+$res=0;
|
|
|
+if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php';
|
|
|
+if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php';
|
|
|
+if (! $res && file_exists("../../../main.inc.php")) $res=@include '../../../main.inc.php';
|
|
|
+if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
|
|
|
+if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
|
|
|
+if (! $res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only
|
|
|
+if (! $res) die("Include of main fails");
|
|
|
+
|
|
|
+// Change this following line to use the correct relative path from htdocs
|
|
|
+dol_include_once('/module/class/skeleton_class.class.php');
|
|
|
+dol_include_once('/adherents/class/adherent.class.php');
|
|
|
+
|
|
|
+require_once('view.php');
|
|
|
+
|
|
|
+// Load traductions files requiredby by page
|
|
|
+$langs->load("companies");
|
|
|
+$langs->load("other");
|
|
|
+
|
|
|
+// Get parameters
|
|
|
+$action = GETPOST('action', 'alpha');
|
|
|
+$login = GETPOST('login', 'alpha');
|
|
|
+$password = GETPOST('password', 'alpha');
|
|
|
+$file = GETPOST('file', 'alpha');
|
|
|
+// Get session
|
|
|
+session_start();
|
|
|
+
|
|
|
+//----------------------------------------
|
|
|
+// Login
|
|
|
+//----------------------------------------
|
|
|
+
|
|
|
+$adherent = new Adherent($db);
|
|
|
+
|
|
|
+if ( $action == 'login' )
|
|
|
+{
|
|
|
+ $_SESSION = array();
|
|
|
+ $adherent->fetch_login($login);
|
|
|
+ if ( $adherent->login === $login && $adherent->pass === $password
|
|
|
+ && $adherent->statut == 1 )
|
|
|
+ {
|
|
|
+ $_SESSION['login'] = $adherent->login;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ paHeader();
|
|
|
+ print('<p>Bad login/password</p>');
|
|
|
+ paFooter();
|
|
|
+ exit(1);
|
|
|
+ }
|
|
|
+}
|
|
|
+else if ( $action == 'logout' )
|
|
|
+{
|
|
|
+ $_SESSION = array();
|
|
|
+ session_destroy();
|
|
|
+ exit('Au revoir');
|
|
|
+}
|
|
|
+else if ( isset($_SESSION['login']) )
|
|
|
+{
|
|
|
+ $adherent->fetch_login($_SESSION['login']);
|
|
|
+}
|
|
|
+else
|
|
|
+{
|
|
|
+ paHeader('Identification');
|
|
|
+ print '<form method="post" action="">
|
|
|
+Utilisateur : <input name="login" type="text" />
|
|
|
+Mot de passe : <input name="password" type="password" />
|
|
|
+<input name="action" type="submit" value="login" />
|
|
|
+</form>';
|
|
|
+ paFooter();
|
|
|
+ exit(0);
|
|
|
+}
|
|
|
+
|
|
|
+$id = $adherent->id;
|
|
|
+$upload_dir = $conf->adherent->dir_output . "/" . get_exdir($id,2,0,1) . '/' . $id . '/';
|
|
|
+
|
|
|
+// Construit liste des fichiers
|
|
|
+$files = array();
|
|
|
+$handle = opendir($upload_dir);
|
|
|
+if($handle)
|
|
|
+{
|
|
|
+ while (false !== ($entry = readdir($handle)))
|
|
|
+ {
|
|
|
+ $filepath = $upload_dir.$entry;
|
|
|
+ if ( is_file($filepath) )
|
|
|
+ {
|
|
|
+ $files[$entry] = $filepath;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ closedir($handle);
|
|
|
+}
|
|
|
+else
|
|
|
+{
|
|
|
+ print('Répertoire non trouvé.');
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+/*******************************************************************
|
|
|
+* ACTIONS
|
|
|
+*
|
|
|
+* Put here all code to do according to value of "action" parameter
|
|
|
+********************************************************************/
|
|
|
+
|
|
|
+if($action == 'Obtenir')
|
|
|
+{
|
|
|
+ if ( isset($files[$file]) )
|
|
|
+ {
|
|
|
+ header('Content-Type: application/octet-stream');
|
|
|
+ header('Content-disposition: attachment; filename="' . basename($file) . '"');
|
|
|
+ print(file_get_contents($files[$file]));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+print($file);
|
|
|
+ print_r($files);
|
|
|
+ }
|
|
|
+}
|
|
|
+else
|
|
|
+{
|
|
|
+ paHeader();
|
|
|
+ print('Bonjour ' . $_SESSION['login']);
|
|
|
+ print('<form action="" method="post">
|
|
|
+<input type="submit" name="action" value="logout" />
|
|
|
+</form>');
|
|
|
+
|
|
|
+ print('<h1>Page adhérent</h1>');
|
|
|
+
|
|
|
+ print('<h2>Informations</h2>');
|
|
|
+
|
|
|
+ print('<p>Nom : '. $adherent->firstname .' '.$adherent->lastname.'</p>');
|
|
|
+ print('<p>Adresse : '. $adherent->address .', '. $adherent->zip .' '.$adherent->town.'</p>');
|
|
|
+ print('<p>Date d\'échéance de cotisation : ' .strftime('%F', $adherent->datefin). '</p>');
|
|
|
+
|
|
|
+ print('<h2>Documents</h2>');
|
|
|
+
|
|
|
+ print('<form method="post" action="">
|
|
|
+<select name="file">');
|
|
|
+ foreach($files as $filename => $filepath)
|
|
|
+ {
|
|
|
+ print('<option value=" ' . $filename . ' ">' . $filename . '</option>');
|
|
|
+ }
|
|
|
+ print('</select>
|
|
|
+<input type="submit" name="action" value="Obtenir" />
|
|
|
+</form>');
|
|
|
+ paFooter();
|
|
|
+}
|
|
|
+
|
|
|
+$db->close();
|
|
|
+?>
|