backport by request~
git-svn-id: file:///home/shish/svn/shimmie2/branches/branch_2.2@922 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
parent
34d2165dfa
commit
8f05de4b66
@ -6,6 +6,8 @@ class Upload extends Extension {
|
|||||||
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;
|
||||||
$config->set_default_int('upload_count', 3);
|
$config->set_default_int('upload_count', 3);
|
||||||
@ -16,9 +18,14 @@ 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)) {
|
||||||
|
if($is_full) {
|
||||||
|
$this->theme->display_full($event->page);
|
||||||
|
}
|
||||||
|
else {
|
||||||
$this->theme->display_block($event->page);
|
$this->theme->display_block($event->page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "upload")) {
|
if(is_a($event, 'PageRequestEvent') && ($event->page_name == "upload")) {
|
||||||
if(count($_FILES) + count($_POST) > 0) {
|
if(count($_FILES) + count($_POST) > 0) {
|
||||||
@ -58,9 +65,11 @@ class Upload extends Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if(!$is_full) {
|
||||||
$this->theme->display_page($event->page);
|
$this->theme->display_page($event->page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(is_a($event, 'SetupBuildingEvent')) {
|
if(is_a($event, 'SetupBuildingEvent')) {
|
||||||
$sb = new SetupBlock("Upload");
|
$sb = new SetupBlock("Upload");
|
||||||
@ -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