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 |
// Langue du Ticket d'impression en fonction de la liste déroulante
|
|
|
69 |
if (isset($_POST["langue_imp"])) { $langue_imp = $_POST["langue_imp"]; } else { $langue_imp = "en"; };
|
1280 |
richard |
70 |
if (is_file("../lib/langues_imp.php")) include("../lib/langues_imp.php") ;
|
1088 |
stephane |
71 |
|
|
|
72 |
require(ROOT.'etc/freeradius-web/config.php');
|
|
|
73 |
require('../lib/attrshow.php');
|
|
|
74 |
require('../lib/defaults.php');
|
|
|
75 |
if ($config[general_lib_type] == 'sql' && $config[sql_use_operators] == 'true'){
|
|
|
76 |
$colspan=2;
|
|
|
77 |
$show_ops=1;
|
|
|
78 |
}else{
|
|
|
79 |
$show_ops = 0;
|
|
|
80 |
$colspan=1;
|
|
|
81 |
}
|
|
|
82 |
|
|
|
83 |
$LIBpath = "../lib/";
|
|
|
84 |
require(ROOT.'etc/freeradius-web/config.php');
|
|
|
85 |
if (is_file($LIBpath."sql/drivers/$config[sql_type]/functions.php"))
|
|
|
86 |
{
|
|
|
87 |
include_once($LIBpath."sql/drivers/$config[sql_type]/functions.php");
|
|
|
88 |
}
|
|
|
89 |
else
|
|
|
90 |
{
|
|
|
91 |
echo "<b>Could not include SQL library</b><br>\n";
|
|
|
92 |
exit();
|
|
|
93 |
}
|
|
|
94 |
include_once($LIBpath.'functions.php');
|
|
|
95 |
if ($config['sql_use_operators'] == 'true')
|
|
|
96 |
{
|
|
|
97 |
include_once($LIBpath."operators.php");
|
|
|
98 |
$text = ',op';
|
|
|
99 |
$passwd_op = ",':='";
|
|
|
100 |
}
|
|
|
101 |
$link = @da_sql_pconnect($config);
|
|
|
102 |
|
|
|
103 |
$nbfailuser = 0;
|
|
|
104 |
|
|
|
105 |
// Préparation de la fiche PDF
|
|
|
106 |
$pdf = new ticketsPDF(2,3);
|
|
|
107 |
$pdf->setTicketsTitle($l_title_imp);
|
|
|
108 |
$pdf->setTicketsFooter($l_footer_imp);
|
|
|
109 |
|
|
|
110 |
if ($link)
|
|
|
111 |
{
|
|
|
112 |
if (is_file($LIBpath."crypt/$config[general_encryption_method].php"))
|
|
|
113 |
{
|
|
|
114 |
include($LIBpath."crypt/$config[general_encryption_method].php");
|
|
|
115 |
// ajout des comptes (mêmes attributs pour tous sauf login + mdp)
|
|
|
116 |
|
|
|
117 |
for ($i = 1; $i <= $nbtickets; $i++)
|
|
|
118 |
{
|
|
|
119 |
// effacement des variables
|
|
|
120 |
$login = "";
|
|
|
121 |
$passwd = "";
|
|
|
122 |
// création des données uniques
|
|
|
123 |
$login = GenRandUsersName();
|
|
|
124 |
$passwd = GenPassword();
|
|
|
125 |
$login = da_sql_escape_string($login);
|
|
|
126 |
$passwd = da_sql_escape_string($passwd);
|
|
|
127 |
// création des variables d'impression
|
|
|
128 |
$login_imp = $login;
|
|
|
129 |
$passwd1_imp = $passwd;
|
1157 |
stephane |
130 |
// encryption du mot de passe (pas besoins, déjà présent dans le fichier create_user.php)
|
|
|
131 |
//$passwd = da_encrypt($passwd);
|
1088 |
stephane |
132 |
|
|
|
133 |
// test si l'usager existe
|
|
|
134 |
if (is_file("../lib/$config[general_lib_type]/user_info.php"))
|
|
|
135 |
include("../lib/$config[general_lib_type]/user_info.php");
|
|
|
136 |
|
|
|
137 |
if ($user_exists == "no"){
|
|
|
138 |
// Création de l'usager
|
|
|
139 |
if (is_file("../lib/$config[general_lib_type]/create_user.php"))
|
|
|
140 |
include("../lib/$config[general_lib_type]/create_user.php");
|
|
|
141 |
/* Petit traitement pré-impression pour la lisibilité */
|
|
|
142 |
/* Récupération des attributs du groupe le cas échéant */
|
|
|
143 |
if ($group!=''){
|
|
|
144 |
$saved_login = $login;
|
|
|
145 |
$login = $group;
|
|
|
146 |
if (is_file("../lib/sql/group_info.php"))
|
|
|
147 |
include("../lib/sql/group_info.php");
|
|
|
148 |
$login = $saved_login;}
|
|
|
149 |
/* Si les valeurs de durée sont vide remplissage avec la valeur 'Illimitée'*/
|
|
|
150 |
/* et formatage des secondes sous le format Heure min ses*/
|
|
|
151 |
if ($sto_imp==''){ $sto_imp=$l_unlimited;}
|
|
|
152 |
else { $sto_imp=sec_imp($sto_imp);}
|
|
|
153 |
if ($mas_imp==''){ $mas_imp=$l_unlimited;}
|
|
|
154 |
else { $mas_imp=sec_imp($mas_imp);}
|
|
|
155 |
if ($mds_imp==''){ $mds_imp=$l_unlimited;}
|
|
|
156 |
else { $mds_imp=sec_imp($mds_imp);}
|
|
|
157 |
if ($mms_imp==''){ $mms_imp=$l_unlimited;}
|
|
|
158 |
else { $mms_imp=sec_imp($mms_imp);}
|
|
|
159 |
/*Formatage de la date afin d'être lisible dans toute les langues 'jj mm yyyy'*/
|
|
|
160 |
$exp_imp = $Expiration;
|
|
|
161 |
if ($exp_imp!=''){ $exp_imp=date("d - m - Y",strtotime($exp_imp));}
|
|
|
162 |
else { $exp_imp=$l_without;}
|
|
|
163 |
// Ajout d'un ticket sur la fiche PDF
|
|
|
164 |
$pdf->newTickets();
|
|
|
165 |
$pdf->Ln(5);
|
|
|
166 |
$pdf->addInfos($l_login_imp, $login_imp);
|
|
|
167 |
$pdf->addInfos($l_password_imp, $passwd1_imp);
|
|
|
168 |
$pdf->Ln(5);
|
|
|
169 |
$pdf->addInfos($l_max_all_session_imp, $mas_imp);
|
|
|
170 |
$pdf->addInfos($l_session_timeout_imp, $sto_imp);
|
|
|
171 |
$pdf->addInfos($l_max_daily_session_imp, $mds_imp);
|
|
|
172 |
$pdf->addInfos($l_expiration_imp, $exp_imp);
|
|
|
173 |
$pdf->Ln(10);
|
|
|
174 |
$pdf->addComment($l_explain);
|
1160 |
stephane |
175 |
|
|
|
176 |
// Création du duplicata
|
|
|
177 |
$pdf->newTickets();
|
|
|
178 |
$pdf->Ln(5);
|
|
|
179 |
$pdf->addInfos($l_login_imp, $login_imp);
|
|
|
180 |
$pdf->addInfos($l_password_imp, $passwd1_imp);
|
|
|
181 |
$pdf->Ln(5);
|
|
|
182 |
$pdf->addInfos($l_max_all_session_imp, $mas_imp);
|
|
|
183 |
$pdf->addInfos($l_session_timeout_imp, $sto_imp);
|
|
|
184 |
$pdf->addInfos($l_max_daily_session_imp, $mds_imp);
|
|
|
185 |
$pdf->addInfos($l_expiration_imp, $exp_imp);
|
|
|
186 |
$pdf->Ln(10);
|
|
|
187 |
$pdf->addComment($l_duplicate,'C');//à mettre en rouge
|
1088 |
stephane |
188 |
} else {
|
|
|
189 |
$nbfailuser++;
|
|
|
190 |
}# if user
|
|
|
191 |
} # end for
|
|
|
192 |
} # end if (is file)
|
|
|
193 |
} # end if (link)
|
|
|
194 |
|
|
|
195 |
//Affichage de la fiche de tickets
|
|
|
196 |
ob_end_clean();
|
|
|
197 |
$pdf->Output();
|
1280 |
richard |
198 |
?>
|