Merge branch 'master' of github.com:m1k1o/blog into docker
This commit is contained in:
commit
2b3b05fe6c
6 changed files with 23 additions and 20 deletions
13
.gitignore
vendored
Normal file → Executable file
13
.gitignore
vendored
Normal file → Executable file
|
@ -1,18 +1,9 @@
|
|||
custom.ini
|
||||
|
||||
# Ignore images content
|
||||
# Ignore images & thumbnails directories (legacy)
|
||||
i/*
|
||||
!i/.gitkeep
|
||||
|
||||
# Ignore thumbnails content
|
||||
t/*
|
||||
!t/.gitkeep
|
||||
|
||||
# Ignore all files in data but keep folder itself (and logs subfolder)
|
||||
# Ignore all files in data but keep directory itself
|
||||
data/*
|
||||
!data/.gitkeep
|
||||
!data/logs/
|
||||
|
||||
# Ignore all logs files but keep folder itself
|
||||
data/logs/*
|
||||
!data/logs/.gitkeep
|
||||
|
|
|
@ -3,9 +3,6 @@ defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
|||
|
||||
class Image
|
||||
{
|
||||
const IMAGES = 'i/';
|
||||
const THUMBS = 't/';
|
||||
|
||||
const THUMB_W = 476;
|
||||
const THUMB_H = 476;
|
||||
|
||||
|
@ -126,6 +123,13 @@ class Image
|
|||
return $d;
|
||||
}
|
||||
|
||||
// Ensure, that directories exists
|
||||
$_images_path = Config::get('images_path');
|
||||
$_thumbnails_path = Config::get('thumbnails_path');
|
||||
if((!is_dir($_images_path) && !mkdir($_images_path, 755, true)) || (!is_dir($_thumbnails_path) && !mkdir($_thumbnails_path, 755, true))){
|
||||
throw new Exception("Images or thumbnails directory could not be created.");
|
||||
}
|
||||
|
||||
// Get metadata
|
||||
$name = $_FILES['file']['name'];
|
||||
$ext = pathinfo($name, PATHINFO_EXTENSION);
|
||||
|
@ -140,12 +144,12 @@ class Image
|
|||
|
||||
// Create path name
|
||||
$name = dechex($id).self::random_str(3).".".$ext;
|
||||
$path = self::IMAGES.$name;
|
||||
$thumb = self::THUMBS.$name;
|
||||
$path = $_images_path.$name;
|
||||
$thumb = $_thumbnails_path.$name;
|
||||
|
||||
// Save path
|
||||
if(!move_uploaded_file($_FILES['file']['tmp_name'], $path)){
|
||||
throw new Exception("File cannot be written to image folders.");
|
||||
throw new Exception("File cannot be written to image directory.");
|
||||
}
|
||||
|
||||
// Create thumb
|
||||
|
|
|
@ -3,8 +3,6 @@ defined('PROJECT_PATH') OR exit('No direct script access allowed');
|
|||
|
||||
class Log
|
||||
{
|
||||
const PATH = 'data/logs/';
|
||||
|
||||
private static $_files = [
|
||||
"ajax_access",
|
||||
"ajax_errors",
|
||||
|
@ -17,7 +15,12 @@ class Log
|
|||
return ;
|
||||
}
|
||||
|
||||
if(false === file_put_contents(PROJECT_PATH.static::PATH.$_file.".log", self::line($_text), FILE_APPEND) && Config::get_safe('debug', false)){
|
||||
$_logs_path = Config::get('logs_path');
|
||||
if(!is_dir($_logs_path) && !mkdir($_logs_path, 755, true)){
|
||||
die("Logs directory could not be created.");
|
||||
}
|
||||
|
||||
if(false === file_put_contents($_logs_path.$_file.".log", self::line($_text), FILE_APPEND) && Config::get_safe('debug', false)){
|
||||
die(sprintf("Can't write to %s.log file.", $_file));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,11 @@ pass = demo
|
|||
;visitor[user] = pass
|
||||
;visitor[user] = pass
|
||||
|
||||
[directories]
|
||||
images_path = data/i/
|
||||
thumbnails_path = data/t/
|
||||
logs_path = data/logs/
|
||||
|
||||
[system]
|
||||
system_name = blog
|
||||
version = 1.18
|
||||
|
|
Loading…
Reference in a new issue