Skip to content

Instantly share code, notes, and snippets.

@morvy
Last active April 7, 2019 10:29
Show Gist options
  • Save morvy/16a9bcba5543d44cc3453dceb1725494 to your computer and use it in GitHub Desktop.
Save morvy/16a9bcba5543d44cc3453dceb1725494 to your computer and use it in GitHub Desktop.
Laragon.org enhanced "homepage"
<?php
if (!empty($_GET['q'])) {
switch ($_GET['q']) {
case 'info':
phpinfo();
exit;
break;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Laragon</title>
<link href="https://fonts.googleapis.com/css?family=Karla:400" rel="stylesheet" type="text/css">
<style>
html, body {
height: 100%;
}
body {
margin: 0;
padding: 0;
width: 100%;
display: table;
font-weight: 100;
font-family: 'Karla';
}
.container {
text-align: center;
display: table-cell;
vertical-align: middle;
}
.content {
text-align: center;
display: inline-block;
}
.title {
font-size: 96px;
}
.opt {
margin-top: 30px;
}
.opt a {
text-decoration: none;
font-size: 150%;
}
a:hover {
color: red;
}
.sites {
display: grid;
grid-template-columns: 275px 275px 275px 275px;
grid-gap: 24px;
}
.sites li {
display: block;
background: #fff;
box-shadow: 0 0 10px 0 #ccc;
height: 48px;
line-height: 48px;
width: 275px;
text-align: left;
transition: box-shadow 250ms ease-in-out;
}
.sites li:hover {
box-shadow: 0 0 15px 0 #bbb;
}
.sites li:hover svg {
fill: #999;
}
.sites li:hover a {
color: #666;
}
.sites li a {
display: block;
padding-left: 48px;
color: #999;
transition: color 250ms ease-in-out;
}
.sites img,
.sites svg {
position: absolute;
margin: 8px;
margin-left: -40px;
fill: #ccc;
transition: fill 250ms ease-in-out;
}
</style>
</head>
<body>
<div class="container">
<div class="content">
<div class="title" title="Laragon">Laragon</div>
<div class="info"><br />
<?php print($_SERVER['SERVER_SOFTWARE']); ?><br />
PHP version: <?php print phpversion(); ?> <span><a title="phpinfo()" href="/?q=info">info</a></span><br />
Document Root: <?php print ($_SERVER['DOCUMENT_ROOT']); ?><br />
<?php
error_reporting(0);
$cfgarray = file('../usr/laragon.ini', FILE_SKIP_EMPTY_LINES);
foreach($cfgarray as $line) {
if(strpos($line, '=')) {
$value = explode('=', $line);
$laraconfig[$value[0]] = trim($value[1]);
}
}
$link = mysqli_connect('localhost', 'root', $laraconfig['MySQLRootPassword']);
if(!$link) $link = mysqli_connect('localhost', 'root', '');
if (!$link) {
echo 'MySQL not running!';
} else {
printf("MySQL server version: %s\n", mysqli_get_server_info($link));
}
?><br />
</div>
<div class="opt">
<?php
$folders = array_filter(glob('*'), 'is_dir');
if($laraconfig['SSLEnabled'] == 0 || $laraconfig['Port'] == 80) $url = 'http';
else $url = 'https';
echo '<ul class="sites">';
foreach($folders as $host) {
if(file_exists($host.'/favicon.png')) $favicon = '<img src="./'.$host.'/favicon.png" width="32" height="32"/>';
elseif(file_exists($host.'/favicon.ico')) $favicon = '<img src="./'.$host.'/favicon.ico" width="32" height="32"/>';
else $favicon = '<svg width="32px" height="32px" viewBox="0 0 19 19" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:1.41421;"><path d="M6.073,1.44l-1.206,1.206l6.853,6.854l-6.853,6.852l1.206,1.207l8.06,-8.059l-8.06,-8.06Z" style="fill-rule:nonzero;"/></svg>';
echo '<li><a href="'. $url .'://'. str_replace('{name}', $host, $laraconfig['HostnameFormat']). '">'.$favicon.' '.$host.'</a></li>';
}
echo '</ul>';
?>
</div>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment