This repository has been archived by the owner on Nov 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
process.php
145 lines (120 loc) · 3.94 KB
/
process.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
//Start session
session_start();
//Handle database connections
include "db.php";
//Connect to the database
connectDB();
//Check if the user is asking something
if(isset($_REQUEST['cmd'])) {
//See if the user wants to logout
if($_REQUEST['cmd'] == "logout") {
unset($_SESSION['user_pk']);
//Send the user to the home screen
header("Location: http://174.34.170.64/bootstrap.php");
}
}
$data = $_POST['packages'];
$id = $_POST['id'];
$manifest = '';
foreach($data as $package) {
if(file_exists('./packages/')) {
$read_file = file_get_contents('./packages/'.$package.'.pp');
$manifest .= $read_file."\n\n";
}
}
$puppet_file = './temp/'.$id.'.pp';
file_put_contents($puppet_file, $manifest);
$final_script = file_get_contents('installer');
$final_script = str_replace('{id}', $id, $final_script);
file_put_contents('./temp/'.$id, $final_script);
$final_file = "curl -s http://174.34.170.64/temp/$id > /tmp/wingscript; sudo bash /tmp/wingscript";
//print_r($final_file);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Our cool app!</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="/css/bootstrap.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 100px;
padding-bottom: 30px;
}
</style>
<link href="/css/bootstrap-responsive.css" rel="stylesheet">
</head>
<body bgcolor="#EEEEEE">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="bootstrap.php">Wingman</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="selection.php">Build Projects</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Saved Projects <b class="caret"></b></a>
<ul class="dropdown-menu">
<?php
$savedProjects = getSavedProjects($user);
if(count($savedProject) > 0) {
foreach($savedProjects as $project) {
echo "<li><a href='#'>" . $project[1] . "</a></li>";
}
} else {
echo "<li><a href='#'>You have no saved projects</a></li>";
}
?>
<!--
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li class="nav-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
-->
</ul>
</li>
</ul>
<form class="navbar-form pull-right" method='post' action='process.php'>
<button type="submit" class="btn">Logout</button>
<input type='hidden' name='cmd' value='logout' />
</form>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
<!-- Main hero unit -->
<div class="hero-unit" >
<center>
<h1>You're one step away!</h1>
</br>
<p>Please run this command in your terminal</p>
</br>
<pre class="curl-tag" background="/img/witewall_3.png">
<?php
echo "<p text-align='center'>" . $final_file . "</p>";
?>
</pre>
</center>
</div>
</div> <!-- /container -->
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="/js/jquery-1.10.2.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
</body>
</html>