Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
1088 stephane 1
<?php
1157 stephane 2
CONST ROOT = '/';
3
require_once(ROOT.'/var/www/html/acc/manager/lib/alcasar/ticketspdf.class.php');
1088 stephane 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
	$heure=0;$minute=0;$seconde=0;
19
	$heure = floor($time/3600);
20
    	$reste = $time%3600;
21
    	if ($heure!=0) $result = $heure.' H ';
22
	$minute = floor($reste/60);
23
    	if ($minute!=0) $result = $result.$minute.' min ';
24
	$seconde = $reste%60;
25
    	if ($seconde!=0) $result = $result.$seconde.' s ';
26
   	return $result;
27
}
28
 
29
function GenPassword($nb_car="8")
30
	{
31
 /* generation aléatoire du mot de passe */
32
	$password = "";
33
	$chaine  = "aAzZeErRtTyYuUIopP152346897mMLkK";
34
	$chaine .= "jJhHgGfFdDsSqQwWxXcCvVbBnN152346897";
35
	while($nb_car != 0)
36
		{
37
		$i = rand(0,71);
38
		$password = $password.$chaine[$i];
39
		$nb_car --;
40
		}
41
	return $password ;
42
	}
43
function GenRandUsersName()
44
{
45
	$nb_car= 12;
46
	$chaine = "AZE489RTYU2PML5KJ35HGF9DSQWXCV3BN267";
47
	//$i = rand(0,25);
48
	//$j = rand(0,25);
49
	//$k = rand(0,25);
50
	$userName = "";
51
	while($nb_car != 0)
52
		{
53
		$i = rand(0,35);
54
		$userName .= $chaine[$i];
55
		$nb_car --;
56
		}
57
	//return "T".$chaine[$i].substr(time(),4).$chaine[$j].$chaine[$k];
58
	return $userName;
59
}
60
 
61
if (isset($_POST['nbtickets'])&& is_numeric($_POST['nbtickets'])){
62
	$nbtickets = (int)$_POST['nbtickets'];
63
} else {
64
	header("Location: voucher_new.php");
65
	exit;
66
}
67
 
68
//	Gestion de la langue
69
//	if (is_file("../lib/langues.php"))
70
//	include("../lib/langues.php");
71
 
72
//	Langue du Ticket d'impression en fonction de la liste déroulante
73
 
74
if (isset($_POST["langue_imp"])) { $langue_imp = $_POST["langue_imp"]; } else { $langue_imp = "en"; };
75
 
