CyTube/www/acp.html

259 lines
9.7 KiB
HTML
Raw Normal View History

2013-03-06 22:02:40 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
2013-05-03 20:53:10 +00:00
<title>CyTube - Administration</title>
2013-03-06 22:02:40 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="Calvin 'calzoneman' Montgomery">
<link href="./assets/css/bootstrap.css" rel="stylesheet">
<link href="./assets/css/ytsync.css" rel="stylesheet">
<style>
2013-05-03 20:53:10 +00:00
body {
2013-03-06 22:02:40 +00:00
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
2013-05-03 20:53:10 +00:00
}
.loginform {
margin: 100px auto 20px;
padding: 19px 29px 29px;
border-radius: 5px 5px 5px 5px;
border: 1px solid #dedede;
max-width: 300px;
}
#log {
max-height: 500px;
overflow-y: scroll;
}
2013-03-06 22:02:40 +00:00
</style>
<link href="./assets/css/bootstrap-responsive.css" rel="stylesheet">
</head>
<body>
2013-05-03 20:53:10 +00:00
<div class="wrapper">
2013-03-06 22:02:40 +00:00
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
2013-05-03 20:53:10 +00:00
<a class="brand" href="index.html">CyTube</a>
<div class="">
2013-03-06 22:02:40 +00:00
<ul class="nav">
2013-05-03 20:53:10 +00:00
<li class="active"><a href="index.html">Home</a></li>
<li><a href="help.html">Help</a></li>
<li><a href="javascript:void(0)" id="optlink">Options</a></li>
2013-03-06 22:02:40 +00:00
</ul>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div id="loggedin" class="span6" style="display: none;">
<h3 id="welcome"></h3>
</div>
2013-05-03 20:53:10 +00:00
<form class="form-horizontal loginform" action="javascript:void(0);">
<div class="control-group">
<input id="name" type="text" placeholder="Username" class="input-block-level">
</div>
<div class="control-group">
<input id="pw" type="password" placeholder="Password" class="input-block-level">
</div>
<button id="login" class="btn btn-block">Authenticate</button>
</form>
2013-03-06 22:02:40 +00:00
</div>
2013-05-03 20:53:10 +00:00
<div class="row">
<div class="span8">
<h3>Log Viewer</h3>
<form class="form-inline" action="javascript:void(0);">
<button id="syslog" class="btn">Syslog</button>
<button id="errlog" class="btn">Error log</button>
<div class="input-append">
<input type="text" id="channame" placeholder="Channel Name">
<button class="btn" id="chanlog">Channel log</button>
</div>
</form>
<pre id="log"></pre>
2013-03-06 22:02:40 +00:00
</div>
</div>
2013-05-04 17:30:38 +00:00
<div class="row">
<div class="span8">
<h3>Global Bans</h3>
<table id="banlist" class="table table-striped table-bordered">
<thead>
<tr>
<th></th>
<th>IP</th>
<th>Reason</th>
</tr>
</thead>
</table>
</div>
</div>
2013-03-06 22:02:40 +00:00
</div> <!-- /container -->
2013-05-03 20:53:10 +00:00
<div class="push"></div>
<div id="sitefooter">
</div>
</div>
<div id="footer">
<p class="muted">
CyTube Software Copyright &copy; 2013 Calvin Montgomery&nbsp;&middot;&nbsp;Available for free on <a href="http://github.com/calzoneman/sync">GitHub</a>&nbsp;&middot;
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=5Y7PUVVGVSEWG&lc=US&item_name=CyTube&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donate_SM%2egif%3aNonHosted">Donate</a>
</p>
</div>
2013-03-06 22:02:40 +00:00
2013-05-03 20:53:10 +00:00
<!-- Third party -->
2013-03-06 22:02:40 +00:00
<script src="./assets/js/jquery.js"></script>
2013-05-03 20:53:10 +00:00
<script src="./assets/js/bootstrap.js"></script>
<script src="./assets/js/bootstrap-transition.js"></script>
<script src="./assets/js/bootstrap-modal.js"></script>
<!-- Mine -->
2013-03-06 22:02:40 +00:00
<script src="./assets/js/iourl.js"></script>
2013-05-03 20:53:10 +00:00
<script type="text/javascript">
var host = document.location+"";
host = host.replace("http://", "");
if(host.indexOf("/") != -1)
host = host.substring(0, host.indexOf("/"));
host = "http://" + host;
var session = readCookie("sync_session") || "";
var uname = readCookie("sync_uname") || "";
var p = "";
if(uname && session) {
2013-05-17 23:04:39 +00:00
$.getJSON(WEB_URL+"/api/json/login?name="+uname+"&session="+session+"&callback=?", function(data) {
2013-05-03 20:53:10 +00:00
if(data.success) {
$(".loginform").remove();
createCookie("sync_uname", uname, 7);
createCookie("sync_session", session, 7);
p = "name=" + uname + "&session=" + session;
2013-05-04 17:30:38 +00:00
loadBanlist();
2013-05-03 20:53:10 +00:00
}
});
}
var q = "";
$("#login").click(function() {
uname = $("#name").val();
q = "name=" + $("#name").val() + "&pw=" + $("#pw").val();
2013-05-17 23:04:39 +00:00
$.getJSON(WEB_URL+"/api/json/login?"+q+"&callback=?", function(data) {
2013-05-03 20:53:10 +00:00
console.log(data);
if(data.success) {
$(".loginform").remove();
session = data.session;
createCookie("sync_uname", uname, 7);
createCookie("sync_session", session, 7);
p = "name=" + uname + "&session=" + session;
2013-05-04 17:30:38 +00:00
loadBanlist();
2013-05-03 20:53:10 +00:00
}
});
});
function getSyslog() {
2013-05-17 23:04:39 +00:00
$.ajax(WEB_URL+"/api/plain/readlog?type=sys&"+p).done(function(data) {
2013-05-03 20:53:10 +00:00
$("#log").text(data);
});
}
$("#syslog").click(getSyslog);
function getErrlog() {
2013-05-17 23:04:39 +00:00
$.ajax(WEB_URL+"/api/plain/readlog?type=err&"+p).done(function(data) {
2013-05-03 20:53:10 +00:00
$("#log").text(data);
});
}
$("#errlog").click(getErrlog);
function getChanlog() {
var chan = $("#channame").val();
2013-05-17 23:04:39 +00:00
$.ajax(WEB_URL+"/api/plain/readlog?type=channel&channel="+chan+"&"+p).done(function(data) {
2013-05-03 20:53:10 +00:00
$("#log").text(data);
});
}
$("#chanlog").click(getChanlog);
$("#channame").keydown(function(ev) {
if(ev.keyCode == 13) {
getChanlog();
}
});
2013-05-04 17:30:38 +00:00
function loadBanlist() {
2013-05-17 23:04:39 +00:00
$.getJSON(WEB_URL+"/api/json/globalbans?action=list&"+p+"&callback=?", function(data) {
2013-05-04 17:30:38 +00:00
handleBanlist(data);
});
}
function handleBanlist(data) {
var tbl = $("#banlist");
if(tbl.children().length > 1) {
$(tbl.children()[1]).remove();
}
for(var ip in data) {
var tr = $("<tr/>").appendTo($("#banlist"));
var btntd = $("<td/>").appendTo(tr);
var remove = $("<button/>").addClass("btn btn-danger")
.appendTo(btntd);
$("<i/>").addClass("icon-minus").appendTo(remove);
remove.click(function(ip) { return function() {
var b = "ip=" + ip;
2013-05-17 23:04:39 +00:00
$.getJSON(WEB_URL+"/api/json/globalbans?action=remove&"+b+"&"+p+"&callback=?", function(data) {
2013-05-04 17:30:38 +00:00
if(data.error) {
alert(data.error);
}
else if(!data.success) {
alert("Remove ban failed");
}
loadBanlist();
});
} }(ip));
var iptd = $("<td/>").appendTo(tr);
$("<code/>").text(ip).appendTo(iptd);
var reason = $("<td/>").appendTo(tr);
$("<code/>").text(data[ip]).appendTo(reason);
}
// Add new
var tr = $("<tr/>").appendTo($("#banlist"));
var add = $("<button/>").addClass("btn btn-success")
.appendTo($("<td/>").appendTo(tr));
$("<i/>").addClass("icon-plus").appendTo(add);
var ip = $("<input/>").attr("type", "text")
.appendTo($("<td/>").appendTo(tr));
var reason = $("<input/>").attr("type", "text")
.appendTo($("<td/>").appendTo(tr));
add.click(function() {
var b = "ip=" + ip.val() + "&reason=" + reason.val();
2013-05-17 23:04:39 +00:00
$.getJSON(WEB_URL+"/api/json/globalbans?action=add&"+b+"&"+p+"&callback=?", function(data) {
2013-05-04 17:30:38 +00:00
if(data.error) {
alert(data.error);
}
else if(!data.success) {
alert("Add ban failed");
}
loadBanlist();
});
});
}
2013-05-03 20:53:10 +00:00
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(";");
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==" ") c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
2013-03-06 22:02:40 +00:00
2013-05-03 20:53:10 +00:00
function eraseCookie(name) {
createCookie(name,"",-1);
}
</script>
2013-03-06 22:02:40 +00:00
</body>
</html>