disk full warnings
git-svn-id: file:///home/shish/svn/shimmie2/trunk@921 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
2c3b82a2fb
commit
14dc15c7bd
@ -5,6 +5,8 @@ class Upload extends Extension {
|
|||||||
// event handling {{{
|
// event handling {{{
|
||||||
public function receive_event($event) {
|
public function receive_event($event) {
|
||||||
if(is_null($this->theme)) $this->theme = get_theme_object("upload", "UploadTheme");
|
if(is_null($this->theme)) $this->theme = get_theme_object("upload", "UploadTheme");
|
||||||
|
|
||||||
|
$is_full = (disk_free_space("./images/") < 100*1024*1024);
|
||||||
|
|
||||||
if(is_a($event, 'InitExtEvent')) {
|
if(is_a($event, 'InitExtEvent')) {
|
||||||
global $config;
|
global $config;
|
||||||
@ -16,7 +18,12 @@ class Upload extends Extension {
|
|||||||
if(is_a($event, 'PostListBuildingEvent')) {
|
if(is_a($event, 'PostListBuildingEvent')) {
|
||||||
global $user;
|
global $user;
|
||||||
if($this->can_upload($user)) {
|
if($this->can_upload($user)) {
|
||||||
$this->theme->display_block($event->page);
|
if($is_full) {
|
||||||
|
$this->theme->display_full($event->page);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$this->theme->display_block($event->page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +65,9 @@ class Upload extends Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this->theme->display_page($event->page);
|
if(!$is_full) {
|
||||||
|
$this->theme->display_page($event->page);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,6 +88,9 @@ class Upload extends Extension {
|
|||||||
|
|
||||||
if(is_a($event, "DataUploadEvent")) {
|
if(is_a($event, "DataUploadEvent")) {
|
||||||
global $config;
|
global $config;
|
||||||
|
if($is_full) {
|
||||||
|
$event->veto("Upload failed; disk nearly full");
|
||||||
|
}
|
||||||
if(filesize($event->tmpname) > $config->get_int('upload_size')) {
|
if(filesize($event->tmpname) > $config->get_int('upload_size')) {
|
||||||
$event->veto("File too large (".filesize($event->tmpname)." > ".($config->get_int('upload_size')).")");
|
$event->veto("File too large (".filesize($event->tmpname)." > ".($config->get_int('upload_size')).")");
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,10 @@ class UploadTheme extends Themelet {
|
|||||||
$page->add_block(new Block("Upload", $this->build_upload_block(), "left", 20));
|
$page->add_block(new Block("Upload", $this->build_upload_block(), "left", 20));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function display_full($page) {
|
||||||
|
$page->add_block(new Block("Upload", "Disk nearly full, uploads disabled", "left", 20));
|
||||||
|
}
|
||||||
|
|
||||||
public function display_page($page) {
|
public function display_page($page) {
|
||||||
global $config;
|
global $config;
|
||||||
$tl_enabled = ($config->get_string("transload_engine", "none") != "none");
|
$tl_enabled = ($config->get_string("transload_engine", "none") != "none");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user