/web/acc/manager/lib/fpdf/license.txt |
---|
File deleted |
\ No newline at end of file |
Property changes: |
Deleted: svn:eol-style |
-native |
\ No newline at end of property |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/fpdf.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/font/timesbi.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/font/zapfdingbats.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/font/helveticai.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/font/helveticabi.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/font/courieri.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/font/times.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/font/courierbi.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/font/timesb.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/font/helvetica.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/font/symbol.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/font/helveticab.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/font/courier.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/font/courierb.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/font/timesi.php |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/fpdf/fpdf.css |
---|
File deleted |
Property changes: |
Deleted: svn:executable |
-* |
\ No newline at end of property |
/web/acc/manager/lib/alcasar/ticketspdf.class.php |
---|
File deleted |
\ No newline at end of file |
/web/acc/manager/lib/alcasar/TicketsGenerator.php |
---|
0,0 → 1,178 |
<?php |
/** |
* ALCASAR tickets generator |
* |
* Generate tickets of users. |
* Use wkhtmltopdf to convert HTML to PDF. |
* |
* @author Tom Houdayer |
* @copyright Copyright (C) ALCASAR (http://www.alcasar.net) |
* @license GPL-3.0 |
* @version $Id$ |
*/ |
class TicketsGenerator |
{ |
/** |
* @var string Path to wkhtmltopdf executable. |
*/ |
private $wkhtmltopdfPath = 'wkhtmltopdf'; |
/** |
* @var object[] Tickets of users. |
*/ |
private $tickets = []; |
/** |
* @var string Language of tickets. |
*/ |
private $language = 'en'; |
/** |
* @var string HTML template filename. |
*/ |
private $template = __DIR__ . '/' . 'tickets.template.php'; |
/** |
* @var string|null HTML generated filename (null if not generated). |
*/ |
private $htmlGeneratedFilename; |
/** |
* Constructor. |
* |
* @param array $options Options of the instance. |
*/ |
public function __construct($options = []) |
{ |
if (isset($options['wkhtmltopdfPath'])) { |
$this->wkhtmltopdfPath = $options['wkhtmltopdfPath']; |
} |
if (isset($options['language'])) { |
$this->language = $options['language']; |
} |
if (isset($options['template'])) { |
$this->template = $options['template']; |
} |
} |
/** |
* Add a ticket. |
* |
* @param array $user User. |
* @param bool $duplicate Print a duplicated ticket if true. |
*/ |
public function addTicket($user, $duplicate = true) |
{ |
$this->tickets[] = (object) [ |
'username' => $user['username'], |
'password' => $user['password'], |
'maxAllSession' => $user['maxAllSession'], |
'sessionTimeout' => $user['sessionTimeout'], |
'maxDailySession' => $user['maxDailySession'], |
'expiration' => ((isset($user['expiration'])) ? $user['expiration'] : '-'), |
'isDuplicate' => false |
]; |
if ($duplicate) { |
$this->tickets[] = (object) [ |
'username' => $user['username'], |
'password' => $user['password'], |
'maxAllSession' => $user['maxAllSession'], |
'sessionTimeout' => $user['sessionTimeout'], |
'maxDailySession' => $user['maxDailySession'], |
'expiration' => ((isset($user['expiration'])) ? $user['expiration'] : '-'), |
'isDuplicate' => true |
]; |
} |
} |
/** |
* Generate and save the PDF to the filesystem. |
* |
* @param string $filename File name of the generated PDF. |
* |
* @return bool Result of the convertion (true if success). |
*/ |
public function saveAs($filename) |
{ |
if (file_exists($filename)) { |
return false; |
} |
// TODO: Regex validation of $filename |
if (!$this->generateHtml("$filename.html")) { |
return false; |
} |
$command = $this->wkhtmltopdfPath . ' --quiet --disable-smart-shrinking --footer-font-size 8 --footer-left "ALCASAR" --footer-center "[page] / [toPage]" --footer-right "' . date('Y-m-d H:i:s') . '" ' . escapeshellarg("$filename.html") . ' ' . escapeshellarg($filename); |
$output; |
$exitCode; |
exec($command, $output, $exitCode); |
unlink("$filename.html"); |
if ($exitCode !== 0) { |
return false; |
} |
return true; |
} |
/** |
* Send the PDF to the browser. |
* |
* @return bool Result of the convertion (true if success). |
*/ |
public function output() |
{ |
$filename = tempnam('/tmp', 'ALCASAR-PDF_'); |
unlink($filename); |
if (!$this->saveAs($filename)) { |
return false; |
} |
header('Content-Type: application/pdf'); |
header('Content-Disposition: inline; filename="tickets.pdf"'); |
header('Cache-Control: private, max-age=0, must-revalidate'); |
header('Pragma: public'); |
readfile($filename); |
unlink($filename); |
return true; |
} |
/** |
* Generate HTML document from the template. |
* |
* @param string $output File name of the generated template. |
* |
* @return bool Result of the generation (true if success). |
*/ |
private function generateHtml($output) |
{ |
if (file_exists($output)) { |
return false; |
} |
if (!file_exists($this->template)) { |
return false; |
} |
$language = $this->language; |
$users = $this->tickets; |
ob_start(); |
require($this->template); |
$content = ob_get_clean(); |
$ret = file_put_contents($output, $content); |
if ($ret === false) { |
return false; |
} |
return true; |
} |
} |
Property changes: |
Added: svn:keywords |
+Id |
\ No newline at end of property |
/web/acc/manager/lib/alcasar/tickets.template.php |
---|
0,0 → 1,134 |
<?php |
/** |
* Tickets template for TicketsGenerator |
* |
* @author Tom Houdayer |
* @copyright Copyright (C) ALCASAR (http://www.alcasar.net) |
* @license GPL-3.0 |
* @version $Id$ |
*/ |
$langue_imp = $language; |
require __DIR__ . '/../langues_imp.php'; |
$img_logoAlcasar = __DIR__ . '/../../../../images/logo-alcasar.png'; |
$img_logoOrganization = __DIR__ . '/../../../../images/organisme.png'; |
?> |
<!doctype html> |
<html> |
<head> |
<meta charset="utf-8"> |
<style> |
body { |
margin: 0; |
} |
.ticket { |
margin: 20px 0; |
width: 50%; |
display: inline-block; |
font-family: Arial; |
font-size: 10px; |
line-height: 20px; |
} |
.ticket-header { |
min-height: 40px; |
line-height: 40px; |
font-size: 12px; |
text-align: center; |
} |
.ticket-header > .ticket-title { |
color: red; |
font-weight: bold; |
} |
.ticket-box { |
position: relative; |
border: 1px solid black; |
border-radius: 10px; |
width: 275px; |
margin: 0 auto; |
} |
.ticket-box > .logo { |
position: absolute; |
display: inline-block; |
width: 80px; |
height: 80px; |
text-align: center; |
} |
.ticket-box > .logo img { |
max-width: 100%; |
max-height: 100%; |
} |
.ticket-box > .logo-alcasar { |
top: -40px; |
left: -40px; |
} |
.ticket-box > .logo-organization { |
top: -40px; |
right: -40px; |
} |
.ticket-body { |
position: relative; |
z-index: 10; |
padding: 5px; |
} |
.ticket-body > div > span { |
display: inline-block; |
} |
.ticket-body > div.spacer { |
height: 12px; |
} |
.ticket-body > div > span.key { |
width: 50%; |
text-align: right; |
} |
.ticket-body > div > span.value { |
width: 50%; |
font-weight: bold; |
} |
.ticket-footer > .infos { |
font-size: 9px; |
height: 70px; |
} |
.center { |
text-align: center; |
} |
</style> |
</head> |
<body> |
<?php foreach ($users as $user): |
?><div class="ticket"> |
<div class="ticket-header"> |
<span class="ticket-title"><?= $l_title_imp ?></span> |
</div> |
<div class="ticket-box"> |
<div class="logo logo-alcasar"><img src="<?= $img_logoAlcasar ?>" alt=""></div> |
<div class="logo logo-organization"><img src="<?= $img_logoOrganization ?>" alt=""></div> |
<div class="ticket-body"> |
<div class="spacer"></div> |
<div><span class="key"><?= $l_login_imp ?> </span><span class="value"><?= $user->username ?></span></div> |
<div><span class="key"><?= $l_password_imp ?> </span><span class="value"><?= $user->password ?></span></div> |
<div class="spacer"></div> |
<div><span class="key"><?= $l_max_all_session_imp ?> </span><span class="value"><?= $user->maxAllSession ?></span></div> |
<div><span class="key"><?= $l_session_timeout_imp ?> </span><span class="value"><?= $user->sessionTimeout ?></span></div> |
<div><span class="key"><?= $l_max_daily_session_imp ?> </span><span class="value"><?= $user->maxDailySession ?></span></div> |
<div><span class="key"><?= $l_expiration_imp ?> </span><span class="value"><?= $user->expiration ?></span></div> |
<div class="spacer"></div> |
</div> |
</div> |
<div class="ticket-footer"> |
<?php if ($user->isDuplicate): ?> |
<div class="infos center"> |
<p><?= $l_duplicate ?></p> |
</div> |
<?php else: ?> |
<div class="infos"> |
<p><?= nl2br($l_explain, false) ?></p> |
</div> |
<?php endif; ?> |
<div class="credits center"><?= $l_footer_imp ?></div> |
</div> |
</div><?php |
endforeach; ?> |
</body> |
</html> |
Property changes: |
Added: svn:keywords |
+Id |
\ No newline at end of property |
/web/acc/manager/lib/langues_imp.php |
---|
1,27 → 1,35 |
<?php |
/******************* |
* READ CONF FILE * |
********************/ |
$CONF_FILE="/usr/local/etc/alcasar.conf"; |
/** |
* Translations of users tickets |
* |
* @copyright Copyright (C) ALCASAR (http://www.alcasar.net) |
* @license GPL-3.0 |
* @version $Id$ |
*/ |
// Read conf file |
$CONF_FILE = '/usr/local/etc/alcasar.conf'; |
if (!file_exists($CONF_FILE)){ |
exit("Requested file ".$CONF_FILE." isn't present");} |
exit("Requested file $CONF_FILE isn't present"); |
} |
if (!is_readable($CONF_FILE)){ |
exit("Can't read the file ".$CONF_FILE);} |
$ouvre=fopen($CONF_FILE,"r"); |
exit("Can't read the file $CONF_FILE"); |
} |
$ouvre = fopen($CONF_FILE, 'r'); |
if ($ouvre){ |
while (!feof ($ouvre)) |
{ |
while (!feof($ouvre)) { |
$tampon = fgets($ouvre, 4096); |
if (strpos($tampon,"=")!==false){ |
$tmp = explode("=",$tampon); |
if (strpos($tampon, '=') !== false) { |
$tmp = explode('=', $tampon); |
$conf[$tmp[0]] = $tmp[1]; |
} |
} |
fclose($ouvre); |
} |
//Langue du Ticket d'impression en fonction de la liste déroulante |
// Translations |
switch ($langue_imp){ |
case 'fr': |
case 'fr': // French |
$l_title_imp = "TICKET D'ACCÈS"; |
$l_login_imp = "Utilisateur :"; |
$l_password_imp = "Mot de passe :"; |
37,7 → 45,8 |
Entrer 'http://logout' dans votre navigateur pour vous déconnecter."; |
$l_footer_imp = "Généré par ALCASAR"; |
break; |
case 'de': |
case 'de': // German |
$l_title_imp = "ZUGANG TICKET"; |
$l_login_imp = "Login :"; |
$l_password_imp = "Passwort :"; |
50,11 → 59,11 |
$l_without="Ohne"; |
$l_duplicate="Duplikat"; |
$l_explain = "Geben Sie 'http://".trim($conf["HOSTNAME"]).".".trim($conf["DOMAIN"])."' in Ihrem Browser, um Ihr Konto zu verwalten (kennwort, zertifikat, etc.). |
Geben Sie 'http://logout' in Ihrem Browser zu trennen. |
"; |
Geben Sie 'http://logout' in Ihrem Browser zu trennen."; |
$l_footer_imp = "Präsentiert von ALCASAR"; |
break; |
case 'nl': |
case 'nl': // Dutch |
$l_title_imp = "TOERANG TICKET"; |
$l_login_imp = "Gebruikers :"; |
$l_password_imp = "Wachtwoord :"; |
70,7 → 79,8 |
Voer 'http://logout' in uw browser de verbinding te verbreken."; |
$l_footer_imp = "Powered by ALCASAR"; |
break; |
case 'es': |
case 'es': // Spanish |
$l_title_imp = "TURISTICA ACCESO"; |
$l_login_imp = "Usuario :"; |
$l_password_imp = "Contraseña :"; |
86,7 → 96,8 |
Escribe 'http://logout' de su navegador para desconectar."; |
$l_footer_imp = "Desarrollado por ALCASAR"; |
break; |
case 'it': |
case 'it': // Italian |
$l_title_imp = "TICKET D'ACCESSO"; |
$l_login_imp = "Utenti :"; |
$l_password_imp = "Password :"; |
102,12 → 113,13 |
Inserisci 'http://logout' nel tuo browser per disconnettersi."; |
$l_footer_imp = "Powered by ALCASAR"; |
break; |
case 'pt': |
case 'pt': // Portuguese |
$l_title_imp = "BILHETE DE ACESSO"; |
$l_login_imp = "Usuário :"; |
$l_password_imp = "Senha :"; |
$l_max_all_session_imp="Período autorizado :"; |
$l_session_timeout_imp="duração de uma sessão :"; |
$l_session_timeout_imp = "Duração de uma sessão :"; |
$l_max_daily_session_imp="Duração diária :"; |
$l_max_monthly_session_imp ="Duração Mensal :"; |
$l_expiration_imp="Data de validade :"; |
118,7 → 130,8 |
Digite 'http://logout' no seu navegador para desligar."; |
$l_footer_imp = "Desenvolvido por ALCASAR"; |
break; |
case 'ar': |
case 'ar': // Arabic |
$l_title_imp = "وصول التذاكر"; |
$l_login_imp = "مستخدم:"; |
$l_password_imp = "كلمه السر:"; |
130,12 → 143,11 |
$l_unlimited = "غير محدود:"; |
$l_without = "بدون"; |
$l_duplicate = "مكرر"; |
$l_explain_url_conn = "http://". trim($conf["HOSTNAME"]) . "." . trim($conf["DOMAIN"]); |
$l_explain_url_logout = "http://logout"; |
$l_explain = " في المتصفح الخاص بك لخروج." . $l_explain_url_logout . "في المستعرض الخاص بك لإدارة حسابك (كلمه السر, شهادة, ...). يكتب " . $l_explain_url . "يكتب"; |
$l_explain = " في المتصفح الخاص بك لخروج.'http://logout' في المستعرض الخاص بك لإدارة حسابك (كلمه السر, شهادة, ...). يكتب 'http://".trim($conf["HOSTNAME"]).".".trim($conf["DOMAIN"])."' يكتب"; |
$l_footer_imp = "مشغل بواسطة ALCASAR"; |
break; |
default: |
default: // English |
$l_title_imp = "ACCESS TICKET"; |
$l_login_imp = "Login :"; |
$l_password_imp = "Password :"; |
152,4 → 164,3 |
$l_footer_imp = "Powered by ALCASAR"; |
break; |
} |
?> |
Property changes: |
Added: svn:keywords |
+Id |
\ No newline at end of property |