diff options
author | friendica <info@friendica.com> | 2012-06-25 01:37:44 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-06-25 01:37:44 -0700 |
commit | 35a098e0dc7940974132d8d65bbc4418d92fb204 (patch) | |
tree | 3f49c1497c38c54b50dacbafc04933aa16cfb28a /mod | |
parent | ad6c82bdea11e4c35284e18608f78ad4c355405d (diff) | |
download | volse-hubzilla-35a098e0dc7940974132d8d65bbc4418d92fb204.tar.gz volse-hubzilla-35a098e0dc7940974132d8d65bbc4418d92fb204.tar.bz2 volse-hubzilla-35a098e0dc7940974132d8d65bbc4418d92fb204.zip |
service limits for photo uploads
Diffstat (limited to 'mod')
-rw-r--r-- | mod/photos.php | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/mod/photos.php b/mod/photos.php index 31046565d..ea4d7f81f 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -711,6 +711,24 @@ function photos_post(&$a) { logger('mod/photos.php: photos_post(): loading the contents of ' . $src , LOGGER_DEBUG); $imagedata = @file_get_contents($src); + + + + $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ", + intval($a->data['user']['uid']) + ); + + $limit = service_class_fetch($a->data['user']['uid'],'photo_upload_limit'); + + if(($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) { + notice( upgrade_message() . EOL ); + @unlink($src); + $foo = 0; + call_hooks('photo_post_end',$foo); + killme(); + } + + $ph = new Photo($imagedata, $type); if(! $ph->is_valid()) { @@ -968,12 +986,25 @@ function photos_content(&$a) { <input type="submit" name="submit" value="' . t('Submit') . '" id="photos-upload-submit" /> </div>'; - + $r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ", + intval($a->data['user']['uid']) + ); + + + $limit = service_class_fetch($a->data['user']['uid'],'photo_upload_limit'); + if($limit !== false) { + $usage_message = sprintf( t("You have used %1$.2f Mbytes of %2$.2f Mbytes photo storage."), $r[0]['total'] / 1024000, $limit / 1024000 ); + } + else { + $usage_message = sprintf( t('You have used %1$.2f Mbytes of photo storage.'), $r[0]['total'] / 1024000 ); + } + $tpl = get_markup_template('photos_upload.tpl'); $o .= replace_macros($tpl,array( '$pagename' => t('Upload Photos'), '$sessid' => session_id(), + '$usage' => $usage_message, '$nickname' => $a->data['user']['nickname'], '$newalbum' => t('New album name: '), '$existalbumtext' => t('or existing album name: '), |