|
15 | 15 | use Spipu\Html2Pdf\Exception\Html2PdfException; |
16 | 16 | use Spipu\Html2Pdf\Exception\ExceptionFormatter; |
17 | 17 |
|
18 | | -if (isset($_SERVER['REQUEST_URI'])) { |
19 | | - $generate = isset($_GET['make_pdf']); |
20 | | - $nom = isset($_GET['nom']) ? $_GET['nom'] : 'inconnu'; |
21 | | - $url = dirname($_SERVER['REQUEST_URI']); |
22 | | - if (substr($url, 0, 7)!=='http://') { |
23 | | - $url = 'http://'.$_SERVER['HTTP_HOST'].$url; |
24 | | - } |
25 | | -} else { |
| 18 | +$name = 'spipu'; |
| 19 | +$generate = false; |
| 20 | + |
| 21 | +if (isset($_GET['nom'])) { |
| 22 | + $generate = true; |
| 23 | + $name = $_GET['nom']; |
| 24 | + $name = preg_replace('/[^a-zA-Z0-9]/isU', '', $name); |
| 25 | + $name = substr($name, 0, 26); |
| 26 | +} else if (!isset($_SERVER['REQUEST_URI'])) { |
26 | 27 | $generate = true; |
27 | | - $nom = 'spipu'; |
28 | | - $url = 'http://localhost/html2pdf/examples/'; |
29 | 28 | } |
30 | 29 |
|
31 | | -$nom = substr(preg_replace('/[^a-zA-Z0-9]/isU', '', $nom), 0, 26); |
32 | | -$url.= '/res/example09.png.php?px=5&py=20'; |
33 | | - |
34 | | - |
35 | 30 | if ($generate) { |
36 | 31 | ob_start(); |
37 | 32 | } else { |
|
49 | 44 | <br> |
50 | 45 | Ceci est un exemple de génération de PDF via un bouton :)<br> |
51 | 46 | <br> |
52 | | -<img src="<?php echo $url; ?>" alt="image_php" ><br> |
| 47 | +<img src="http://html2pdf-dev.lxd/res/example09.png.php?px=5&py=20" alt="image_php" ><br> |
53 | 48 | <br> |
54 | 49 | <?php |
55 | 50 | if ($generate) { |
56 | 51 | ?> |
57 | | -Bonjour <b><?php echo $nom; ?></b>, ton nom peut s'écrire : <br> |
58 | | -<barcode type="C39" value="<?php echo strtoupper($nom); ?>" style="color: #770000" ></barcode><hr> |
| 52 | +Bonjour <b><?php echo $name; ?></b>, ton nom peut s'écrire : <br> |
| 53 | +<barcode type="C39" value="<?php echo strtoupper($name); ?>" style="color: #770000" ></barcode><hr> |
59 | 54 | <br> |
60 | 55 | <?php |
61 | 56 | } |
|
0 commit comments