Merge branch 'docker' of github.com:m1k1o/blog into docker
This commit is contained in:
commit
c7a4c5e2c5
6 changed files with 22 additions and 24 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);
|
||||
|
@ -138,15 +142,10 @@ class Image
|
|||
$name, $ext, $md5
|
||||
)->last_id();
|
||||
|
||||
// Ensure, that directories exists
|
||||
if((!is_dir(self::IMAGES) && !mkdir(self::IMAGES)) || (!is_dir(self::THUMBS) && !mkdir(self::THUMBS))){
|
||||
throw new Exception("Images / thumbnails directories could not be created.");
|
||||
}
|
||||
|
||||
// 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)){
|
||||
|
|
|
@ -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