Subversion Repositories ALCASAR

Rev

Rev 2473 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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