76
switch ($langue_imp){
77
	case 'fr':
78
		$l_title_imp = "TICKET D'ACCÈS INTERNET";
79
		$l_footer_imp = "Généré par ALCASAR";
1157 stephane 80
			//$l_explain1_imp = "Entrer 'alcasar' dans votre navigateur pour gérer votre compte (mot de passe, certificat, etc.).";
81
			//$l_explain2_imp = "Entrer 'logout' dans votre navigateur pour vous déconnecter.";
1088 stephane 82
			$l_explain = "Entrer 'alcasar' dans votre navigateur pour gérer votre compte
83
			(mot de passe, certificat, etc.).
84
			Entrer 'logout' dans votre navigateur pour vous déconnecter.";
85
		$l_login_imp = "Utilisateur :";
86
		$l_password_imp = "Mot de passe :";
87
		$l_max_all_session_imp="Durée totale autorisée :";
88
		$l_session_timeout_imp="Durée d'une session :";
89
		$l_max_daily_session_imp="Durée journalière :";
90
		$l_max_monthly_session_imp ="Durée mensuelle :";
91
		$l_expiration_imp="Date d'expiration :";
92
		$l_unlimited="Illimitée";
93
		$l_without="Aucune";
1160 stephane 94
		$l_duplicate="Duplicata";
1088 stephane 95
	break;
96
	case 'de':
97
		$l_title_imp = "INTERNETZUGANG TICKET";
98
		$l_footer_imp = "Präsentiert von ALCASAR";
1157 stephane 99
			//$l_explain1_imp = "Geben Sie 'Alcasar' in Ihrem Browser, um Ihr Konto zu verwalten (kennwort, zertifikat, etc.).";
100
			//$l_explain2_imp = "Geben Sie 'logout' in Ihrem Browser zu trennen.";
1088 stephane 101
			$l_explain = "Geben Sie 'Alcasar' in Ihrem Browser, um Ihr Konto zu verwalten (kennwort, zertifikat, etc.).
102
			Geben Sie 'logout' in Ihrem Browser zu trennen.
103
			";
104
		$l_login_imp = "Login :";
105
		$l_password_imp = "Passwort :";
106
		$l_max_all_session_imp="Maximale erlaubt Dauer :";
107
		$l_session_timeout_imp="Dauer der Sitzung :";
108
		$l_max_daily_session_imp="Stunden t&auml;glich :";
109
		$l_max_monthly_session_imp ="monatlich Dauer :";
110
		$l_expiration_imp="Verfallsdatum :";
111
		$l_unlimited="Unbegrentz";
112
		$l_without="Ohne";
1160 stephane 113
		$l_duplicate="Duplikat";
1088 stephane 114
	break;
115
	case 'nl':
116
		$l_title_imp = "ONTVANGST INTERNET";
117
		$l_footer_imp = "Powered by ALCASAR";
1157 stephane 118
			//$l_explain1_imp = "Voer 'Alcasar' in uw browser om uw account te beheren (wachtwoord, certificaat, etc.).";
119
			//$l_explain2_imp = "Voer 'logout' in uw browser de verbinding te verbreken.";
1088 stephane 120
			$l_explain = "Voer 'Alcasar' in uw browser om uw account te beheren (wachtwoord, certificaat, etc.).
121
			Voer 'logout' in uw browser de verbinding te verbreken.";
122
		$l_login_imp = "Gebruikers :";
123
		$l_password_imp = "Wachtwoord :";
124
		$l_max_all_session_imp="Totaal toegestane tijd :";
125
		$l_session_timeout_imp="Sessieduur :";
126
		$l_max_daily_session_imp="Dagelijkse uren :";
127
		$l_max_monthly_session_imp ="Maandelijkse duur :";
128
		$l_expiration_imp="Vervaldatum :";
129
		$l_unlimited="Onbeperkte";
130
		$l_without="Ohne";
1160 stephane 131
		$l_duplicate="Duplicaat";
1088 stephane 132
	break;
133
	case 'es':
134
		$l_title_imp = "BONO INTERNET";
135
		$l_footer_imp = "Desarrollado por ALCASAR";
1157 stephane 136
			//$l_explain1_imp = "Escribe 'Alcasar' de su navegador para administrar su cuenta (contraseña, certificado, etc.).";
137
			//$l_explain2_imp = "Escribe 'logout' de su navegador para desconectar.";
1088 stephane 138
			$l_explain = "Escribe 'Alcasar' de su navegador para administrar su cuenta (contraseña, certificado, etc.).
139
			Escribe 'logout' de su navegador para desconectar.";
140
		$l_login_imp = "Usuario :";
141
		$l_password_imp = "Contraseña :";
142
		$l_max_all_session_imp="Tiempo total permitido :";
143
		$l_session_timeout_imp="Duraciôn de Sesiôn :";
144
		$l_max_daily_session_imp="Horas diarias :";
145
		$l_max_monthly_session_imp ="Duraciôn mensual :";
146
		$l_expiration_imp="Fecha de caducidad :";
147
		$l_unlimited="Ilimitado";
148
		$l_without="Sin";
1160 stephane 149
		$l_duplicate="Duplicado";
1088 stephane 150
	break;
151
	case 'it':
152
		$l_title_imp = "RICEVIMENTO INTERNET";
153
		$l_footer_imp = "Powered by ALCASAR";
1157 stephane 154
			//$l_explain1_imp = "Inserisci 'alcasar' nel tuo browser per gestire il tuo account (password, certificato, ecc).";
155
			//$l_explain2_imp = "Inserisci 'logout' nel tuo browser per disconnettersi.";
1088 stephane 156
			$l_explain = "Inserisci 'alcasar' nel tuo browser per gestire il tuo account (password, certificato, ecc).
157
			Inserisci 'logout' nel tuo browser per disconnettersi.";
158
		$l_login_imp = "Utenti :";
159
		$l_password_imp = "Password :";
160
		$l_max_all_session_imp="Tempo totale consentito:";
161
		$l_session_timeout_imp="Durata della sessione :";
162
		$l_max_daily_session_imp="Ore giornaliere :";
163
		$l_max_monthly_session_imp ="Durata mensile :";
164
		$l_expiration_imp="Data di scadenza :";
165
		$l_unlimited="Illimitato";
166
		$l_without="Senza";
1160 stephane 167
		$l_duplicate="Duplicato";
1088 stephane 168
	break;
169
	case 'pt':
170
		$l_title_imp = "BILHETE DE ACESSO À INTERNET";
171
		$l_footer_imp = "Desenvolvido por ALCASAR";
1157 stephane 172
			//$l_explain1_imp = "Digite 'Alcasar' no seu navegador para gerenciar sua conta (senha, certidão, etc).";
173
			//$l_explain2_imp = "Digite 'logout' no seu navegador para desligar.";
1088 stephane 174
			$l_explain = "Digite 'Alcasar' no seu navegador para gerenciar sua conta (senha, certidão, etc).
175
			Digite 'logout' no seu navegador para desligar.";
176
		$l_login_imp = "Usuário :";
177
		$l_password_imp = "Senha :";
178
		$l_max_all_session_imp="Tempo máximo de toda conexão :";
179
		$l_session_timeout_imp="Fim da conexão :";
180
		$l_max_daily_session_imp="Conexão máxima diária :";
181
		$l_max_monthly_session_imp ="MConexão máxima mensal :";
182
		$l_expiration_imp="Data de vencimento :";
183
		$l_unlimited="Ilimitado";
184
		$l_without="Sem";
1160 stephane 185
		$l_duplicate="Duplicado";
1088 stephane 186
	break;
187
	default:
188
		$l_title_imp = "INTERNET ACCESS TICKET";
189
		$l_footer_imp = "Powered by ALCASAR";
1157 stephane 190
			//$l_explain1_imp = "Enter 'alcasar' in your browser to manage your account (password, certificate, etc.).";
191
			//$l_explain2_imp = "Enter 'logout' in your browser to disconnect.";
1088 stephane 192
			$l_explain = "Enter 'alcasar' in your browser to manage your account (password, certificate, etc.).
193
			Enter 'logout' in your browser to disconnect.";
194
		$l_login_imp = "Login :";
195
		$l_password_imp = "Password :";
196
		$l_max_all_session_imp="Total time allowed :";
197
		$l_session_timeout_imp="Session timeout :";
198
		$l_max_daily_session_imp="Max daily session :";
199
		$l_max_monthly_session_imp ="Max monthly session :";
200
		$l_expiration_imp="Expiration date :";
201
		$l_unlimited="Unlimited";
202
		$l_without="Without";
1160 stephane 203
		$l_duplicate="Duplicate";
1088 stephane 204
	break;
205
	}
