Skip to content

Commit c4c75dc

Browse files
author
Anirudh Anand
authored
Merge pull request #6 from a0xnirudh/dev
Merged !
2 parents cf1253f + f5e5ce6 commit c4c75dc

32 files changed

+2113
-167
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<img src="/staticfiles/img/logo.png" alt="Kurukshetra"/>
55
</p>
66

7-
[![Github Release Version](https://img.shields.io/badge/release-V1.0-green.svg)](https://github.com/a0xnirudh/kurukshetra)
7+
[![Github Release Version](https://img.shields.io/badge/release-V2.0-green.svg)](https://github.com/a0xnirudh/kurukshetra)
88
[![Github Release Version](https://img.shields.io/badge/php-7.2-green.svg)](https://github.com/a0xnirudh/kurukshetra)
99
[![License](https://img.shields.io/badge/License-GPL%20v3-green.svg)](https://github.com/a0xnirudh/kurukshetra/blob/master/LICENSE)
1010
[![Kurukshetra loves Open source](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/a0xnirudh/kurukshetra)

admin/add_new.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@
6969
Users
7070
</a>
7171
</li>
72+
<li>
73+
<a href="containers.php">
74+
<i class="glyphicon glyphicon-cloud"></i>
75+
Hosted Challenges
76+
</a>
77+
</li>
7278
<li>
7379
<a href="faq.php">
7480
<i class="glyphicon glyphicon-screenshot"></i>

admin/api/get_all_containers.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
require $_SERVER['DOCUMENT_ROOT'].'/includes/core.php';
4+
check_admin(); //not logged in? redirect to login page
5+
header('Content-Type: application/json');
6+
echo get_all_containers();
7+
?>

admin/api/get_container_stats.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
require $_SERVER['DOCUMENT_ROOT'].'/includes/core.php';
3+
check_admin(); //not logged in? redirect to login page
4+
header('Content-Type: application/json');
5+
echo get_container_stats($_GET['id']);
6+
?>

admin/api/kill_challenge.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
require $_SERVER['DOCUMENT_ROOT'].'/includes/core.php';
4+
check_admin(); //not logged in? redirect to login page
5+
6+
$url = "http://127.0.0.1:2376";
7+
8+
if(isset($_GET['id']) && $_GET['id'] != "") {
9+
// Killing the container
10+
$result = httpPost($url . "/containers/" . $_GET['id'] . "/kill");
11+
12+
// Removing the container
13+
httpDelete($url . "/containers/" . $_GET['id'] . "?force=1");
14+
15+
// Update the DB
16+
update_container_status($_GET['id']);
17+
18+
if(!$result or $result == "")
19+
{
20+
$output = array("status" => True);
21+
header('Content-Type: application/json');
22+
echo json_encode($output);
23+
}
24+
}
25+
else
26+
echo '{"message": "No challenge ID passed."}';
27+
?>

admin/containers.php

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
<?php
2+
/**
3+
* Continaer management - container.php
4+
*
5+
* PHP version 7.2
6+
*
7+
* Admins can Kill containers from the dashboard.
8+
*
9+
* @category PHP
10+
* @package Kurukshetra
11+
* @author Anirudh Anand <a0xnirudh@gmail.com>
12+
* @license GPL v3.0
13+
*/
14+
15+
require $_SERVER['DOCUMENT_ROOT'].'/includes/core.php';
16+
check_admin();
17+
?>
18+
19+
<!DOCTYPE html>
20+
<html>
21+
<head>
22+
<meta charset="utf-8">
23+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
24+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
25+
<link rel="shortcut icon" type="image/png" href="/staticfiles/img/favicon.png"/>
26+
27+
<title>Kurukshetra</title>
28+
29+
<!-- Bootstrap CSS CDN -->
30+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
31+
<!-- Our Custom CSS -->
32+
<link rel="stylesheet" href="/staticfiles/css/base.css">
33+
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
34+
<link rel="stylesheet" href="/staticfiles/css/bootstrap-table.min.css">
35+
36+
<!-- Latest compiled and minified JavaScript -->
37+
<script src="/staticfiles/js/bootstrap-table.min.js"></script>
38+
<style>
39+
th {
40+
text-align: center;
41+
background-color: #333333;
42+
color: white;
43+
min-height: 50px;
44+
}
45+
46+
</style>
47+
</head>
48+
<body>
49+
<div class="wrapper">
50+
<!-- Sidebar Holder -->
51+
<nav id="sidebar">
52+
<div class="sidebar-header">
53+
<button type="button" id="sidebarCollapse" class="btn btn-success navbar-btn">
54+
<i class="glyphicon glyphicon-align-left"></i>
55+
</button>
56+
<strong>PG</strong>
57+
</div>
58+
59+
<ul class="list-unstyled components">
60+
<li>
61+
<a href="index.php">
62+
<i class="glyphicon glyphicon-briefcase"></i>
63+
Play Ground
64+
</a>
65+
</li>
66+
<li>
67+
<a href="#homeSubmenu" data-toggle="collapse" aria-expanded="false">
68+
<i class="glyphicon glyphicon-home"></i>
69+
Challenges
70+
</a>
71+
<ul class="collapse list-unstyled" id="homeSubmenu">
72+
<li><a href="add_new.php">Add New</a></li>
73+
<li><a href="view_edit.php">View / Modify</a></li>
74+
</ul>
75+
</li>
76+
<li>
77+
<a href="users.php">
78+
<i class="glyphicon glyphicon-user"></i>
79+
Users
80+
</a>
81+
</li>
82+
<li class="active">
83+
<a href="#">
84+
<i class="glyphicon glyphicon-cloud"></i>
85+
Hosted Challenges
86+
</a>
87+
</li>
88+
<li>
89+
<a href="faq.php">
90+
<i class="glyphicon glyphicon-screenshot"></i>
91+
FAQ
92+
</a>
93+
</li>
94+
<li>
95+
<a href="mailto:<?php echo get_admin_email(); ?>">
96+
<i class="glyphicon glyphicon-send"></i>
97+
Contact
98+
</a>
99+
</li>
100+
<li>
101+
<a href="/login/logout.php">
102+
<i class="glyphicon glyphicon-log-out"></i>
103+
Logout
104+
</a>
105+
</li>
106+
</ul>
107+
</nav>
108+
109+
<!-- Page Content Holder -->
110+
<div id="content">
111+
<nav class="navbar navbar-default">
112+
<div class="container-fluid">
113+
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
114+
<h3 id='page_title'>User Management</h3>
115+
</div>
116+
</div>
117+
</nav>
118+
119+
<div id="page_content">
120+
<div id="result"></div>
121+
<script src="/staticfiles/js/containers.js"></script>
122+
<table id="table" data-pagination="true"></table>
123+
</div>
124+
<div class="line"></div>
125+
</div>
126+
</div>
127+
<!-- jQuery CDN -->
128+
<!-- Bootstrap Js CDN -->
129+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
130+
131+
<script type="text/javascript">
132+
$(document).ready(function () {
133+
$('#sidebarCollapse').on('click', function () {
134+
$('#sidebar').toggleClass('active');
135+
});
136+
});
137+
</script>
138+
</body>
139+
</html>

admin/faq.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@
108108
Users
109109
</a>
110110
</li>
111+
<li>
112+
<a href="containers.php">
113+
<i class="glyphicon glyphicon-cloud"></i>
114+
Hosted Challenges
115+
</a>
116+
</li>
111117
<li class="active">
112118
<a href="#">
113119
<i class="glyphicon glyphicon-screenshot"></i>

admin/index.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@
7272
Users
7373
</a>
7474
</li>
75+
<li>
76+
<a href="containers.php">
77+
<i class="glyphicon glyphicon-cloud"></i>
78+
Hosted Challenges
79+
</a>
80+
</li>
7581
<li>
7682
<a href="faq.php">
7783
<i class="glyphicon glyphicon-screenshot"></i>
@@ -105,6 +111,10 @@
105111

106112
<div id="page_content">
107113
<div class="container-fluid bg-4 text-center">
114+
<div align="left">
115+
Click here to view <a style="text-decoration:underline" href="javascript:show_token()">Developer Token</a>
116+
</br></br>
117+
</div>
108118
<div class="row no-gutter">
109119
<div class="columns col-sm-4">
110120
<div id="container" style="min-width: 310px; height: 300px; max-width: 600px; margin: 0 auto"></div>
@@ -131,6 +141,10 @@
131141
$('#sidebar').toggleClass('active');
132142
});
133143
});
144+
145+
function show_token(){
146+
alert("<?php echo get_dev_token(); ?>");
147+
}
134148
</script>
135149
</body>
136150
</html>

admin/users.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@
8282
Users
8383
</a>
8484
</li>
85+
<li>
86+
<a href="containers.php">
87+
<i class="glyphicon glyphicon-cloud"></i>
88+
Hosted Challenges
89+
</a>
90+
</li>
8591
<li>
8692
<a href="faq.php">
8793
<i class="glyphicon glyphicon-screenshot"></i>

0 commit comments

Comments
 (0)