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