206
 
207
require(ROOT.'etc/freeradius-web/config.php');
208
 
209
require('../lib/attrshow.php');
210
require('../lib/defaults.php');
211
if ($config[general_lib_type] == 'sql' && $config[sql_use_operators] == 'true'){
212
	$colspan=2;
213
	$show_ops=1;
214
}else{
215
	$show_ops = 0;
216
	$colspan=1;
217
}
218
 
219
$LIBpath = "../lib/";
220
require(ROOT.'etc/freeradius-web/config.php');
221
if (is_file($LIBpath."sql/drivers/$config[sql_type]/functions.php"))
222
	{
223
	include_once($LIBpath."sql/drivers/$config[sql_type]/functions.php");
224
	}
225
else
226
	{
227
	echo "<b>Could not include SQL library</b><br>\n";
228
	exit();
229
	}
230
include_once($LIBpath.'functions.php');
231
if ($config['sql_use_operators'] == 'true')
232
	{
233
	include_once($LIBpath."operators.php");
234
	$text = ',op';
235
	$passwd_op = ",':='";
236
	}
237
$link = @da_sql_pconnect($config);
238
 
239
$nbfailuser = 0;
240
 
241
// Préparation de la fiche PDF
242
$pdf = new ticketsPDF(2,3);
243
$pdf->setTicketsTitle($l_title_imp);
244
$pdf->setTicketsFooter($l_footer_imp);
245
 
