Skip to content
This repository has been archived by the owner on Nov 10, 2021. It is now read-only.

Commit

Permalink
:octocat: + Some smaller improvements
Browse files Browse the repository at this point in the history
updated stylefile and Frontend mysql stuff
  • Loading branch information
LukvonStrom committed Dec 11, 2015
1 parent aa0d2a9 commit 1ccd141
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 38 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ https://twitter.com/stetto98
##License
Released under the MIT License - http://opensource.org/licenses/mit-license.php

Current MySQLCommands version is A_0.1.1
Current MySQLCommands version is A_0.1
6 changes: 2 additions & 4 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
$dbpass = '12345'; //Your DB Password.
$dbname = 'minecraft'; //Your DB Name.


$debug = 'false'; //Debug mode, set to 'true' to activate.

$updatechecking = 'true'; //Should the Script search for Updates automatically
/*
Do not edit down here if you don't know what you are doing!
*/
if($debug != 'true') {
error_reporting(0);
}

/*
Update Variables | DO NOT EDIT THESE OR YOU WOULD NOT BE ABLE TO CHECK FOR UPDATES!
*/
$version = "A_0.1.1";
$version = "A_0.1.2";
17 changes: 2 additions & 15 deletions execute.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,54 +21,42 @@ function MessageHandler($message,$type) {
echo "Success: $success";
}
}

if(!empty($_POST['command'])) {
require_once("./config.php");

require("./config.php");
if($debug != 'true') {
$con = mysql_connect($dbhost,$dbname,$dbpass);

if(!$con) {
$error = "Couldn't connect to database.";
MessageHandler($error,0);
}
} else {
$con = mysql_connect($dbhost,$dbname,$dbpass) or die("Couldn't connect to database. Error:".mysql_error());
}

mysql_select_db($dbname) or die("Cannot select defined database. Error:".mysql_error());

$command = $_POST['command'];

$command_count = strlen($command);
if($command_count > "255") {
$error = "Your Message contains too many characters. Maximum is 255 and you used $command_count of them.";
MessageHandler($error,0);
}
$check1 = strpos($command, '"');
$check2 = strpos($command, "'");

if($check1 !== false or $check2 !== false) {
$error = "Your Message contains not allowed characters.";
MessageHandler($error,0);
}

$insert = mysql_query("INSERT INTO `MySQLCommands` (`command`) VALUES('$command')") or die("MYSQL INSERT COMMAND QUERY ERROR: " . mysql_error());
$success = "Command '$command' successfully scheduled.";
MessageHandler($success,1);
} elseif(!empty($_GET['delete'])) {
require_once("./config.php");

require("./config.php");
$con = mysql_connect($dbhost,$dbname,$dbpass);

if(!$con) {
$error = "Couldn't connect to database.";
MessageHandler($error,0);
}
mysql_select_db($dbname) or die("Cannot select defined database. Error:".mysql_error());

$id = $_GET['delete'];

$delete = mysql_query("DELETE FROM `MySQLCommands` WHERE `id` = '$id'");
if(!$delete) {
$error = "There was an error while performing the request.";
Expand All @@ -81,4 +69,3 @@ function MessageHandler($message,$type) {
$error = "Command not defined.";
MessageHandler($error,0);
}
?>
29 changes: 12 additions & 17 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>MySQL Commands &bull; Web UI</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/3.3.5/darkly/bootstrap.min.css">
</head>
<body>
<style>body {overflow: hidden;}</style>
<form method='post' action='./execute.php' class="form-horizontal">
<fieldset>
<legend>MySQL Commands Console</legend>
<h1><center><legend><font size="6">MySQL Commands Console</font></legend></center></h1>
<?php if(!isset($_GET['schedule'])) { ?>
<div class="form-group">
<label class="col-md-3 control-label" for="command"></label>
Expand All @@ -38,39 +39,33 @@
<?php if(isset($_GET['success'])){echo"Success";}else{echo"Error";}?>!</strong> <?php if(isset($_GET['success'])){echo$_GET['success'];}else{echo$_GET['error'];}?></div>
<br>
<?php } ?>
<p>Send your command to the Minecraft Server. Characters <b>'</b> and <b>"</b> will be removed.</p><br />
<center><p>Send your command to the Minecraft Server. Characters <b>'</b> and <b>"</b> will be removed.</p></center><br />
<input type="text" id="command" name="command" maxlength="255" placeholder="Command" class="form-control input-md">
</div>
</div>

<div class="form-group">
<label class="col-md-3 control-label"></label>
<div class="col-md-4">
<button type='submit' class="btn btn-success">Submit</button> <a class="btn btn-info" href='./index.php?schedule'>Scheduled Commands</a>
<button type='submit' class="btn btn-success" style="margin-right: 0.115em; margin-left: 0.115em;">Submit</button> <a class="btn btn-info" style="margin-right: 0.115em; margin-left: 0.115em;" href='./index.php?schedule'>Scheduled Commands</a> <a class="btn btn-primary" style="margin-right: 0.115em; margin-left: 0.115em;" href='./update.php'>Check for Updates</a>
</div>
</div>
<?php } else {
require_once("./config.php");
if($debug != 'true') {
$con = mysql_connect($dbhost,$dbname,$dbpass);
$con = mysqli_connect($dbhost, $dbname, $dbpass, $dbname);

if(!$con) {
$error = "Couldn't connect to database.";
header("Location: ./index.php?error=$error");
exit();
if($con->connect_error) {
die("Couldn't connect to database. Error:".$conn->connect_error);
}
} else {
$con = mysql_connect($dbhost,$dbname,$dbpass) or die("Couldn't connect to database. Error:".mysql_error());
}
mysql_select_db($dbname) or die("Cannot select defined database. Error:".mysql_error());

$select = mysql_query("SELECT * FROM `MySQLCommands` ORDER BY `id` ASC");
$select = 'SELECT * FROM `MySQLCommands` ORDER BY `id` ASC';
$rs=$con->query($select);

$count = mysql_num_rows($select);
$count = $rs->num_rows;
if($count >= 1) {
echo "<div class='col-md-3'></div><div class='col-md-6'><table class='table table-bordered'>";
echo "<tr><td>#</td><td>Command</td><td>Action</td></tr>";
while($row = mysql_fetch_array($select)) {
while($row = mysqli_fetch_array($rs)) {
echo "<tr><td>".$row['id']."</td><td>".$row['command']."</td><td><a class='btn btn-danger' href='./execute.php?delete=".$row['id']."' onclick='Conf()'><span class='glyphicon glyphicon-remove'></span></td></tr>";
}
echo "</table>";
Expand Down
3 changes: 2 additions & 1 deletion update.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
require_once("config.php");

if ($updatechecking === 'true') {
$get = file_get_contents("http://minecraftsmp.altervista.org/mysqlcmd/uptodate.php?version=$version");
$reply = json_decode($get, true);
if(!$get) {
Expand All @@ -24,4 +24,5 @@
$fail_1 = "Your MySQLCommands installation is OUTDATED! You are using the $version version. Check for new updates at <a href='https://github.com/J0ker98/MySQLCommands'>GitHub</a>";
header("Location: ./index.php?error=$fail_1");
}
}
?>

0 comments on commit 1ccd141

Please sign in to comment.