Subversion Repositories ALCASAR

Rev

Rev 2168 | Rev 2493 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2168 Rev 2473
1
<?php
1
<?php
2
/**
2
/**
3
 * Print tickets of the new user
3
 * Print tickets of the new user
4
 *
4
 *
5
 * @author    Tom Houdayer
5
 * @author    Tom Houdayer
6
 * @copyright Copyright (C) ALCASAR (http://www.alcasar.net)
6
 * @copyright Copyright (C) ALCASAR (http://www.alcasar.net)
7
 * @license   GPL-3.0
7
 * @license   GPL-3.0
8
 * @version   $Id: ticket_user.php 2168 2017-04-18 17:39:54Z tom.houdayer $
8
 * @version   $Id: ticket_user.php 2473 2017-12-30 00:37:45Z tom.houdayer $
9
 */
9
 */
10
 
10
 
11
require_once __DIR__ . '/../lib/alcasar/TicketsGenerator.php';
11
require_once __DIR__ . '/../lib/alcasar/TicketsGenerator.php';
12
$langue_imp = ((isset($_POST['langue_imp'])) ? $_POST['langue_imp'] : 'en');
12
$langue_imp = ((isset($_POST['langue_imp'])) ? $_POST['langue_imp'] : 'en');
13
require_once __DIR__ . '/../lib/langues_imp.php';
13
require_once __DIR__ . '/../lib/langues_imp.php';
14
 
14
 
15
// Get datas from form
15
// Get datas from form
16
if ((!isset($_POST['log_imp'])) || (!isset($_POST['passwd_imp'])) || (!isset($_POST['exp_imp'])) || (!isset($_POST['sto_imp'])) || (!isset($_POST['mas_imp'])) || (!isset($_POST['mds_imp']))) {
16
if ((!isset($_POST['log_imp'])) || (!isset($_POST['passwd_imp'])) || (!isset($_POST['exp_imp'])) || (!isset($_POST['sto_imp'])) || (!isset($_POST['mas_imp'])) || (!isset($_POST['mds_imp']))) {
17
	exit();
17
	exit();
18
}
18
}
19
$log_imp    = $_POST['log_imp'];
19
$log_imp    = $_POST['log_imp'];
20
$passwd_imp = $_POST['passwd_imp'];
20
$passwd_imp = $_POST['passwd_imp'];
21
$exp_imp    = ((($_POST['exp_imp'] === '') || ($_POST['exp_imp'] === '-')) ? $l_without   : utf8_decode($_POST['exp_imp']));
21
$exp_imp    = ((($_POST['exp_imp'] === '') || ($_POST['exp_imp'] === '-')) ? $l_without   : utf8_decode($_POST['exp_imp']));
22
$sto_imp    = ((($_POST['sto_imp'] === '') || ($_POST['sto_imp'] === '-')) ? $l_unlimited : utf8_decode($_POST['sto_imp']));
22
$sto_imp    = ((($_POST['sto_imp'] === '') || ($_POST['sto_imp'] === '-')) ? $l_unlimited : utf8_decode($_POST['sto_imp']));
23
$mas_imp    = ((($_POST['mas_imp'] === '') || ($_POST['mas_imp'] === '-')) ? $l_unlimited : utf8_decode($_POST['mas_imp']));
23
$mas_imp    = ((($_POST['mas_imp'] === '') || ($_POST['mas_imp'] === '-')) ? $l_unlimited : utf8_decode($_POST['mas_imp']));
24
$mds_imp    = ((($_POST['mds_imp'] === '') || ($_POST['mds_imp'] === '-')) ? $l_unlimited : utf8_decode($_POST['mds_imp']));
24
$mds_imp    = ((($_POST['mds_imp'] === '') || ($_POST['mds_imp'] === '-')) ? $l_unlimited : utf8_decode($_POST['mds_imp']));
25
 
25
 
26
// Generate tickets
26
// Generate tickets
27
$ticketsGenerator = new TicketsGenerator(['language' => $langue_imp]);
27
$ticketsGenerator = new TicketsGenerator(['language' => $langue_imp]);
28
 
28
 
29
// Add user
29
// Add user
30
$ticketsGenerator->addTicket([
30
$ticketsGenerator->addTicket([
31
	'username'        => $log_imp,
31
	'username'        => $log_imp,
32
	'password'        => $passwd_imp,
32
	'password'        => $passwd_imp,
33
	'maxAllSession'   => $mas_imp,
33
	'maxAllSession'   => $mas_imp,
34
	'sessionTimeout'  => $sto_imp,
34
	'sessionTimeout'  => $sto_imp,
35
	'maxDailySession' => $mds_imp,
35
	'maxDailySession' => $mds_imp,
36
	'expiration'      => $exp_imp
36
	'expiration'      => $exp_imp
37
]);
37
]);
38
 
38
 
39
// Save the PDF and redirect user to it
39
// Save the PDF and redirect user to it
40
$filename = 'ticket_' . $log_imp . '.pdf';
40
$filename = 'ticket_' . $log_imp . '.pdf';
-
 
41
// Remove accents
-
 
42
$filename = strtr(utf8_decode($filename), utf8_decode('ŠŒŽšœžŸ¥µÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ'), 'SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy'); // TODO : manage all UTF-8 chars
41
$ticketsGenerator->saveAs($filename);
43
$ticketsGenerator->saveAs($filename);
42
header('Location: ' . $filename);
44
header('Location: ' . $filename);
43
 
45