246
if ($link)
247
{
248
	if (is_file($LIBpath."crypt/$config[general_encryption_method].php"))
249
	{
250
		include($LIBpath."crypt/$config[general_encryption_method].php");
251
		// ajout des comptes (mêmes attributs pour tous sauf login + mdp)
252
 
253
		for ($i = 1; $i <= $nbtickets; $i++) 
254
		{
255
			// effacement des variables
256
			$login = "";
257
			$passwd = "";
258
			// création des données uniques
259
			$login = GenRandUsersName();
260
			$passwd = GenPassword();
261
			$login = da_sql_escape_string($login);
262
			$passwd = da_sql_escape_string($passwd);
263
			// création des variables d'impression
264
			$login_imp = $login;
265
			$passwd1_imp = $passwd;
1157 stephane 266
			// encryption du mot de passe (pas besoins, déjà présent dans le fichier create_user.php)
267
			//$passwd = da_encrypt($passwd);
1088 stephane 268
 
269
			// test si l'usager existe
270
			if (is_file("../lib/$config[general_lib_type]/user_info.php"))
271
				include("../lib/$config[general_lib_type]/user_info.php");
272
 
273
			if ($user_exists == "no"){
274
				// Création de l'usager
275
				if (is_file("../lib/$config[general_lib_type]/create_user.php"))
276
				 	include("../lib/$config[general_lib_type]/create_user.php");
277
				/*  Petit traitement pré-impression pour la lisibilité */
278
				/*  Récupération des attributs du groupe le cas échéant */
279
				if ($group!=''){
280
				 	$saved_login = $login;
281
				 	$login = $group;
282
				 	if (is_file("../lib/sql/group_info.php"))
283
				 		include("../lib/sql/group_info.php");
284
				 	$login = $saved_login;}
285
				/*  Si les valeurs de durée sont vide remplissage avec la valeur 'Illimitée'*/
286
				/*  et formatage des secondes sous le format Heure min ses*/
287
				if ($sto_imp==''){ $sto_imp=$l_unlimited;}
288
				 	else { $sto_imp=sec_imp($sto_imp);}
289
				if ($mas_imp==''){ $mas_imp=$l_unlimited;}
290
					else { $mas_imp=sec_imp($mas_imp);}
291
				if ($mds_imp==''){ $mds_imp=$l_unlimited;}
292
				 	else { $mds_imp=sec_imp($mds_imp);}
293
				if ($mms_imp==''){ $mms_imp=$l_unlimited;}
294
				 	else { $mms_imp=sec_imp($mms_imp);}	
295
				/*Formatage de la date afin d'être lisible dans toute les langues 'jj mm yyyy'*/
296
				$exp_imp = $Expiration;
297
				if ($exp_imp!=''){ $exp_imp=date("d - m - Y",strtotime($exp_imp));}
298
				 	else { $exp_imp=$l_without;}
299
				// Ajout d'un ticket sur la fiche PDF
300
				$pdf->newTickets();
301
				$pdf->Ln(5);
302
				$pdf->addInfos($l_login_imp, $login_imp);
303
				$pdf->addInfos($l_password_imp, $passwd1_imp);
304
				$pdf->Ln(5);
305
				$pdf->addInfos($l_max_all_session_imp, $mas_imp);
306
				$pdf->addInfos($l_session_timeout_imp, $sto_imp);
307
				$pdf->addInfos($l_max_daily_session_imp, $mds_imp);
308
				$pdf->addInfos($l_expiration_imp, $exp_imp);
309
				$pdf->Ln(10);
310
				$pdf->addComment($l_explain);
1160 stephane 311
 
312
				// Création du duplicata
313
				$pdf->newTickets();
314
				$pdf->Ln(5);
315
				$pdf->addInfos($l_login_imp, $login_imp);
316
				$pdf->addInfos($l_password_imp, $passwd1_imp);
317
				$pdf->Ln(5);
318
				$pdf->addInfos($l_max_all_session_imp, $mas_imp);
319
				$pdf->addInfos($l_session_timeout_imp, $sto_imp);
320
				$pdf->addInfos($l_max_daily_session_imp, $mds_imp);
321
				$pdf->addInfos($l_expiration_imp, $exp_imp);
322
				$pdf->Ln(10);
323
				$pdf->addComment($l_duplicate,'C');//à mettre en rouge
1088 stephane 324
			} else {
325
				$nbfailuser++;
326
			}# if user
327
		} # end for
328
	} # end if (is file)
329
} # end if (link)
330
 
331
//Affichage de la fiche de tickets
332
ob_end_clean();
333
$pdf->Output();
334
?>