diff --git a/.gitignore b/.gitignore index 04e4b02e..e24ffb58 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,10 @@ templates/* images/guilds/* !images/guilds/default.gif +# editor images +images/editor/* +!images/editor/index.html + # cache system/cache/* !system/cache/index.html @@ -54,9 +58,5 @@ landing # system system/functions_custom.php -# user data -user/* -!user/index.html - # others/rest system/pages/downloads.php diff --git a/admin/tools/upload_image.php b/admin/tools/upload_image.php index be39b9ed..5d881f18 100644 --- a/admin/tools/upload_image.php +++ b/admin/tools/upload_image.php @@ -15,7 +15,7 @@ if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') { return; } -$imageFolder = BASE . 'images/editor'; +$imageFolder = BASE . EDITOR_IMAGES_DIR; reset ($_FILES); $temp = current($_FILES); @@ -43,7 +43,7 @@ if (is_uploaded_file($temp['tmp_name'])) { 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]); } else { // Notify editor that the upload failed diff --git a/common.php b/common.php index 1874b15f..2d4cf7e3 100644 --- a/common.php +++ b/common.php @@ -68,6 +68,12 @@ const TEMPLATES = BASE . 'templates/'; const TOOLS = BASE . 'tools/'; 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 const MENU_CATEGORY_NEWS = 1; const MENU_CATEGORY_ACCOUNT = 2; @@ -89,7 +95,7 @@ const TFS_LAST = TFS_03; // other definitions const ACCOUNT_NUMBER_LENGTH = 8; -session_save_path(SYSTEM . 'php_sessions'); +session_save_path(SESSIONS_DIR); session_start(); // basedir diff --git a/install/steps/3-requirements.php b/install/steps/3-requirements.php index cd727f0d..659e3036 100644 --- a/install/steps/3-requirements.php +++ b/install/steps/3-requirements.php @@ -7,8 +7,8 @@ $dirs_required = [ 'system/cache', ]; $dirs_optional = [ - 'images/guilds' => $locale['step_requirements_warning_images_guilds'], - 'images/gallery' => $locale['step_requirements_warning_images_gallery'], + GUILD_IMAGES_DIR => $locale['step_requirements_warning_images_guilds'], + GALLERY_DIR => $locale['step_requirements_warning_images_gallery'], ]; $extensions_required = [ diff --git a/system/migrations/11.php b/system/migrations/11.php index 91cd92fe..dc335577 100644 --- a/system/migrations/11.php +++ b/system/migrations/11.php @@ -3,12 +3,12 @@ $db->query("RENAME TABLE " . TABLE_PREFIX . "screenshots TO " . TABLE_PREFIX . "gallery, " . TABLE_PREFIX . "movies TO " . TABLE_PREFIX . "videos;"); - + // rename images dir - if(file_exists(BASE . 'images/screenshots') && !file_exists(BASE .'images/gallery')) { - rename(BASE . 'images/screenshots', BASE . 'images/gallery'); + if(file_exists(BASE . 'images/screenshots') && !file_exists(BASE . GALLERY_DIR)) { + rename(BASE . 'images/screenshots', BASE . GALLERY_DIR); } - + // convert old database screenshots images to gallery $query = $db->query('SELECT `id`, `image`, `thumb` FROM `' . TABLE_PREFIX . 'gallery`;'); foreach($query->fetchAll() as $item) { @@ -17,4 +17,4 @@ 'thumb' => str_replace('/screenshots/', '/gallery/', $item['thumb']), ), array('id' => $item['id'])); } -?> \ No newline at end of file +?> diff --git a/system/pages/gallery.php b/system/pages/gallery.php index 58e34598..8cbf3975 100644 --- a/system/pages/gallery.php +++ b/system/pages/gallery.php @@ -145,8 +145,8 @@ class Gallery $pathinfo = pathinfo($image); $extension = strtolower($pathinfo['extension']); - $thumb_filename = 'images/gallery/' . $pathinfo['filename'] . '_thumb.' . $extension; - $filename = 'images/gallery/' . $pathinfo['filename'] . '.' . $extension; + $thumb_filename = GALLERY_DIR . $pathinfo['filename'] . '_thumb.' . $extension; + $filename = GALLERY_DIR . $pathinfo['filename'] . '.' . $extension; if($db->insert(TABLE_PREFIX . 'gallery', array( 'comment' => $comment, 'image' => $filename, 'author' => $author, @@ -172,7 +172,7 @@ class Gallery $pathinfo = pathinfo($image); $extension = strtolower($pathinfo['extension']); - $filename = 'images/gallery/' . $pathinfo['filename'] . '.' . $extension; + $filename = GALLERY_DIR . $pathinfo['filename'] . '.' . $extension; if($db->update(TABLE_PREFIX . 'gallery', array( 'comment' => $comment, @@ -291,7 +291,7 @@ class Gallery { $pathinfo = pathinfo($file); $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)) return false; diff --git a/system/pages/guilds/change_logo.php b/system/pages/guilds/change_logo.php index 2430360d..109b2379 100644 --- a/system/pages/guilds/change_logo.php +++ b/system/pages/guilds/change_logo.php @@ -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'); $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_path = 'images/guilds/' . $save_file_name; + $save_path = GUILD_IMAGES_DIR . $save_file_name; if(isset($_REQUEST['todo']) && $_REQUEST['todo'] == 'save') { $file = $_FILES['newlogo']; @@ -74,12 +74,12 @@ if(empty($errors)) { { $guild_logo = $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"; } 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'); - 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"; } @@ -122,4 +122,4 @@ if(!empty($errors)) { 'action' => '?subtopic=guilds' )); } -?> \ No newline at end of file +?> diff --git a/system/pages/guilds/list_of_guilds.php b/system/pages/guilds/list_of_guilds.php index 1d827c7f..c20825cc 100644 --- a/system/pages/guilds/list_of_guilds.php +++ b/system/pages/guilds/list_of_guilds.php @@ -19,7 +19,7 @@ if(count($guilds_list) > 0) { foreach ($guilds_list as $guild) { $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"; $description = $guild->getCustomField('description'); @@ -36,4 +36,4 @@ $twig->display('guilds.list.html.twig', array( 'guilds' => $guilds, 'logged' => isset($logged) ? $logged : false, 'isAdmin' => admin(), -)); \ No newline at end of file +)); diff --git a/system/pages/guilds/show.php b/system/pages/guilds/show.php index ebd04ce6..10a8eeef 100644 --- a/system/pages/guilds/show.php +++ b/system/pages/guilds/show.php @@ -77,7 +77,7 @@ if($logged) //show guild page $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"; $description = $guild->getCustomField('description'); @@ -159,4 +159,4 @@ $twig->display('guilds.view.html.twig', array( 'invited_list' => $invited_list, 'show_accept_invite' => $show_accept_invite, 'useGuildNick' => $useGuildNick -)); \ No newline at end of file +)); diff --git a/system/templates/guilds.change_logo.html.twig b/system/templates/guilds.change_logo.html.twig index 9205b7a0..f8aa002e 100644 --- a/system/templates/guilds.change_logo.html.twig +++ b/system/templates/guilds.change_logo.html.twig @@ -1,5 +1,5 @@