Skip to content

Commit

Permalink
Merge pull request #6 from a0xnirudh/dev
Browse files Browse the repository at this point in the history
Merged !
  • Loading branch information
Anirudh Anand committed Nov 27, 2018
2 parents cf1253f + f5e5ce6 commit c4c75dc
Show file tree
Hide file tree
Showing 32 changed files with 2,113 additions and 167 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<img src="/staticfiles/img/logo.png" alt="Kurukshetra"/>
</p>

[![Github Release Version](https://img.shields.io/badge/release-V1.0-green.svg)](https://github.com/a0xnirudh/kurukshetra)
[![Github Release Version](https://img.shields.io/badge/release-V2.0-green.svg)](https://github.com/a0xnirudh/kurukshetra)
[![Github Release Version](https://img.shields.io/badge/php-7.2-green.svg)](https://github.com/a0xnirudh/kurukshetra)
[![License](https://img.shields.io/badge/License-GPL%20v3-green.svg)](https://github.com/a0xnirudh/kurukshetra/blob/master/LICENSE)
[![Kurukshetra loves Open source](https://badges.frapsoft.com/os/v1/open-source.svg?v=103)](https://github.com/a0xnirudh/kurukshetra)
Expand Down
6 changes: 6 additions & 0 deletions admin/add_new.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
Users
</a>
</li>
<li>
<a href="containers.php">
<i class="glyphicon glyphicon-cloud"></i>
Hosted Challenges
</a>
</li>
<li>
<a href="faq.php">
<i class="glyphicon glyphicon-screenshot"></i>
Expand Down
7 changes: 7 additions & 0 deletions admin/api/get_all_containers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

require $_SERVER['DOCUMENT_ROOT'].'/includes/core.php';
check_admin(); //not logged in? redirect to login page
header('Content-Type: application/json');
echo get_all_containers();
?>
6 changes: 6 additions & 0 deletions admin/api/get_container_stats.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
require $_SERVER['DOCUMENT_ROOT'].'/includes/core.php';
check_admin(); //not logged in? redirect to login page
header('Content-Type: application/json');
echo get_container_stats($_GET['id']);
?>
27 changes: 27 additions & 0 deletions admin/api/kill_challenge.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

require $_SERVER['DOCUMENT_ROOT'].'/includes/core.php';
check_admin(); //not logged in? redirect to login page

$url = "http://127.0.0.1:2376";

if(isset($_GET['id']) && $_GET['id'] != "") {
// Killing the container
$result = httpPost($url . "/containers/" . $_GET['id'] . "/kill");

// Removing the container
httpDelete($url . "/containers/" . $_GET['id'] . "?force=1");

// Update the DB
update_container_status($_GET['id']);

if(!$result or $result == "")
{
$output = array("status" => True);
header('Content-Type: application/json');
echo json_encode($output);
}
}
else
echo '{"message": "No challenge ID passed."}';
?>
139 changes: 139 additions & 0 deletions admin/containers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?php
/**
* Continaer management - container.php
*
* PHP version 7.2
*
* Admins can Kill containers from the dashboard.
*
* @category PHP
* @package Kurukshetra
* @author Anirudh Anand <[email protected]>
* @license GPL v3.0
*/

require $_SERVER['DOCUMENT_ROOT'].'/includes/core.php';
check_admin();
?>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="shortcut icon" type="image/png" href="/staticfiles/img/favicon.png"/>

<title>Kurukshetra</title>

<!-- Bootstrap CSS CDN -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- Our Custom CSS -->
<link rel="stylesheet" href="/staticfiles/css/base.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<link rel="stylesheet" href="/staticfiles/css/bootstrap-table.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="/staticfiles/js/bootstrap-table.min.js"></script>
<style>
th {
text-align: center;
background-color: #333333;
color: white;
min-height: 50px;
}

</style>
</head>
<body>
<div class="wrapper">
<!-- Sidebar Holder -->
<nav id="sidebar">
<div class="sidebar-header">
<button type="button" id="sidebarCollapse" class="btn btn-success navbar-btn">
<i class="glyphicon glyphicon-align-left"></i>
</button>
<strong>PG</strong>
</div>

<ul class="list-unstyled components">
<li>
<a href="index.php">
<i class="glyphicon glyphicon-briefcase"></i>
Play Ground
</a>
</li>
<li>
<a href="#homeSubmenu" data-toggle="collapse" aria-expanded="false">
<i class="glyphicon glyphicon-home"></i>
Challenges
</a>
<ul class="collapse list-unstyled" id="homeSubmenu">
<li><a href="add_new.php">Add New</a></li>
<li><a href="view_edit.php">View / Modify</a></li>
</ul>
</li>
<li>
<a href="users.php">
<i class="glyphicon glyphicon-user"></i>
Users
</a>
</li>
<li class="active">
<a href="#">
<i class="glyphicon glyphicon-cloud"></i>
Hosted Challenges
</a>
</li>
<li>
<a href="faq.php">
<i class="glyphicon glyphicon-screenshot"></i>
FAQ
</a>
</li>
<li>
<a href="mailto:<?php echo get_admin_email(); ?>">
<i class="glyphicon glyphicon-send"></i>
Contact
</a>
</li>
<li>
<a href="/login/logout.php">
<i class="glyphicon glyphicon-log-out"></i>
Logout
</a>
</li>
</ul>
</nav>

<!-- Page Content Holder -->
<div id="content">
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<h3 id='page_title'>User Management</h3>
</div>
</div>
</nav>

<div id="page_content">
<div id="result"></div>
<script src="/staticfiles/js/containers.js"></script>
<table id="table" data-pagination="true"></table>
</div>
<div class="line"></div>
</div>
</div>
<!-- jQuery CDN -->
<!-- Bootstrap Js CDN -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<script type="text/javascript">
$(document).ready(function () {
$('#sidebarCollapse').on('click', function () {
$('#sidebar').toggleClass('active');
});
});
</script>
</body>
</html>
6 changes: 6 additions & 0 deletions admin/faq.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@
Users
</a>
</li>
<li>
<a href="containers.php">
<i class="glyphicon glyphicon-cloud"></i>
Hosted Challenges
</a>
</li>
<li class="active">
<a href="#">
<i class="glyphicon glyphicon-screenshot"></i>
Expand Down
14 changes: 14 additions & 0 deletions admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,12 @@
Users
</a>
</li>
<li>
<a href="containers.php">
<i class="glyphicon glyphicon-cloud"></i>
Hosted Challenges
</a>
</li>
<li>
<a href="faq.php">
<i class="glyphicon glyphicon-screenshot"></i>
Expand Down Expand Up @@ -105,6 +111,10 @@

<div id="page_content">
<div class="container-fluid bg-4 text-center">
<div align="left">
Click here to view <a style="text-decoration:underline" href="javascript:show_token()">Developer Token</a>
</br></br>
</div>
<div class="row no-gutter">
<div class="columns col-sm-4">
<div id="container" style="min-width: 310px; height: 300px; max-width: 600px; margin: 0 auto"></div>
Expand All @@ -131,6 +141,10 @@
$('#sidebar').toggleClass('active');
});
});

function show_token(){
alert("<?php echo get_dev_token(); ?>");
}
</script>
</body>
</html>
6 changes: 6 additions & 0 deletions admin/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@
Users
</a>
</li>
<li>
<a href="containers.php">
<i class="glyphicon glyphicon-cloud"></i>
Hosted Challenges
</a>
</li>
<li>
<a href="faq.php">
<i class="glyphicon glyphicon-screenshot"></i>
Expand Down
Loading

0 comments on commit c4c75dc

Please sign in to comment.