Guild logo upload

This commit is contained in:
rigaer@hotmail.es 2014-05-18 20:28:11 +02:00
parent 48d6483a82
commit 721a52867f
4 changed files with 250 additions and 63 deletions

View File

@ -49,6 +49,68 @@
// ------------------- \\ // ------------------- \\
// CUSTOM SERVER STUFF \\ // 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. // Vocation ids and names.
$config['vocations'] = array( $config['vocations'] = array(
@ -234,6 +296,9 @@
// Restricted names // Restricted names
$config['invalidNameTags'] = array("god", "gm", "cm", "gamemaster", "hoster", "admin", "admim", "adm", "owner", "staff"); $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). // Level requirement to create guild? (Just set it to 1 to allow all levels).
$config['create_guild_level'] = 8; $config['create_guild_level'] = 8;

View File

@ -407,4 +407,103 @@ function sanitize($data) {
function output_errors($errors) { function output_errors($errors) {
return '<ul><li>'. implode('</li><li>', $errors) .'</li></ul>'; 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';
}
}
?> ?>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -167,7 +167,7 @@ if (user_logged_in() === true) {
// Display the specific guild page // 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> ?> </h1>
<table id="guildViewTable" class="table table-striped"> <table id="guildViewTable" class="table table-striped">
<tr class="yellow"> <tr class="yellow">
@ -534,8 +534,31 @@ if ($highest_access >= 2) {
<?php <?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 --> <!-- forms to invite character -->
<form action="" method="post"> <form action="" method="post">
<ul> <ul>