mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-05-01 11:49:21 +02:00
Guild logo upload
This commit is contained in:
parent
48d6483a82
commit
721a52867f
65
config.php
65
config.php
@ -49,6 +49,68 @@
|
||||
// ------------------- \\
|
||||
// CUSTOM SERVER STUFF \\
|
||||
// ------------------- \\
|
||||
// Enable / disable Questlog function (true / false)
|
||||
$config['EnableQuests'] = false;
|
||||
|
||||
// array for filling questlog (Questid, max value, name, end of the quest fill 1 for the last part 0 for all others)
|
||||
$config['Quests'] = array(
|
||||
array(1501,100,'Killing in the Name of',0),
|
||||
array(1502,150,'Killing in the Name of',0),
|
||||
array(65001,100,'Killing in the Name of',0),
|
||||
array(65002,150,'Killing in the Name of',0),
|
||||
array(65003,300,'Killing in the Name of',0),
|
||||
array(65004,3,'Killing in the Name of',0),
|
||||
array(65005,300,'Killing in the Name of',0),
|
||||
array(65006,150,'Killing in the Name of',0),
|
||||
array(65007,200,'Killing in the Name of',0),
|
||||
array(65008,300,'Killing in the Name of',0),
|
||||
array(65009,300,'Killing in the Name of',0),
|
||||
array(65010,300,'Killing in the Name of',0),
|
||||
array(65011,300,'Killing in the Name of',0),
|
||||
array(65012,300,'Killing in the Name of',0),
|
||||
array(65013,300,'Killing in the Name of',0),
|
||||
array(65014,300,'Killing in the Name of',1),
|
||||
array(12110,2,'The Inquisition',0),
|
||||
array(12111,7,'The Inquisition',0),
|
||||
array(12112,3,'The Inquisition',0),
|
||||
array(12113,6,'The Inquisition',0),
|
||||
array(12114,3,'The Inquisition',0),
|
||||
array(12115,3,'The Inquisition',0),
|
||||
array(12116,3,'The Inquisition',0),
|
||||
array(12117,5,'The Inquisition',1),
|
||||
array(330,3,'Sam\'s Old Backpack',1),
|
||||
array(12121,3,'The Ape City',0),
|
||||
array(12122,5,'The Ape City',0),
|
||||
array(12123,3,'The Ape City',0),
|
||||
array(12124,3,'The Ape City',0),
|
||||
array(12125,3,'The Ape City',0),
|
||||
array(12126,3,'The Ape City',0),
|
||||
array(12127,4,'The Ape City',0),
|
||||
array(12128,3,'The Ape City',0),
|
||||
array(12129,3,'The Ape City',1),
|
||||
array(12101,1,'The Ancient Tombs',0),
|
||||
array(12102,1,'The Ancient Tombs',0),
|
||||
array(12103,1,'The Ancient Tombs',0),
|
||||
array(12104,1,'The Ancient Tombs',0),
|
||||
array(12105,1,'The Ancient Tombs',0),
|
||||
array(12106,1,'The Ancient Tombs',0),
|
||||
array(12107,1,'The Ancient Tombs',1),
|
||||
array(12022,3,'Barbarian Test Quest',0),
|
||||
array(12022,3,'Barbarian Test Quest',0),
|
||||
array(12022,3,'Barbarian Test Quest',1),
|
||||
array(12025,3,'The Ice Islands Quest',0),
|
||||
array(12026,5,'The Ice Islands Quest',0),
|
||||
array(12027,3,'The Ice Islands Quest',0),
|
||||
array(12028,2,'The Ice Islands Quest',0),
|
||||
array(12029,6,'The Ice Islands Quest',0),
|
||||
array(12030,8,'The Ice Islands Quest',0),
|
||||
array(12031,3,'The Ice Islands Quest',0),
|
||||
array(12032,4,'The Ice Islands Quest',0),
|
||||
array(12033,2,'The Ice Islands Quest',0),
|
||||
array(12034,2,'The Ice Islands Quest',0),
|
||||
array(12035,2,'The Ice Islands Quest',0),
|
||||
array(12036,6,'The Ice Islands Quest',1),
|
||||
);
|
||||
|
||||
// Vocation ids and names.
|
||||
$config['vocations'] = array(
|
||||
@ -234,6 +296,9 @@
|
||||
// Restricted names
|
||||
$config['invalidNameTags'] = array("god", "gm", "cm", "gamemaster", "hoster", "admin", "admim", "adm", "owner", "staff");
|
||||
|
||||
// Use guild logo system
|
||||
$config['use_guild_logos'] = 4;
|
||||
|
||||
// Level requirement to create guild? (Just set it to 1 to allow all levels).
|
||||
$config['create_guild_level'] = 8;
|
||||
|
||||
|
@ -407,4 +407,103 @@ function sanitize($data) {
|
||||
function output_errors($errors) {
|
||||
return '<ul><li>'. implode('</li><li>', $errors) .'</li></ul>';
|
||||
}
|
||||
|
||||
// Resize images
|
||||
|
||||
function resize_imagex($file, $width, $height) {
|
||||
|
||||
list($w, $h) = getimagesize($file['tmp']);
|
||||
|
||||
$ratio = max($width/$w, $height/$h);
|
||||
$h = ceil($height / $ratio);
|
||||
$x = ($w - $width / $ratio) / 2;
|
||||
$w = ceil($width / $ratio);
|
||||
|
||||
$path = 'engine/guildimg/'.$file['new_name'];
|
||||
|
||||
$imgString = file_get_contents($file['tmp']);
|
||||
|
||||
$image = imagecreatefromstring($imgString);
|
||||
$tmp = imagecreatetruecolor($width, $height);
|
||||
imagecopyresampled($tmp, $image,
|
||||
0, 0,
|
||||
$x, 0,
|
||||
$width, $height,
|
||||
$w, $h);
|
||||
|
||||
imagegif($tmp, $path);
|
||||
imagedestroy($image);
|
||||
imagedestroy($tmp);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Guild logo upload security
|
||||
function check_image($image) {
|
||||
|
||||
$image_data = array('new_name' => $_GET['name'].'.gif', 'name' => $image['name'], 'tmp' => $image['tmp_name'], 'error' => $image['error'], 'size' => $image['size'], 'type' => $image['type']);
|
||||
|
||||
// First security check, quite useless but still do its job
|
||||
if ($image_data['type'] === 'image/gif') {
|
||||
|
||||
// Second security check, lets go
|
||||
$check = getimagesize($image_data['tmp']);
|
||||
|
||||
if ($check) {
|
||||
|
||||
// Third
|
||||
if ($check['mime'] === 'image/gif') {
|
||||
|
||||
$path_info = pathinfo($image_data['name']);
|
||||
|
||||
// Last one
|
||||
if ($path_info['extension'] === 'gif') {
|
||||
|
||||
// Resize image
|
||||
$img = resize_imagex($image_data, 150, 150);
|
||||
|
||||
if ($img) {
|
||||
|
||||
header('Location: guilds.php?name='. $_GET['name']);
|
||||
exit();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
header('Location: guilds.php?name='. $_GET['name']);
|
||||
exit();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
header('Location: guilds.php?name='. $_GET['name']);
|
||||
exit();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
header('Location: guilds.php?name='. $_GET['name']);
|
||||
exit();
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
header('Location: guilds.php?name='. $_GET['name']);
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
// Check guild logo
|
||||
function logo_exists($guild) {
|
||||
|
||||
if (file_exists('engine/guildimg/'.$guild.'.gif')) {
|
||||
|
||||
echo'engine/guildimg/'.$guild.'.gif';
|
||||
|
||||
} else {
|
||||
|
||||
echo'engine/guildimg/default@logo.gif';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
BIN
engine/guildimg/default@logo.gif
Normal file
BIN
engine/guildimg/default@logo.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
25
guilds.php
25
guilds.php
@ -167,7 +167,7 @@ if (user_logged_in() === true) {
|
||||
// Display the specific guild page
|
||||
?>
|
||||
|
||||
<h1>Guild: <?php echo sanitize($_GET['name']);
|
||||
<h1><img src="<?php logo_exists(sanitize($_GET['name'])); ?>"></img> Guild: <?php echo sanitize($_GET['name']);
|
||||
?> </h1>
|
||||
<table id="guildViewTable" class="table table-striped">
|
||||
<tr class="yellow">
|
||||
@ -534,8 +534,31 @@ if ($highest_access >= 2) {
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ($config['use_guild_logos']) {
|
||||
|
||||
?>
|
||||
|
||||
<!-- form to upload guild logo -->
|
||||
<form action="" method="post" enctype="multipart/form-data">
|
||||
<ul>
|
||||
<li>Upload guild logo:<br>
|
||||
<input type="file" name="file" id="file" accept="image/gif">
|
||||
<input type="submit" name="submit" value="Upload guild logo">
|
||||
</li>
|
||||
</ul>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
if (!empty($_FILES['file'])) {
|
||||
|
||||
check_image($_FILES['file']);
|
||||
|
||||
echo '<br><br>';
|
||||
}
|
||||
|
||||
} ?>
|
||||
<!-- forms to invite character -->
|
||||
<form action="" method="post">
|
||||
<ul>
|
||||
|
Loading…
x
Reference in New Issue
Block a user