devilbox/.devilbox/www/htdocs/vhosts.php

107 lines
3.0 KiB
PHP
Raw Normal View History

2016-10-09 16:47:49 +00:00
<?php require '../config.php'; ?>
2017-04-19 17:48:44 +00:00
<?php $Docker = loadClass('Docker'); ?>
2016-10-09 16:47:49 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
2016-10-22 14:39:08 +00:00
<?php require '../include/head.php'; ?>
2016-10-09 16:47:49 +00:00
</head>
<body>
2016-11-15 18:39:11 +00:00
<?php require '../include/navbar.php'; ?>
2016-10-09 16:47:49 +00:00
<div class="container">
<h1>Virtual Hosts</h1>
2016-10-22 17:07:09 +00:00
<br/>
<br/>
2016-10-09 16:47:49 +00:00
<div class="row">
<div class="col-md-12">
2016-11-06 12:36:07 +00:00
<?php $vHosts = $Docker->PHP_getVirtualHosts(); ?>
2016-10-09 16:47:49 +00:00
<?php if ($vHosts): ?>
2016-10-22 15:38:21 +00:00
<table class="table table-striped">
2016-10-22 14:39:08 +00:00
<thead class="thead-inverse">
2016-10-09 16:47:49 +00:00
<tr>
<th>Project</th>
<th>DocumentRoot</th>
<th>Valid</th>
<th>URL</th>
</th>
</thead>
<tbody>
<?php
$totals = 70;
$filler = '&nbsp;';
for ($i=0; $i<$totals; $i++) {
$filler = $filler. '&nbsp;';
}
?>
2016-10-09 16:47:49 +00:00
<?php foreach ($vHosts as $vHost): ?>
<tr>
<td><?php echo $vHost['name'];?></td>
2016-11-06 12:36:07 +00:00
<td><?php echo $Docker->getEnv('HOST_PATH_TO_WWW_DOCROOTS');?>/<?php echo $vHost['name'];?>/htdocs</td>
2016-10-22 14:39:08 +00:00
<td class="text-xs-center text-xs-small" id="valid-<?php echo $vHost['name'];?>">&nbsp;&nbsp;&nbsp;</td>
<td id="href-<?php echo $vHost['name'];?>"><?php echo $filler;?></td>
2016-10-09 16:47:49 +00:00
</tr>
<input type="hidden" name="vhost[]" class="vhost" value="<?php echo $vHost['name'];?>" />
2016-10-09 16:47:49 +00:00
<?php endforeach; ?>
</tbody>
</table>
<?php else: ?>
<h4>No projects here.</h4>
2016-11-06 12:36:07 +00:00
<p>Simply create a folder in <strong><?php echo $Docker->getEnv('HOST_PATH_TO_WWW_DOCROOTS');?></strong> (on your host computer - not inside the docker).</p>
<p><strong>Example:</strong><br/><?php echo $Docker->getEnv('HOST_PATH_TO_WWW_DOCROOTS');?>/my_project</p>
2016-10-09 16:47:49 +00:00
<?php endif;?>
</div>
</div>
</div><!-- /.container -->
<?php require '../include/footer.php'; ?>
<script>
// self executing function here
(function() {
// your page initialization code here
// the DOM will be available here
function updateStatus(vhost) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
var error = '';
var el_valid;
var el_href;
if (this.readyState == 4 && this.status == 200) {
el_valid = document.getElementById('valid-' + vhost);
el_href = document.getElementById('href-' + vhost);
error = this.responseText;
if (error.length) {
2016-10-22 14:39:08 +00:00
el_valid.className += ' bg-danger';
el_valid.innerHTML = 'ERR';
el_href.innerHTML = error;
} else {
2016-10-22 14:39:08 +00:00
el_valid.className += ' bg-success';
el_valid.innerHTML = 'OK';
el_href.innerHTML = '<a target="_blank" href="http://'+vhost+'.<?php echo $Docker->getTld().$Docker->getPort();?>">'+vhost+'.<?php echo $Docker->getTld().$Docker->getPort();?></a>';
}
}
};
2016-11-15 18:39:11 +00:00
xhttp.open('GET', '_ajax_callback.php?vhost=' + vhost, true);
xhttp.send();
}
var vhosts = document.getElementsByName('vhost[]');
for (i = 0; i < vhosts.length; i++) {
updateStatus(vhosts[i].value);
}
})();
</script>
2016-10-09 16:47:49 +00:00
</body>
</html>