Skip to content

Instantly share code, notes, and snippets.

@maxanier
Last active August 29, 2015 14:05
Show Gist options
  • Save maxanier/9c1918014191e22099cf to your computer and use it in GitHub Desktop.
Save maxanier/9c1918014191e22099cf to your computer and use it in GitHub Desktop.
Website for Versionupload
<?php
$version=$_GET["version"];
$link=$_GET["link"];
$mcversion=$_GET["mcversion"];
$recommend=(int)$_GET["recommend"];
$pass=$_GET["pass"];
$dev=$_GET["devlink"];
if($pass!="<a custom password>"){
return;
}
$con=mysqli_connect("localhost","<database-username">,"<database-password>","<database-name>");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
return;
}
$sql="INSERT INTO <TABLENAME_FILES> (version,link,minecraftversion,recommend,timestamp,devlink) VALUES ('".$version."','".$link."','".$mcversion."',".$recommend.",".time().",'".$dev."')";
if(!mysqli_query($con,$sql)){
echo "Failed to add version: " . mysqli_error($con);
}
mysqli_close($con);
?>
<?php
$pass=$_POST["pass"];
if($pass!="<same custom password>"){
echo "Error wrong password";
return;
}
$major=$_POST["major"];
$minor=$_POST["minor"];
$change=$_POST["change"];
$build=$_POST["build"];
$con=mysqli_connect("localhost","<database-username">,"<database-password>","<database-name>");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
return;
}
$sql="INSERT INTO <TABLENAME-CHANGELOG> (major,minor,build,changelog) VALUES ('".$major."','".$minor."','".$build."','".$change."')";
if(!mysqli_query($con,$sql)){
echo "Failed to add changelog: " . mysqli_error($con);
}
else{
echo "Inserted: '".$major."','".$minor."','".$build."','".$change."'";
}
mysqli_close($con);
?>
##Replace the text to fit your mod
<?php
echo "<h1>Minecraft Second Screen</h1>";
echo "<font color='red'><b>Please read the instructions on the forum first</b></font><p>";
echo "<font color='blue'><h3>App/Client</h3></font>
<h4>Android 4.0+ App</h4>
Only works with version 0.9 or higher.
<br>
<a href='https://play.google.com/store/apps/details?id=de.maxgb.android.minecraft_second_screen'>Google Play</a>
<h4>Any other OS/universal app</h4>
Only works with version 0.9 or higher.<br>
This is a webapp, so you have to open it in your browser and set a bookmark. Native versions may follow.<br>
<a href='http://maxgb.de/minecraftsecondscreen/app'>App</a>";
echo "<font color='blue'><h2>Download Mod Universal </h2></font>";
echo "<form method='GET' action='".$_SERVER['PHP_SELF']."'>
<input type='hidden' name='showall' value='".($_GET['showall']=='true'? "false" : "true")."'>
<input type='submit' value='".($_GET['showall']=='true'? "Show only important Downloads" : "Show all Downloads")."'>
</form>";
echo "<b>Do not</b> download the '-dev' versions unless you want to use it in your IDE";
echo "<iframe src='".($_GET['showall']=='true' ? "showall.php" : "show.php")."' width='100%' height='60%'><a href='".($_GET['showall']=='true' ? "showall.php" : "show.php")."'>Here</a></iframe>";
?>
<?php
function display($result,$name){
$item = mysqli_fetch_array($result);
if($item!=null){
$time= date('Y-m-d H:i:s', $item['timestamp']);
echo "<tr><td>".$name."</td><td>".$item['minecraftversion']."</td><td>".$item['version']."</td><td><a href='".$item['link']."' target='_top'>Download</a></td>".addDevLink($item)."<td>".$time."</td></tr>";
}
}
function addDevLink($item){
if($item['devlink']==null||$item['devlink']==""){
return "<td>Not available</td>";
}
else{
return "<td><a href='".$item['devlink']."' target='_top'>Download</a></td>";
}
}
$con=mysqli_connect("localhost","<database-username">,"<database-password>","<database-name>");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
return;
}
$sql ="SELECT DISTINCT minecraftversion FROM <TABLENAME_FILES> ORDER BY minecraftversion DESC";
$result = mysqli_query($con,$sql);
//HTML start
echo "<table><tr><th>Name</th><th>Minecraftversion</th><th>Version</th><th>Download</th><th>Download-Dev</th><th>Timestamp</th><tr>";
while($row = mysqli_fetch_array($result)){
$mcv=$row['minecraftversion'];
$sql = "SELECT * FROM <TABLENAME_FILES> WHERE minecraftversion='".$mcv."' AND recommend=1 ORDER BY timestamp DESC";
$recommend = mysqli_query($con,$sql);
display($recommend,$mcv."-recommend");
$sql = "SELECT * FROM <TABLENAME_FILES> WHERE minecraftversion='".$mcv."' ORDER BY timestamp DESC";
$latest = mysqli_query($con,$sql);
display($latest,$mcv."-latest");
echo "<tr><td>-</td><td></td></tr>";
}
//HTML end
echo"</table>";
?>
<?php
function display($item){
$time= date('Y-m-d H:i:s', $item['timestamp']);
echo "<tr><td>".$item['minecraftversion']."</td><td>".$item['version']."</td><td><a href='".$item['link']."' target='_top'>Download</a></td>".addDevLink($item)."<td>".($item['recommend'] == 1 ? "true" : "false")."</td><td>".$time."</td>".(($_GET["pass"]=="<custom password>") ? addChangeButton($item) : "<td></td>")."</tr>";
}
function addChangeButton($item){
return "<td><form method='POST' action='".$_SERVER['PHP_SELF']."?pass=".$_GET["pass"]."'>
<input type='hidden' name='recommend' value='".(((int)$item['recommend']) == 1 ? "0" : "1")."'>
<input type='hidden' name='timestamp' value='".$item['timestamp']."'>
<input type='submit' name='changerecommend' value='Change recommend'/>
</form></td>
<td><form method='POST' action='".$_SERVER['PHP_SELF']."?pass=".$_GET['pass']."'>
<input type='hidden' name='timestamp' value='".$item['timestamp']."'>
<input type='submit' name='delete' value='Delete'/>
</form></td>";
}
function addDevLink($item){
if($item['devlink']==null||$item['devlink']==""){
return "<td>Not available</td>";
}
else{
return "<td><a href='".$item['devlink']."' target='_top'>Download</a></td>";
}
}
$con=mysqli_connect("localhost","<database-username">,"<database-password>","<database-name>");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
return;
}
if(isset($_POST['changerecommend'])&&$_GET["pass"]=="<custom password>"){
$sql="UPDATE <TABLENAME_FILES> SET recommend=".(int)$_POST['recommend']." WHERE timestamp=".$_POST['timestamp'];
mysqli_query($con,$sql);
}
if(isset($_POST['delete'])&&$_GET["pass"]=="<custom password>"){
$sql="DELETE FROM <TABLENAME_FILES> WHERE timestamp=".$_POST['timestamp'];
mysqli_query($con,$sql);
}
$sql="SELECT * FROM <TABLENAME_FILES> ORDER BY minecraftversion DESC,version DESC,timestamp DESC;";
$result = mysqli_query($con,$sql);
//HTML start
echo "<table><tr><th>Minecraftversion</th><th>Version</th><th>Download</th><th>Download-Dev</th><th>Recommend</th><th>Timestamp</th><th></th><th></th><tr>";
while($row = mysqli_fetch_array($result)){
display($row);
}
echo "</table><p>";
if($_GET["pass"]!="<custom password>"){
echo "<form action='".$_SERVER['PHP_SELF']."' method='GET'>
<input type='password' name='pass'>
<input type='submit' value='Edit'>
</form>";
}
else {
echo "<form action='".$_SERVER['PHP_SELF']."' method='GET'>
<input type='submit' value='Stop'>
</form>";
}
?>
<?php
function display($item){
echo "<b>Version: ".$item['major'].".".$item['minor'].".".$item['build']."</b><br>";
echo $item['changelog'];
echo "<br>";
}
$con=mysqli_connect("localhost","<database-username">,"<database-password>","<database-name>");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
return;
}
$sql="SELECT * FROM <TABLENAME_CHANGELOG> ORDER BY build DESC;";
$result = mysqli_query($con,$sql);
while($row = mysqli_fetch_array($result)){
display($row);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment