-
Notifications
You must be signed in to change notification settings - Fork 123
/
index.php
108 lines (76 loc) · 3.14 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<!DOCTYPE html>
<?php require('config.php'); ?>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Local</title>
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="<?= $projroot ?>css/main.css">
</head>
<body>
<div class="canvas">
<header>
<h1>My Local Sites</h1>
<nav>
<ul>
<?php
foreach ( $devtools as $tool ) {
printf( '<li><a href="%1$s">%2$s</a></li>', $tool['url'], $tool['name'] );
}
?>
</ul>
</nav>
</header>
<content class="cf">
<?php
foreach ( $dir as $d ) {
$dirsplit = explode('/', $d);
$dirname = $dirsplit[count($dirsplit)-2];
printf( '<ul class="sites %1$s">', $dirname );
foreach( glob( $d ) as $file ) {
$project = basename($file);
if ( in_array( $project, $hiddensites ) ) continue;
echo '<li>';
$siteroot = sprintf( 'http://%1$s.%2$s.%3$s', $project, $dirname, $tld );
// Display an icon for the site
$icon_output = '<span class="no-img"></span>';
foreach( $icons as $icon ) {
if ( file_exists( $file . '/' . $icon ) ) {
$icon_output = sprintf( '<img src="%1$s/%2$s">', $siteroot, $icon );
break;
} // if ( file_exists( $file . '/' . $icon ) )
} // foreach( $icons as $icon )
echo $icon_output;
// Display a link to the site
$displayname = $project;
if ( array_key_exists( $project, $siteoptions ) ) {
if ( is_array( $siteoptions[$project] ) )
$displayname = array_key_exists( 'displayname', $siteoptions[$project] ) ? $siteoptions[$project]['displayname'] : $project;
else
$displayname = $siteoptions[$project];
}
printf( '<a class="site" href="%1$s">%2$s</a>', $siteroot, $displayname );
// Display an icon with a link to the admin area
$adminurl = '';
// We'll start by checking if the site looks like it's a WordPress site
if ( is_dir( $file . '/wp-admin' ) )
$adminurl = sprintf( 'http://%1$s/wp-admin', $siteroot );
// If the user has defined an adminurl for the project we'll use that instead
if (isset($siteoptions[$project]) && is_array( $siteoptions[$project] ) && array_key_exists( 'adminurl', $siteoptions[$project] ) )
$adminurl = $siteoptions[$project]['adminurl'];
// If there's an admin url then we'll show it - the icon will depend on whether it looks like WP or not
if ( ! empty( $adminurl ) )
printf( '<a class="%2$s icon" href="%1$s">Admin</a>', $adminurl, is_dir( $file . '/wp-admin' ) ? 'wp' : 'admin' );
echo '</li>';
} // foreach( glob( $d ) as $file )
echo '</ul>';
} // foreach ( $dir as $d )
?>
</content>
<footer class="cf">
<p></p>
</footer>
</div>
</body>
</html>