mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-04-30 03:09:22 +02:00
Merge pull request #120 from Alvaritos/master
Guild logo upload and Market item name
This commit is contained in:
commit
e52fb6a2ef
@ -296,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;
|
||||||
|
|
||||||
|
@ -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';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
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
|
// 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>
|
||||||
|
10
market.php
10
market.php
@ -25,6 +25,7 @@ if (!$compare) {
|
|||||||
<h2>WTS: Want to sell</h2>
|
<h2>WTS: Want to sell</h2>
|
||||||
<table class="table tbl-hover">
|
<table class="table tbl-hover">
|
||||||
<tr class="yellow">
|
<tr class="yellow">
|
||||||
|
<td>Item name</td>
|
||||||
<td>Item</td>
|
<td>Item</td>
|
||||||
<td>Count</td>
|
<td>Count</td>
|
||||||
<td>Price for 1</td>
|
<td>Price for 1</td>
|
||||||
@ -36,6 +37,7 @@ if (!$compare) {
|
|||||||
foreach (($offers['wts'] ? $offers['wts'] : array()) as $o) {
|
foreach (($offers['wts'] ? $offers['wts'] : array()) as $o) {
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><?php getItemNameById($o['item_id']); ?></td>
|
||||||
<td><img src="<?php echo "http://".$server."/".$o['item_id'].".".$imageType; ?>" alt="Item Image"></td>
|
<td><img src="<?php echo "http://".$server."/".$o['item_id'].".".$imageType; ?>" alt="Item Image"></td>
|
||||||
<td><?php echo $o['amount']; ?></td>
|
<td><?php echo $o['amount']; ?></td>
|
||||||
<td><?php echo number_format($o['price'], 0, "", " "); ?></td>
|
<td><?php echo number_format($o['price'], 0, "", " "); ?></td>
|
||||||
@ -50,6 +52,7 @@ if (!$compare) {
|
|||||||
<h2>WTB: Want to buy</h2>
|
<h2>WTB: Want to buy</h2>
|
||||||
<table class="table tbl-hover">
|
<table class="table tbl-hover">
|
||||||
<tr class="yellow">
|
<tr class="yellow">
|
||||||
|
<td>Item name</td>
|
||||||
<td>Item</td>
|
<td>Item</td>
|
||||||
<td>Count</td>
|
<td>Count</td>
|
||||||
<td>Price for 1</td>
|
<td>Price for 1</td>
|
||||||
@ -61,6 +64,7 @@ if (!$compare) {
|
|||||||
foreach (($offers['wtb'] ? $offers['wtb'] : array()) as $o) {
|
foreach (($offers['wtb'] ? $offers['wtb'] : array()) as $o) {
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><?php getItemNameById($o['item_id']); ?></td>
|
||||||
<td><img src="<?php echo "http://".$server."/".$o['item_id'].".".$imageType; ?>" alt="Item Image"></td>
|
<td><img src="<?php echo "http://".$server."/".$o['item_id'].".".$imageType; ?>" alt="Item Image"></td>
|
||||||
<td><?php echo $o['amount']; ?></td>
|
<td><?php echo $o['amount']; ?></td>
|
||||||
<td><?php echo number_format($o['price'], 0, "", " "); ?></td>
|
<td><?php echo number_format($o['price'], 0, "", " "); ?></td>
|
||||||
@ -88,6 +92,7 @@ if (!$compare) {
|
|||||||
<h2>Active offers</h2>
|
<h2>Active offers</h2>
|
||||||
<table class="table tbl-hover">
|
<table class="table tbl-hover">
|
||||||
<tr class="yellow">
|
<tr class="yellow">
|
||||||
|
<td>Item name</td>
|
||||||
<td>Item</td>
|
<td>Item</td>
|
||||||
<td>Count</td>
|
<td>Count</td>
|
||||||
<td>Price for 1</td>
|
<td>Price for 1</td>
|
||||||
@ -104,6 +109,7 @@ if (!$compare) {
|
|||||||
} else {
|
} else {
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><?php getItemNameById($o['item_id']); ?></td>
|
||||||
<td><img src="<?php echo "http://".$server."/".$o['item_id'].".".$imageType; ?>" alt="Item Image"></td>
|
<td><img src="<?php echo "http://".$server."/".$o['item_id'].".".$imageType; ?>" alt="Item Image"></td>
|
||||||
<td><?php echo $o['amount']; ?></td>
|
<td><?php echo $o['amount']; ?></td>
|
||||||
<td><?php echo number_format($o['price'], 0, "", " "); ?></td>
|
<td><?php echo number_format($o['price'], 0, "", " "); ?></td>
|
||||||
@ -121,6 +127,7 @@ if (!$compare) {
|
|||||||
<h2>Want to buy:</h2>
|
<h2>Want to buy:</h2>
|
||||||
<table class="table tbl-hover">
|
<table class="table tbl-hover">
|
||||||
<tr class="yellow">
|
<tr class="yellow">
|
||||||
|
<td>Item name</td>
|
||||||
<td>Item</td>
|
<td>Item</td>
|
||||||
<td>Count</td>
|
<td>Count</td>
|
||||||
<td>Price for 1</td>
|
<td>Price for 1</td>
|
||||||
@ -131,6 +138,7 @@ if (!$compare) {
|
|||||||
foreach ($buylist as $o) {
|
foreach ($buylist as $o) {
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><?php getItemNameById($o['item_id']); ?></td>
|
||||||
<td><img src="<?php echo "http://".$server."/".$o['item_id'].".".$imageType; ?>" alt="Item Image"></td>
|
<td><img src="<?php echo "http://".$server."/".$o['item_id'].".".$imageType; ?>" alt="Item Image"></td>
|
||||||
<td><?php echo $o['amount']; ?></td>
|
<td><?php echo $o['amount']; ?></td>
|
||||||
<td><?php echo number_format($o['price'], 0, "", " "); ?></td>
|
<td><?php echo number_format($o['price'], 0, "", " "); ?></td>
|
||||||
@ -147,6 +155,7 @@ if (!$compare) {
|
|||||||
<h2>Old purchased offers</h2>
|
<h2>Old purchased offers</h2>
|
||||||
<table class="table tbl-hover">
|
<table class="table tbl-hover">
|
||||||
<tr class="yellow">
|
<tr class="yellow">
|
||||||
|
<td>Item name</td>
|
||||||
<td>Item</td>
|
<td>Item</td>
|
||||||
<td>Count</td>
|
<td>Count</td>
|
||||||
<td>Price for 1</td>
|
<td>Price for 1</td>
|
||||||
@ -156,6 +165,7 @@ if (!$compare) {
|
|||||||
foreach (($historyOffers ? $historyOffers : array()) as $o) {
|
foreach (($historyOffers ? $historyOffers : array()) as $o) {
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
|
<td><?php getItemNameById($o['item_id']); ?></td>
|
||||||
<td><img src="<?php echo "http://".$server."/".$o['item_id'].".".$imageType; ?>" alt="Item Image"></td>
|
<td><img src="<?php echo "http://".$server."/".$o['item_id'].".".$imageType; ?>" alt="Item Image"></td>
|
||||||
<td><?php echo $o['amount']; ?></td>
|
<td><?php echo $o['amount']; ?></td>
|
||||||
<td><?php echo number_format($o['price'], 0, "", " "); ?></td>
|
<td><?php echo number_format($o['price'], 0, "", " "); ?></td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user