Subversion Repositories ALCASAR

Rev

Rev 1831 | Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
1281 richard 1
<?php
2
CONST ROOT = '/';
3
require_once(ROOT.'/var/www/html/acc/manager/lib/alcasar/ticketspdf.class.php');
4
 
5
/*
6
TODO :
7
- refonte de GenRandUsersName()
8
- traiter si $nbfailuser (nombre de ticket non créé pour cause de doublon)
9
*/
10
 
11
// POUR LES BESOINS DU DEVELOPPEMENT
12
// BUFFERISATION DES DONNEES ENVOYEES AU CLIENT (compatibilité avec les fichiers existants)
13
ob_start();
14
//Common Functions
15
function sec_imp($time)
16
/* Formatage des secondes avant l'impression */
17
{
18
	$jour = 0;$heure = 0;$minute = 0;$seconde = 0;
19
	$jour = floor($time/86400);
20
	$reste = $time%86400;
21
    	if ($jour!=0) $result = $jour.' J ';
22
	$heure = floor($reste/3600);
23
    	$reste = $reste%3600;
24
    	if ($heure!=0) $result = $result.$heure.' H ';
25
	$minute = floor($reste/60);
26
    	if ($minute!=0) $result = $result.$minute.' min ';
27
	$seconde = $reste%60;
28
    	if ($seconde!=0) $result = $result.$seconde.' s ';
29
   	return $result;
30
}
31
 
32
function GenPassword($nb_car="8")
33
	{
34
 /* generation aléatoire du mot de passe */
35
	$password = "";
36
	$chaine  = "aAzZeErRtTyYuUIopP152346897mMLkK";
37
	$chaine .= "jJhHgGfFdDsSqQwWxXcCvVbBnN152346897";
38
	while($nb_car != 0)
39
		{
40
		$i = rand(0,71);
41
		$password = $password.$chaine[$i];
42
		$nb_car --;
43
		}
44
	return $password ;
45
	}
46
function GenRandUsersName()
47
{
48
	$nb_car= 12;
49
	$chaine = "AZE489RTYU2PML5KJ35HGF9DSQWXCV3BN267";
50
	//$i = rand(0,25);
51
	//$j = rand(0,25);
52
	//$k = rand(0,25);
53
	$userName = "";
54
	while($nb_car != 0)
55
		{
56
		$i = rand(0,35);
57
		$userName .= $chaine[$i];
58
		$nb_car --;
59
		}
60
	//return "T".$chaine[$i].substr(time(),4).$chaine[$j].$chaine[$k];
61
	return $userName;
62
}
63
 
64
if (isset($_POST['nbtickets'])&& is_numeric($_POST['nbtickets'])){
65
	$nbtickets = (int)$_POST['nbtickets'];
66
} else {
67
	header("Location: voucher_new.php");
68
	exit;
69
}
70
 
71
//	Langue du Ticket d'impression en fonction de la liste déroulante
72
if (isset($_POST["langue_imp"])) { $langue_imp = $_POST["langue_imp"]; } else { $langue_imp = "en"; };
73
if (is_file("../lib/langues_imp.php")) include("../lib/langues_imp.php") ;
74
 
75
require(ROOT.'etc/freeradius-web/config.php');
76
require('../lib/attrshow.php');
77
require('../lib/defaults.php');
78
if ($config[general_lib_type] == 'sql' && $config[sql_use_operators] == 'true'){
79
	$colspan=2;
80
	$show_ops=1;
81
}else{
82
	$show_ops = 0;
83
	$colspan=1;
84
}
85
 
86
$LIBpath = "../lib/";
87
require(ROOT.'etc/freeradius-web/config.php');
88
if (is_file($LIBpath."sql/drivers/$config[sql_type]/functions.php"))
89
	{
90
	include_once($LIBpath."sql/drivers/$config[sql_type]/functions.php");
91
	}
92
else
93
	{
94
	echo "<b>Could not include SQL library</b><br>\n";
95
	exit();
96
	}
97
include_once($LIBpath.'functions.php');
98
if ($config['sql_use_operators'] == 'true')
99
	{
100
	include_once($LIBpath."operators.php");
101
	$text = ',op';
102
	$passwd_op = ",':='";
103
	}
104
$link = @da_sql_pconnect($config);
105
 
106
$nbfailuser = 0;
107
 
108
// Préparation de la fiche PDF
109
$pdf = new ticketsPDF(2,3);
110
$pdf->setTicketsTitle($l_title_imp);
111
$pdf->setTicketsFooter($l_footer_imp);
112
 
