Subversion Repositories ALCASAR

Rev

Rev 1281 | Rev 2168 | Go to most recent revision | Details | Compare with Previous | 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();
1831 raphael.pi 128
 
1281 richard 129
			// création des variables d'impression
130
			$login_imp = $login;
131
			$passwd1_imp = $passwd;
132
			// encryption du mot de passe (pas besoins, déjà présent dans le fichier create_user.php)
133
			//$passwd = da_encrypt($passwd);
134
 
135
			// test si l'usager existe
136
			if (is_file("../lib/$config[general_lib_type]/user_info.php"))
137
				include("../lib/$config[general_lib_type]/user_info.php");
138
 
139
			if ($user_exists == "no"){
140
				// Création de l'usager
141
				if (is_file("../lib/$config[general_lib_type]/create_user.php"))
142
				 	include("../lib/$config[general_lib_type]/create_user.php");
143
				/*  Petit traitement pré-impression pour la lisibilité */
144
				/*  Récupération des attributs du groupe le cas échéant */
145
				if ($group!=''){
146
				 	$saved_login = $login;
147
				 	$login = $group;
148
				 	if (is_file("../lib/sql/group_info.php"))
149
				 		include("../lib/sql/group_info.php");
150
				 	$login = $saved_login;}
151
				/*  Si les valeurs de durée sont vide remplissage avec la valeur 'Illimitée'*/
152
				/*  et formatage des secondes sous le format Heure min ses*/
153
				if ($sto_imp==''){ $sto_imp=$l_unlimited;}
154
				 	else { $sto_imp=sec_imp($sto_imp);}
155
				if ($mas_imp==''){ $mas_imp=$l_unlimited;}
156
					else { $mas_imp=sec_imp($mas_imp);}
157
				if ($mds_imp==''){ $mds_imp=$l_unlimited;}
158
				 	else { $mds_imp=sec_imp($mds_imp);}
159
				if ($mms_imp==''){ $mms_imp=$l_unlimited;}
160
				 	else { $mms_imp=sec_imp($mms_imp);}	
161
				/*Formatage de la date afin d'être lisible dans toute les langues 'jj mm yyyy'*/
162
				$exp_imp = $Expiration;
163
				if ($exp_imp!=''){ $exp_imp=date("d - m - Y",strtotime($exp_imp));}
164
				 	else { $exp_imp=$l_without;}
165
				// Ajout d'un ticket sur la fiche PDF
166
				$pdf->newTickets();
167
				$pdf->Ln(5);
168
				$pdf->addInfos($l_login_imp, $login_imp);
169
				$pdf->addInfos($l_password_imp, $passwd1_imp);
170
				$pdf->Ln(5);
171
				$pdf->addInfos($l_max_all_session_imp, $mas_imp);
172
				$pdf->addInfos($l_session_timeout_imp, $sto_imp);
173
				$pdf->addInfos($l_max_daily_session_imp, $mds_imp);
174
				$pdf->addInfos($l_expiration_imp, $exp_imp);
175
				$pdf->Ln(10);
176
				$pdf->addComment($l_explain);
177
 
178
				// Création du duplicata
179
				$pdf->newTickets();
180
				$pdf->Ln(5);
181
				$pdf->addInfos($l_login_imp, $login_imp);
182
				$pdf->addInfos($l_password_imp, $passwd1_imp);
183
				$pdf->Ln(5);
184
				$pdf->addInfos($l_max_all_session_imp, $mas_imp);
185
				$pdf->addInfos($l_session_timeout_imp, $sto_imp);
186
				$pdf->addInfos($l_max_daily_session_imp, $mds_imp);
187
				$pdf->addInfos($l_expiration_imp, $exp_imp);
188
				$pdf->Ln(10);
189
				$pdf->addComment($l_duplicate,'C');//à mettre en rouge
190
			} else {
191
				$nbfailuser++;
192
			}# if user
193
		} # end for
194
	} # end if (is file)
195
} # end if (link)
196
 
197
//Affichage de la fiche de tickets
198
ob_end_clean();
199
$pdf->Output();
200
?>