Skip to content

Commit

Permalink
Add missing Minecraft association file
Browse files Browse the repository at this point in the history
Add file missing from 159623b allowing
configuration of mcassoc
  • Loading branch information
samerton committed Aug 19, 2016
1 parent fe7441d commit dfc1b06
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions pages/admin/minecraft.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<li<?php if(!isset($_GET['view'])){ ?> class="active"<?php } ?>><a href="/admin/minecraft"><?php echo $admin_language['settings']; ?></a></li>
<li<?php if(isset($_GET['view']) && $_GET['view'] == 'servers'){ ?> class="active"<?php } ?>><a href="/admin/minecraft/?view=servers"><?php echo $admin_language['servers']; ?></a></li>
<li<?php if(isset($_GET['view']) && $_GET['view'] == 'errors'){ ?> class="active"<?php } ?>><a href="/admin/minecraft/?view=errors"><?php echo $admin_language['query_errors']; ?></a></li>
<li<?php if(isset($_GET['view']) && $_GET['view'] == 'mcassoc'){ ?> class="active"<?php } ?>><a href="/admin/minecraft/?view=mcassoc"><?php echo $admin_language['mcassoc']; ?></a></li>
</ul>
<hr>
<div class="well">
Expand Down Expand Up @@ -676,6 +677,88 @@
echo '<div class="panel panel-danger"><div class="panel-body"><p>' . htmlspecialchars($query_error->error) . '</p></div></div>';
}
}
} else if(!isset($_GET['settings']) && isset($_GET['view']) && $_GET['view'] == 'mcassoc'){
if(Input::exists()){
// Check token
if(Token::check(Input::get('token'))){
// Validate input
$validate = new Validate();
$validation = $validate->check($_POST, array(
'mcassoc_key' => array(
'max' => 128
)
));

if($validation->passed()){
// Update database
if(Input::get('use_mcassoc') == 'on'){
$use_mcassoc = 1;
} else {
$use_mcassoc = 0;
}

$use_mcassoc_id = $queries->getWhere('settings', array('name', '=', 'use_mcassoc'));
$queries->update('settings', $use_mcassoc_id[0]->id, array(
'value' => $use_mcassoc
));

$mcassoc_key = $queries->getWhere('settings', array('name', '=', 'mcassoc_key'));
$queries->update('settings', $mcassoc_key[0]->id, array(
'value' => htmlspecialchars(Input::get('mcassoc_key'))
));

} else {
// Invalid key
$message = '<div class="alert alert-danger">' . $admin_language['invalid_mcassoc_key'] . '</div>';
}

} else {
// Invalid token
$message = '<div class="alert alert-danger">' . $admin_language['invalid_token'] . '</div>';
}
}

// Get mcassoc settings
$use_mcassoc = $queries->getWhere('settings', array('name', '=', 'use_mcassoc'));
$use_mcassoc = $use_mcassoc[0]->value;

$mcassoc_key = $queries->getWhere('settings', array('name', '=', 'mcassoc_key'));
$mcassoc_key = htmlspecialchars($mcassoc_key[0]->value);

$mcassoc_instance = $queries->getWhere('settings', array('name', '=', 'mcassoc_instance'));
$mcassoc_instance = htmlspecialchars($mcassoc_instance[0]->value);

?>
<h3><?php echo $admin_language['mcassoc']; ?></h3>
<?php if(isset($message)) echo $message; ?>
<form action="" method="post">
<div class="form-group">
<div class="row">
<div class="col-md-5">
<div class="form-group">
<label for="use_mcassoc"><?php echo $admin_language['use_mcassoc']; ?></label> <a class="btn btn-info btn-xs" href="#" data-toggle="popover" data-content="<?php echo $admin_language['use_mcassoc_help']; ?>"><i class="fa fa-question-circle"></i></a>
<span class="pull-right">
<input id="use_mcassoc" name="use_mcassoc" type="checkbox" class="js-switch" <?php if($use_mcassoc == '1'){ ?>checked <?php } ?>/>
</span>
</div>
</div>
</div>
<div class="form-group">
<label for="mcassoc_key"><?php echo $admin_language['mcassoc_key']; ?></label>
<input type="text" class="form-control" name="mcassoc_key" id="mcassoc_key" value="<?php echo $mcassoc_key; ?>" placeholder="<?php echo $admin_language['mcassoc_key']; ?>">
</div>
<div class="form-group">
<label for="mcassoc_instance"><?php echo $admin_language['mcassoc_instance']; ?></label>
<input type="text" class="form-control" name="mcassoc_instance" id="mcassoc_instance" value="<?php echo $mcassoc_instance; ?>" placeholder="<?php echo $admin_language['mcassoc_instance']; ?>">
<p><?php echo $admin_language['mcassoc_instance_help']; ?></p>
</div>
<div class="form-group">
<input type="hidden" name="token" value="<?php echo Token::generate(); ?>">
<input type="submit" class="btn btn-primary" value="<?php echo $general_language['submit']; ?>">
</div>
</div>
</form>
<?php
}
?>
</div>
Expand Down

0 comments on commit dfc1b06

Please sign in to comment.