113
if ($link)
114
{
115
	if (is_file($LIBpath."crypt/$config[general_encryption_method].php"))
116
	{
117
		include($LIBpath."crypt/$config[general_encryption_method].php");
118
		// ajout des comptes (mêmes attributs pour tous sauf login + mdp)
119
 
120
		for ($i = 1; $i <= $nbtickets; $i++) 
121
		{
122
			// effacement des variables
123
			$login = "";
124
			$passwd = "";
125
			// création des données uniques
126
			$login = GenRandUsersName();
127
			$passwd = GenPassword();
128
			$login = da_sql_escape_string($login);
129
			$passwd = da_sql_escape_string($passwd);
130
			// création des variables d'impression
131
			$login_imp = $login;
132
			$passwd1_imp = $passwd;
133
			// encryption du mot de passe (pas besoins, déjà présent dans le fichier create_user.php)
134
			//$passwd = da_encrypt($passwd);
135
 
136
			// test si l'usager existe
137
			if (is_file("../lib/$config[general_lib_type]/user_info.php"))
138
				include("../lib/$config[general_lib_type]/user_info.php");
139
 
140
			if ($user_exists == "no"){
141
				// Création de l'usager
142
				if (is_file("../lib/$config[general_lib_type]/create_user.php"))
143
				 	include("../lib/$config[general_lib_type]/create_user.php");
144
				/*  Petit traitement pré-impression pour la lisibilité */
145
				/*  Récupération des attributs du groupe le cas échéant */
146
				if ($group!=''){
147
				 	$saved_login = $login;
148
				 	$login = $group;
149
				 	if (is_file("../lib/sql/group_info.php"))
150
				 		include("../lib/sql/group_info.php");
151
				 	$login = $saved_login;}
152
				/*  Si les valeurs de durée sont vide remplissage avec la valeur 'Illimitée'*/
153
				/*  et formatage des secondes sous le format Heure min ses*/
154
				if ($sto_imp==''){ $sto_imp=$l_unlimited;}
155
				 	else { $sto_imp=sec_imp($sto_imp);}
156
				if ($mas_imp==''){ $mas_imp=$l_unlimited;}
157
					else { $mas_imp=sec_imp($mas_imp);}
158
				if ($mds_imp==''){ $mds_imp=$l_unlimited;}
159
				 	else { $mds_imp=sec_imp($mds_imp);}
160
				if ($mms_imp==''){ $mms_imp=$l_unlimited;}
161
				 	else { $mms_imp=sec_imp($mms_imp);}	
162
				/*Formatage de la date afin d'être lisible dans toute les langues 'jj mm yyyy'*/
163
				$exp_imp = $Expiration;
164
				if ($exp_imp!=''){ $exp_imp=date("d - m - Y",strtotime($exp_imp));}
165
				 	else { $exp_imp=$l_without;}
166
				// Ajout d'un ticket sur la fiche PDF
167
				$pdf->newTickets();
168
				$pdf->Ln(5);
169
				$pdf->addInfos($l_login_imp, $login_imp);
170
				$pdf->addInfos($l_password_imp, $passwd1_imp);
171
				$pdf->Ln(5);
172
				$pdf->addInfos($l_max_all_session_imp, $mas_imp);
173
				$pdf->addInfos($l_session_timeout_imp, $sto_imp);
174
				$pdf->addInfos($l_max_daily_session_imp, $mds_imp);
175
				$pdf->addInfos($l_expiration_imp, $exp_imp);
176
				$pdf->Ln(10);
177
				$pdf->addComment($l_explain);
178
 
179
				// Création du duplicata
180
				$pdf->newTickets();
181
				$pdf->Ln(5);
182
				$pdf->addInfos($l_login_imp, $login_imp);
183
				$pdf->addInfos($l_password_imp, $passwd1_imp);
184
				$pdf->Ln(5);
185
				$pdf->addInfos($l_max_all_session_imp, $mas_imp);
186
				$pdf->addInfos($l_session_timeout_imp, $sto_imp);
187
				$pdf->addInfos($l_max_daily_session_imp, $mds_imp);
188
				$pdf->addInfos($l_expiration_imp, $exp_imp);
189
				$pdf->Ln(10);
190
				$pdf->addComment($l_duplicate,'C');//à mettre en rouge
191
			} else {
192
				$nbfailuser++;
193
			}# if user
194
		} # end for
195
	} # end if (is file)
196
} # end if (link)
197
 
198
//Affichage de la fiche de tickets
199
ob_end_clean();
200
$pdf->Output();
201
?>