Skip to content

Commit d0157f3

Browse files
committed
Inital Commit
0 parents  commit d0157f3

13 files changed

+540
-0
lines changed

README

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Requirements:
2+
3+
A HTTP Server (Apache or nginx etc)
4+
An instance of PHP
5+
6+
Run setup.php after uploading to your Raspberry Pi.
7+
8+
Login with:
9+
Username: admin
10+
Password: admin

app/classes/_hdd.php

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
class hddPercentage {
3+
function freeStorage(){
4+
echo "<div style='float:left'>SD Card:";
5+
6+
7+
$bytes = disk_free_space(".");
8+
$si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
9+
$base = 1024;
10+
$class = min((int)log($bytes , $base) , count($si_prefix) - 1);
11+
$free = sprintf('%1.2f' , $bytes / pow($base,$class));
12+
13+
14+
15+
$bytes = disk_total_space(".");
16+
$si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
17+
$base = 1024;
18+
$class = min((int)log($bytes , $base) , count($si_prefix) - 1);
19+
$total = sprintf('%1.2f' , $bytes / pow($base,$class));
20+
21+
22+
23+
$used = $total - $free;
24+
$percentage = round($used / $total * 100);
25+
echo '<br/><div class="graph"><strong class="barGreen" style="width:'.$percentage.'%;">'.$percentage.'%</strong></div> &nbsp; &nbsp; <div class="clear"></div>';
26+
echo "<br/>Total: <strong>".$total."</strong> GB &middot ";
27+
echo "Free: <strong>".$free."</strong> GB";
28+
echo "</div>";
29+
30+
31+
}
32+
}
33+
?>

app/classes/_login.php

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php session_start();
2+
3+
if(isset($_POST['login'])){
4+
5+
$handle = file_get_contents("/etc/raspcontrol/database.aptmnt");
6+
$db = json_decode($handle);
7+
$username = $db->{'user'};
8+
$password = $db->{'password'};
9+
10+
if($_POST['username'] == $username && $_POST['password'] == $password){
11+
12+
$_SESSION['username'] = $username; ?>
13+
14+
<script type="text/javascript">
15+
<!--
16+
window.location = "main.php"
17+
//-->
18+
</script>
19+
20+
<?php
21+
22+
}else{
23+
24+
$wrong = 1;
25+
26+
}
27+
28+
}
29+
30+
?>

app/classes/_ram.php

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
class ramPercentage {
3+
function freeMemory(){
4+
echo "<div style='float:left'>Memory:";
5+
exec('free -mo', $out);
6+
preg_match_all('/\s+([0-9]+)/', $out[1], $matches);
7+
list($total, $used, $free, $shared, $buffers, $cached) = $matches[1];
8+
9+
$percentage = round($used / $total * 100);
10+
11+
if($percentage > '80'){
12+
echo '<br/><div class="graph"><strong class="barAmber" style="width:'.$percentage.'%;">'.$percentage.'%</strong></div> &nbsp; &nbsp; <div class="clear"></div>';
13+
}else{
14+
echo '<br/><div class="graph"><strong class="barGreen" style="width:'.$percentage.'%;">'.$percentage.'%</strong></div> &nbsp; &nbsp; <div class="clear"></div>';
15+
}
16+
17+
echo "<br/>Free: <strong>".$free." MB</strong> Used: <strong>" . $used . " MB</strong> &middot Total: <strong>" . $total." MB</strong><br/></div>";
18+
19+
}
20+
21+
function freeSwap(){
22+
echo "<div style='margin-left: 30px; float:left'>Swap:";
23+
exec('free -mo', $out);
24+
preg_match_all('/\s+([0-9]+)/', $out[2], $matches);
25+
list($total, $used, $free) = $matches[1];
26+
27+
$percentage = round($used / $total * 100);
28+
29+
echo '<br/><div class="graph"><strong class="barGreen" style="width:'.$percentage.'%;">'.$percentage.'%</strong></div> &nbsp; &nbsp; <div class="clear"></div>';
30+
31+
echo "<br/>Free: <strong>".$free." MB</strong> Used: <strong>" . $used . " MB</strong> &middot Total: <strong>" . $total." MB</strong><br/></div>";
32+
33+
}
34+
}
35+
36+
?>

app/commands/_reboot.php

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
system('sudo reboot');
3+
?>
4+
5+
<center> Your Raspberry Pi is now rebooting! </center>

app/commands/_updatesources.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
echo '<pre>';
3+
4+
// Outputs all the result of shellcommand "ls", and returns
5+
// the last output line into $last_line. Stores the return value
6+
// of the shell command in $retval.
7+
$last_line = system('sudo apt-get update', $retval);
8+
9+
// Printing additional info
10+
echo '
11+
</pre>'; ?>
12+
Source Update Complete!

app/images/bargraph.gif

222 Bytes
Loading

app/includes/_footer.php

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div id="footerContainer">
2+
<div class="footerWrapper">
3+
Powered by Raspcontrol &middot; <a href="http://fusionstrike.com">Fusion Strike</a>.
4+
</div>
5+
</div>
6+
</body>
7+
</html>

app/includes/_header.php

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php session_start(); ?>
2+
3+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
4+
5+
<html>
6+
<head>
7+
<title>Raspcontrol - The Raspberry Pi Control Centre</title>
8+
<link rel="stylesheet" href="app/styles/style.css" type="text/css" media="screen" charset="utf-8">
9+
</head>
10+
11+
<body>
12+
<div id="topContainer">
13+
<div class="topWrapper">
14+
<div style="float: left;&gt;">
15+
<h1>Raspcontrol</h1>
16+
17+
<h2>The Raspberry Pi Control Centre</h2>
18+
</div>
19+
20+
<?php
21+
if($_SESSION['username'] == ""){
22+
23+
}else{ ?>
24+
25+
<div style="text-align: right; color: #FFFFFF; font-family: Arial; font-size: 14px; float: right; width:500px;">
26+
Hostname: <strong><?php echo gethostname(); ?></strong> &middot; Internal IP: <strong><?php echo $_SERVER['SERVER_ADDR']; ?></strong><br>
27+
Accessed From: <strong><?php echo $_SERVER['SERVER_NAME']; ?></strong> &middot; Port <strong><?php echo $_SERVER['SERVER_PORT']; ?></strong> &middot; System: <strong><?php echo $_SERVER['SERVER_SOFTWARE']; ?></strong>
28+
</div>
29+
30+
<?php }
31+
?>
32+
33+
</div>
34+
</div>

0 commit comments

Comments
 (0)