mirror of
https://github.com/slawkens/myaac.git
synced 2025-11-27 21:56:50 +01:00
Made so it's possible to configure more directories as constants
More flexibility for the user.
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@@ -24,6 +24,10 @@ templates/*
|
|||||||
images/guilds/*
|
images/guilds/*
|
||||||
!images/guilds/default.gif
|
!images/guilds/default.gif
|
||||||
|
|
||||||
|
# editor images
|
||||||
|
images/editor/*
|
||||||
|
!images/editor/index.html
|
||||||
|
|
||||||
# cache
|
# cache
|
||||||
system/cache/*
|
system/cache/*
|
||||||
!system/cache/index.html
|
!system/cache/index.html
|
||||||
@@ -54,9 +58,5 @@ landing
|
|||||||
# system
|
# system
|
||||||
system/functions_custom.php
|
system/functions_custom.php
|
||||||
|
|
||||||
# user data
|
|
||||||
user/*
|
|
||||||
!user/index.html
|
|
||||||
|
|
||||||
# others/rest
|
# others/rest
|
||||||
system/pages/downloads.php
|
system/pages/downloads.php
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$imageFolder = BASE . 'images/editor';
|
$imageFolder = BASE . EDITOR_IMAGES_DIR;
|
||||||
|
|
||||||
reset ($_FILES);
|
reset ($_FILES);
|
||||||
$temp = current($_FILES);
|
$temp = current($_FILES);
|
||||||
@@ -43,7 +43,7 @@ if (is_uploaded_file($temp['tmp_name'])) {
|
|||||||
|
|
||||||
move_uploaded_file($temp['tmp_name'], $fileToWrite);
|
move_uploaded_file($temp['tmp_name'], $fileToWrite);
|
||||||
|
|
||||||
$returnPathToImage = BASE_URL . 'images/editor/' . $randomName;
|
$returnPathToImage = BASE_URL . EDITOR_IMAGES_DIR . $randomName;
|
||||||
echo json_encode(['location' => $returnPathToImage]);
|
echo json_encode(['location' => $returnPathToImage]);
|
||||||
} else {
|
} else {
|
||||||
// Notify editor that the upload failed
|
// Notify editor that the upload failed
|
||||||
|
|||||||
@@ -68,6 +68,12 @@ const TEMPLATES = BASE . 'templates/';
|
|||||||
const TOOLS = BASE . 'tools/';
|
const TOOLS = BASE . 'tools/';
|
||||||
const VENDOR = BASE . 'vendor/';
|
const VENDOR = BASE . 'vendor/';
|
||||||
|
|
||||||
|
// other dirs
|
||||||
|
const SESSIONS_DIR = SYSTEM . 'php_sessions';
|
||||||
|
const GUILD_IMAGES_DIR = 'user_images/';
|
||||||
|
const EDITOR_IMAGES_DIR = 'images/editor/';
|
||||||
|
const GALLERY_DIR = 'images/gallery/';
|
||||||
|
|
||||||
// menu categories
|
// menu categories
|
||||||
const MENU_CATEGORY_NEWS = 1;
|
const MENU_CATEGORY_NEWS = 1;
|
||||||
const MENU_CATEGORY_ACCOUNT = 2;
|
const MENU_CATEGORY_ACCOUNT = 2;
|
||||||
@@ -89,7 +95,7 @@ const TFS_LAST = TFS_03;
|
|||||||
// other definitions
|
// other definitions
|
||||||
const ACCOUNT_NUMBER_LENGTH = 8;
|
const ACCOUNT_NUMBER_LENGTH = 8;
|
||||||
|
|
||||||
session_save_path(SYSTEM . 'php_sessions');
|
session_save_path(SESSIONS_DIR);
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
// basedir
|
// basedir
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ $dirs_required = [
|
|||||||
'system/cache',
|
'system/cache',
|
||||||
];
|
];
|
||||||
$dirs_optional = [
|
$dirs_optional = [
|
||||||
'images/guilds' => $locale['step_requirements_warning_images_guilds'],
|
GUILD_IMAGES_DIR => $locale['step_requirements_warning_images_guilds'],
|
||||||
'images/gallery' => $locale['step_requirements_warning_images_gallery'],
|
GALLERY_DIR => $locale['step_requirements_warning_images_gallery'],
|
||||||
];
|
];
|
||||||
|
|
||||||
$extensions_required = [
|
$extensions_required = [
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
$db->query("RENAME TABLE
|
$db->query("RENAME TABLE
|
||||||
" . TABLE_PREFIX . "screenshots TO " . TABLE_PREFIX . "gallery,
|
" . TABLE_PREFIX . "screenshots TO " . TABLE_PREFIX . "gallery,
|
||||||
" . TABLE_PREFIX . "movies TO " . TABLE_PREFIX . "videos;");
|
" . TABLE_PREFIX . "movies TO " . TABLE_PREFIX . "videos;");
|
||||||
|
|
||||||
// rename images dir
|
// rename images dir
|
||||||
if(file_exists(BASE . 'images/screenshots') && !file_exists(BASE .'images/gallery')) {
|
if(file_exists(BASE . 'images/screenshots') && !file_exists(BASE . GALLERY_DIR)) {
|
||||||
rename(BASE . 'images/screenshots', BASE . 'images/gallery');
|
rename(BASE . 'images/screenshots', BASE . GALLERY_DIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert old database screenshots images to gallery
|
// convert old database screenshots images to gallery
|
||||||
$query = $db->query('SELECT `id`, `image`, `thumb` FROM `' . TABLE_PREFIX . 'gallery`;');
|
$query = $db->query('SELECT `id`, `image`, `thumb` FROM `' . TABLE_PREFIX . 'gallery`;');
|
||||||
foreach($query->fetchAll() as $item) {
|
foreach($query->fetchAll() as $item) {
|
||||||
@@ -17,4 +17,4 @@
|
|||||||
'thumb' => str_replace('/screenshots/', '/gallery/', $item['thumb']),
|
'thumb' => str_replace('/screenshots/', '/gallery/', $item['thumb']),
|
||||||
), array('id' => $item['id']));
|
), array('id' => $item['id']));
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -145,8 +145,8 @@ class Gallery
|
|||||||
|
|
||||||
$pathinfo = pathinfo($image);
|
$pathinfo = pathinfo($image);
|
||||||
$extension = strtolower($pathinfo['extension']);
|
$extension = strtolower($pathinfo['extension']);
|
||||||
$thumb_filename = 'images/gallery/' . $pathinfo['filename'] . '_thumb.' . $extension;
|
$thumb_filename = GALLERY_DIR . $pathinfo['filename'] . '_thumb.' . $extension;
|
||||||
$filename = 'images/gallery/' . $pathinfo['filename'] . '.' . $extension;
|
$filename = GALLERY_DIR . $pathinfo['filename'] . '.' . $extension;
|
||||||
if($db->insert(TABLE_PREFIX . 'gallery', array(
|
if($db->insert(TABLE_PREFIX . 'gallery', array(
|
||||||
'comment' => $comment,
|
'comment' => $comment,
|
||||||
'image' => $filename, 'author' => $author,
|
'image' => $filename, 'author' => $author,
|
||||||
@@ -172,7 +172,7 @@ class Gallery
|
|||||||
|
|
||||||
$pathinfo = pathinfo($image);
|
$pathinfo = pathinfo($image);
|
||||||
$extension = strtolower($pathinfo['extension']);
|
$extension = strtolower($pathinfo['extension']);
|
||||||
$filename = 'images/gallery/' . $pathinfo['filename'] . '.' . $extension;
|
$filename = GALLERY_DIR . $pathinfo['filename'] . '.' . $extension;
|
||||||
|
|
||||||
if($db->update(TABLE_PREFIX . 'gallery', array(
|
if($db->update(TABLE_PREFIX . 'gallery', array(
|
||||||
'comment' => $comment,
|
'comment' => $comment,
|
||||||
@@ -291,7 +291,7 @@ class Gallery
|
|||||||
{
|
{
|
||||||
$pathinfo = pathinfo($file);
|
$pathinfo = pathinfo($file);
|
||||||
$extension = strtolower($pathinfo['extension']);
|
$extension = strtolower($pathinfo['extension']);
|
||||||
$thumb_filename = 'images/gallery/' . $pathinfo['filename'] . '_thumb.' . $extension;
|
$thumb_filename = GALLERY_DIR . $pathinfo['filename'] . '_thumb.' . $extension;
|
||||||
|
|
||||||
if(!self::resize($file, 170, 110, $thumb_filename, $errors))
|
if(!self::resize($file, 170, 110, $thumb_filename, $errors))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ if(empty($errors)) {
|
|||||||
$allowed_ext = array('image/gif', 'image/jpg', 'image/pjpeg', 'image/jpeg', 'image/bmp', 'image/png', 'image/x-png');
|
$allowed_ext = array('image/gif', 'image/jpg', 'image/pjpeg', 'image/jpeg', 'image/bmp', 'image/png', 'image/x-png');
|
||||||
$ext_name = array('image/gif' => 'gif', 'image/jpg' => 'jpg', 'image/jpeg' => 'jpg', 'image/pjpeg' => 'jpg', 'image/bmp' => 'bmp', 'image/png' => 'png', 'image/x-png' => 'png');
|
$ext_name = array('image/gif' => 'gif', 'image/jpg' => 'jpg', 'image/jpeg' => 'jpg', 'image/pjpeg' => 'jpg', 'image/bmp' => 'bmp', 'image/png' => 'png', 'image/x-png' => 'png');
|
||||||
$save_file_name = str_replace(' ', '_', strtolower($guild->getName()));
|
$save_file_name = str_replace(' ', '_', strtolower($guild->getName()));
|
||||||
$save_path = 'images/guilds/' . $save_file_name;
|
$save_path = GUILD_IMAGES_DIR . $save_file_name;
|
||||||
if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save')
|
if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save')
|
||||||
{
|
{
|
||||||
$file = $_FILES['newlogo'];
|
$file = $_FILES['newlogo'];
|
||||||
@@ -74,12 +74,12 @@ if(empty($errors)) {
|
|||||||
{
|
{
|
||||||
$guild_logo = $guild->getCustomField('logo_name');
|
$guild_logo = $guild->getCustomField('logo_name');
|
||||||
$guild_logo = str_replace(array('..', '/', '\\'), array('','',''), $guild->getCustomField('logo_name'));
|
$guild_logo = str_replace(array('..', '/', '\\'), array('','',''), $guild->getCustomField('logo_name'));
|
||||||
if(empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo)) {
|
if(empty($guild_logo) || !file_exists(GUILD_IMAGES_DIR . $guild_logo)) {
|
||||||
$guild_logo = "default.gif";
|
$guild_logo = "default.gif";
|
||||||
}
|
}
|
||||||
|
|
||||||
if($guild_logo != "default.gif" && $guild_logo != $save_file_name.'.'.$extension) {
|
if($guild_logo != "default.gif" && $guild_logo != $save_file_name.'.'.$extension) {
|
||||||
unlink('images/guilds/' . $guild_logo);
|
unlink(GUILD_IMAGES_DIR . $guild_logo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,7 +94,7 @@ if(empty($errors)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$guild_logo = $guild->getCustomField('logo_name');
|
$guild_logo = $guild->getCustomField('logo_name');
|
||||||
if(empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo)) {
|
if(empty($guild_logo) || !file_exists(GUILD_IMAGES_DIR . $guild_logo)) {
|
||||||
$guild_logo = "default.gif";
|
$guild_logo = "default.gif";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,4 +122,4 @@ if(!empty($errors)) {
|
|||||||
'action' => '?subtopic=guilds'
|
'action' => '?subtopic=guilds'
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ if(count($guilds_list) > 0)
|
|||||||
{
|
{
|
||||||
foreach ($guilds_list as $guild) {
|
foreach ($guilds_list as $guild) {
|
||||||
$guild_logo = $guild->getCustomField('logo_name');
|
$guild_logo = $guild->getCustomField('logo_name');
|
||||||
if (empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo))
|
if (empty($guild_logo) || !file_exists(GUILD_IMAGES_DIR . $guild_logo))
|
||||||
$guild_logo = "default.gif";
|
$guild_logo = "default.gif";
|
||||||
|
|
||||||
$description = $guild->getCustomField('description');
|
$description = $guild->getCustomField('description');
|
||||||
@@ -36,4 +36,4 @@ $twig->display('guilds.list.html.twig', array(
|
|||||||
'guilds' => $guilds,
|
'guilds' => $guilds,
|
||||||
'logged' => isset($logged) ? $logged : false,
|
'logged' => isset($logged) ? $logged : false,
|
||||||
'isAdmin' => admin(),
|
'isAdmin' => admin(),
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ if($logged)
|
|||||||
|
|
||||||
//show guild page
|
//show guild page
|
||||||
$guild_logo = $guild->getCustomField('logo_name');
|
$guild_logo = $guild->getCustomField('logo_name');
|
||||||
if(empty($guild_logo) || !file_exists('images/guilds/' . $guild_logo))
|
if(empty($guild_logo) || !file_exists(GUILD_IMAGES_DIR . $guild_logo))
|
||||||
$guild_logo = "default.gif";
|
$guild_logo = "default.gif";
|
||||||
|
|
||||||
$description = $guild->getCustomField('description');
|
$description = $guild->getCustomField('description');
|
||||||
@@ -159,4 +159,4 @@ $twig->display('guilds.view.html.twig', array(
|
|||||||
'invited_list' => $invited_list,
|
'invited_list' => $invited_list,
|
||||||
'show_accept_invite' => $show_accept_invite,
|
'show_accept_invite' => $show_accept_invite,
|
||||||
'useGuildNick' => $useGuildNick
|
'useGuildNick' => $useGuildNick
|
||||||
));
|
));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div style="text-align:center"><h2>Change guild logo</h2></div>
|
<div style="text-align:center"><h2>Change guild logo</h2></div>
|
||||||
Here you can change logo of your guild.<br/>Actuall logo: <img src="images/guilds/{{ guild_logo }}" height="64" width="64"><br/><br/>
|
Here you can change logo of your guild.<br/>Actuall logo: <img src="{{ constant('GUILD_IMAGES_DIR') }}{{ guild_logo }}" height="64" width="64"><br/><br/>
|
||||||
<form enctype="multipart/form-data" action="?subtopic=guilds&guild={{ guild.getName() }}&action=change_logo" method="post" id="upload_form">
|
<form enctype="multipart/form-data" action="?subtopic=guilds&guild={{ guild.getName() }}&action=change_logo" method="post" id="upload_form">
|
||||||
<input type="hidden" name="todo" value="save" />
|
<input type="hidden" name="todo" value="save" />
|
||||||
<input type="hidden" name="MAX_FILE_SIZE" value="{{ max_image_size_b }}" />
|
<input type="hidden" name="MAX_FILE_SIZE" value="{{ max_image_size_b }}" />
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
{% set i = i + 1 %}
|
{% set i = i + 1 %}
|
||||||
<tr bgcolor="{{ getStyle(i) }}">
|
<tr bgcolor="{{ getStyle(i) }}">
|
||||||
<td>
|
<td>
|
||||||
<img src="images/guilds/{{ guild.logo }}" width="64" height="64">
|
<img src="{{ constant('GUILD_IMAGES_DIR') }}{{ guild.logo }}" width="64" height="64">
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
|
|||||||
@@ -5,13 +5,13 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="64">
|
<td width="64">
|
||||||
<img src="images/guilds/{{ logo }}" width="64" height="64">
|
<img src="{{ constant('GUILD_IMAGES_DIR') }}{{ logo }}" width="64" height="64">
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td align="center" width="100%"><h1>{{ guild_name }}</h1></td>
|
<td align="center" width="100%"><h1>{{ guild_name }}</h1></td>
|
||||||
|
|
||||||
<td width="64">
|
<td width="64">
|
||||||
<img src="images/guilds/{{ logo }}" width="64" height="64">
|
<img src="{{ constant('GUILD_IMAGES_DIR') }}{{ logo }}" width="64" height="64">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user