Alternc  latest
Alternc logiel libre pour l'hébergement
ssl_view.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  AlternC - Web Hosting System
5  Copyright (C) 2002 by the AlternC Development Team.
6  http://alternc.org/
7  ----------------------------------------------------------------------
8  LICENSE
9 
10  This program is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License (GPL)
12  as published by the Free Software Foundation; either version 2
13  of the License, or (at your option) any later version.
14 
15  This program is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  To read the license please visit http://www.gnu.org/copyleft/gpl.html
21  ----------------------------------------------------------------------
22  Original Author of file: Benjamin Sonntag
23  Purpose of file: Create / Import an SSL Certificate
24  ----------------------------------------------------------------------
25  */
26 require_once("../class/config.php");
27 
28 if (!isset($is_include)) {
29  $fields = array(
30  "id" => array("request", "integer", ""),
31  );
33 }
34 
35 $cert = $ssl->get_certificate($id);
36 $error = $err->errstr();
37 if ($error) {
38  require_once("ssl_list.php");
39  exit();
40 }
41 
42 include_once("head.php");
43 
44 if ($info) {
45  echo "<p class=\"alert alert-info\">$info</p>";
46 }
47 
48 if ($cert["status"] == $ssl::STATUS_PENDING) {
49  ?>
50  <h3><?php __("Pending Certificate"); ?></h3>
51 
52  <p><?php __("Your <i>Certificate Request File</i> (CSR) has been created, along with its <i>private RSA Key</i> (KEY). Please find below the CSR you must send to your SSL Certificate provider."); ?></p>
53 
54  <p><?php __("Once you'll have your <i>Certificate File</i> (CRT) and a <i>Chained Certificate File</i> (CHAIN), please paste them here to finish the enrollment."); ?></p>
55 
56  <form method="post" action="ssl_finalize.php" name="main" id="main">
57 <?php csrf_get(); ?>
58  <input type="hidden" name="id" id="id" value="<?php echo $cert["id"]; ?>"/>
59  <table border="1" cellspacing="0" cellpadding="4" class="tedit">
60  <tr>
61  <th><label for="fqdn"><?php __("Fully Qualified Domain Name"); ?></label></th>
62  <td><?php echo $cert["fqdn"]; ?></td>
63  </tr>
64  <tr>
65  <th><label for="validstart"><?php __("Date of the request"); ?></label></th>
66  <td><?php echo format_date(_('%3$d-%2$d-%1$d %4$d:%5$d'), date("Y-m-d H:i:s", $cert["validstartts"])); ?></td>
67  </tr>
68  <tr>
69  <th><label for="csr"><?php __("Certificate Request File"); ?></label></th>
70  <td><textarea readonly="readonly" onclick="this.focus();
71  this.select()" class="int cert" name="csr" id="csr" style="width: 500px; height: 120px;"><?php echo $cert["sslcsr"]; ?></textarea></td>
72  </tr>
73  <tr>
74  <th><label for="crt"><?php __("SSL Certificate"); ?></label></th>
75  <td><textarea class="int cert" name="crt" id="crt" style="width: 500px; height: 120px;"><?php echo $cert["sslcrt"]; ?></textarea></td>
76  </tr>
77  <tr>
78  <th><label for="chain"><?php __("Chained Certificate<br />(not mandatory)"); ?></label></th>
79  <td><textarea class="int cert" name="chain" id="chain" style="width: 500px; height: 120px;"><?php echo $cert["sslchain"]; ?></textarea></td>
80  </tr>
81  </table>
82  <p>
83  <input type="submit" class="inb ok" name="submit" value="<?php __("Save"); ?>"/> &nbsp;
84  <input type="button" class="inb cancel" name="cancel" value="<?php __("Cancel"); ?>" onclick="document.location = 'ssl_list.php'"/>
85  </p><p>
86  <input type="submit" class="inb delete" name="delete" value="<?php __("Delete"); ?>" onclick="return confirm('<?php
87  echo addslashes(_("Please confirm that you want to delete this certificate request AND ITS PRIVATE KEY!"));
88  ?>');"/>
89 
90  </p>
91  </form>
92 
93  <?php
94 } else {
95 
96  if ($cert["status"] == $ssl::STATUS_OK) {
97  ?>
98  <h3><?php __("Valid Certificate"); ?></h3>
99  <p><?php __("Please find below your valid certificate data."); ?></p>
100 
101  <?php
102  }
103  if ($cert["status"] == $ssl::STATUS_EXPIRED) {
104  ?>
105  <h3><?php __("EXPIRED Certificate"); ?></h3>
106  <p><?php __("Your certificate is EXPIRED. You should not use it for any purpose. Please find below its data."); ?></p>
107 
108  <?php
109  }
110  ?>
111  <p>
112  <span class="inb ok"><a href="ssl_list.php"><?php __("Back to my SSL Certificates"); ?></a></span>
113  </p>
114  <table border="1" cellspacing="0" cellpadding="4" class="tedit">
115  <tr>
116  <th><?php __("Valid From:"); ?></th>
117  <td><?php
118  echo format_date(_('%3$d-%2$d-%1$d %4$d:%5$d'), date("Y-m-d H:i:s", $cert["validstartts"]));
119  echo " ";
120  $days = intval((time() - $cert["validstartts"]) / 86400);
121  if ($days < 60) {
122  printf(_("(%d days ago)"), $days);
123  } else {
124  $month = intval($days / 30);
125  printf(_("(%d month ago)"), $month);
126  }
127  ?></td>
128  </tr>
129  <tr>
130  <th><?php __("Valid Until:"); ?></th>
131  <td><?php
132  echo format_date(_('%3$d-%2$d-%1$d %4$d:%5$d'), date("Y-m-d H:i:s", $cert["validendts"]));
133  echo " ";
134  $days = intval(($cert["validendts"] - time()) / 86400);
135  if ($days < 60) {
136  printf(_("(%d days from now)"), $days);
137  } else {
138  $month = intval($days / 30);
139  printf(_("(%d month from now)"), $month);
140  }
141  ?></td>
142  </tr>
143  <tr>
144  <th><?php __("FQDN:"); ?></th>
145  <td><?php echo $cert["fqdn"]; ?></td>
146  </tr>
147  <tr>
148  <th><?php __("Other Valid FQDN:"); ?></th>
149  <td><?php echo nl2br($cert["altnames"]); ?></td>
150  </tr>
151 
152  <tr>
153  <th><label for="csr"><?php __("Certificate Request File"); ?></label></th>
154  <td><textarea readonly="readonly" onclick="this.focus();
155  this.select()" class="int cert" name="csr" id="csr" style="width: 500px; height: 120px;"><?php echo $cert["sslcsr"]; ?></textarea></td>
156  </tr>
157  <tr>
158  <th><label for="crt"><?php __("SSL Certificate"); ?></label></th>
159  <td><textarea readonly="readonly" onclick="this.focus();
160  this.select()" class="int cert" name="crt" id="crt" style="width: 500px; height: 120px;"><?php echo $cert["sslcrt"]; ?></textarea></td>
161  </tr>
162  <tr>
163  <th><label for="chain"><?php __("Chained Certificate<br />(not mandatory)"); ?></label></th>
164  <td><textarea readonly="readonly" onclick="this.focus();
165  this.select()" class="int cert" name="chain" id="chain" style="width: 500px; height: 120px;"><?php echo $cert["sslchain"]; ?></textarea></td>
166  </tr>
167  </table>
168  <?php
169 // The admin is allowed to share (or not share) his valid certificates
170  if ($admin->enabled) {
171  ?>
172  <p><?php __("As an administrator you can allow any account on this server to use this certificate to host his services. <br />(This is only useful for wildcard or multi-domain certificates)."); ?></p>
173  <p>
174  <?php
175  if ($cert["shared"]) {
176  echo _("This certificate is currently <b>shared</b>");
177  if ($cert["uid"] == $cuid) {
178  ?>
179  </p>
180  <form method="post" action="ssl_share.php">
181 <?php csrf_get(); ?>
182  <input type="hidden" name="id" id="id" value="<?php echo $cert["id"]; ?>"/>
183  <input type="hidden" name="action" id="action" value="0" />
184  <input class="inb cancel" type="submit" name="unshare" value="<?php __("Click here to stop sharing this certificate"); ?>" />
185  </form>
186  <?php
187  } else {
188  ?>
189  <p><?php __("You are not the owner of this certificate, only its owner can share/unshare this certificate."); ?></p>
190  <?php
191  }
192  } else {
193  echo _("This certificate is currently <b>NOT shared</b>");
194  if ($cert["uid"] == $cuid) {
195  ?>
196  </p>
197  <form method="post" action="ssl_share.php">
198 <?php csrf_get(); ?>
199  <input type="hidden" name="id" id="id" value="<?php echo $cert["id"]; ?>"/>
200  <input type="hidden" name="action" id="action" value="1" />
201  <input class="inb ok" type="submit" name="unshare" value="<?php __("Click here to share this certificate"); ?>" />
202  </form>
203  <?php
204  } else {
205  ?>
206  <p><?php __("You are not the owner of this certificate, only its owner can share/unshare this certificate."); ?></p>
207  <?php
208  }
209  }
210  }
211  if ($cert["uid"] == $cuid) {
212  ?>
213  <p>
214  <form method="post" action="ssl_finalize.php" name="main" id="main">
215 <?php csrf_get(); ?>
216  <input type="hidden" name="id" id="id" value="<?php echo $cert["id"]; ?>"/>
217  <input type="submit" class="inb delete" name="delete" value="<?php __("Delete"); ?>" onclick="return confirm('<?php
218  echo addslashes(_("Please confirm that you want to delete this certificate AND ITS PRIVATE KEY!"));
219  ?>');"/>
220  </form>
221  </p>
222  <?php
223  }
224 } // pending or OK ?
225 
226 ?>
227 
228 
229 
230 <?php include_once("foot.php"); ?>
exit
Definition: adm_doadd.php:70
$err
Definition: bootstrap.php:72
$cuid
Definition: bootstrap.php:43
$fields
Definition: aws_add.php:27
format_date($format, $date)
Definition: functions.php:494
__($str)
Definition: functions.php:404
getFields($fields, $requestOnly=false)
Get the Fields of the posted form from $_REQUEST or POST or GET and check their type.
Definition: functions.php:688
csrf_get($return=false)
Give a new CSRF uniq token for a form the session must be up since the CSRF is linked to the session ...
Definition: functions.php:1159
if(!isset($is_include)) if(! $key &&! $crt) $id
if($error) $is_include
Definition: ssl_donew.php:55
if($error) $info
$days
Definition: ssl_view.php:120
$error
Definition: ssl_view.php:36
if(!isset($is_include)) $cert
Definition: ssl_view.php:35