fixed: UGContainer<Type> used a std::vector<Type> and when a new item was inserted
then current iterators (and pointers) were invalidated now we are using std::vector<Type*> this caused some crashes when a new user was added by 'adduser' winix function added: plugin 'export' is able to upload files on a remote server now (not finished yet) changed: Thumb class is now called: Image and we are able to resize images too (some new options in the config and in mount points) added: some new plugin messages git-svn-id: svn://ttmath.org/publicrep/winix/trunk@764 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <errno.h>
|
||||
#include "upload.h"
|
||||
#include "core/misc.h"
|
||||
#include "core/plugin.h"
|
||||
#include "functions/functions.h"
|
||||
#include "templates/templates.h"
|
||||
#include "utf8.h"
|
||||
@@ -89,16 +90,17 @@ bool Upload::UploadSaveStaticFile(const Item & item, const std::wstring & tmp_fi
|
||||
}
|
||||
|
||||
|
||||
void Upload::CreateThumb(Item & item)
|
||||
|
||||
void Upload::ResizeImage(Item & item)
|
||||
{
|
||||
::Mount & m = *system->mounts.pmount;
|
||||
size_t cx = config->thumb_cx;
|
||||
size_t cy = config->thumb_cy;
|
||||
int mode = config->thumb_mode;
|
||||
int index;
|
||||
::Mount & m = *cur->mount;
|
||||
size_t cx = config->image_cx;
|
||||
size_t cy = config->image_cy;
|
||||
int mode = config->image_mode;
|
||||
int quality = config->image_quality;
|
||||
|
||||
// reading width and height from the mount point (if exists)
|
||||
index = system->mounts.MountParThumbSize();
|
||||
int index = system->mounts.MountParImageSize();
|
||||
|
||||
if( m.param[index].defined && m.param[index].arg.size() == 2 )
|
||||
{
|
||||
@@ -106,11 +108,39 @@ void Upload::CreateThumb(Item & item)
|
||||
cy = Tol(m.param[index].arg[1]);
|
||||
}
|
||||
|
||||
if( cx > 2000 )
|
||||
cx = 2000;
|
||||
// reading image mode from the mount point (if exists)
|
||||
index = system->mounts.MountParImageMode();
|
||||
|
||||
if( cy > 2000 )
|
||||
cy = 2000;
|
||||
if( m.param[index].defined && m.param[index].arg.size() == 1 )
|
||||
mode = Toi(m.param[index].arg[0]);
|
||||
|
||||
// reading image quality from the mount point (if exists)
|
||||
index = system->mounts.MountParImageQuality();
|
||||
|
||||
if( m.param[index].defined && m.param[index].arg.size() == 1 )
|
||||
quality = Toi(m.param[index].arg[0]);
|
||||
|
||||
system->image.Resize(item, cx, cy, mode, quality);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Upload::CreateThumb(Item & item)
|
||||
{
|
||||
::Mount & m = *cur->mount;
|
||||
size_t cx = config->thumb_cx;
|
||||
size_t cy = config->thumb_cy;
|
||||
int mode = config->thumb_mode;
|
||||
int quality = config->thumb_quality;
|
||||
|
||||
// reading width and height from the mount point (if exists)
|
||||
int index = system->mounts.MountParThumbSize();
|
||||
|
||||
if( m.param[index].defined && m.param[index].arg.size() == 2 )
|
||||
{
|
||||
cx = Tol(m.param[index].arg[0]);
|
||||
cy = Tol(m.param[index].arg[1]);
|
||||
}
|
||||
|
||||
// reading thumb mode from the mount point (if exists)
|
||||
index = system->mounts.MountParThumbMode();
|
||||
@@ -118,7 +148,13 @@ void Upload::CreateThumb(Item & item)
|
||||
if( m.param[index].defined && m.param[index].arg.size() == 1 )
|
||||
mode = Toi(m.param[index].arg[0]);
|
||||
|
||||
system->thumb.CreateThumb(item, cx, cy, mode);
|
||||
// reading image quality from the mount point (if exists)
|
||||
index = system->mounts.MountParThumbQuality();
|
||||
|
||||
if( m.param[index].defined && m.param[index].arg.size() == 1 )
|
||||
quality = Toi(m.param[index].arg[0]);
|
||||
|
||||
system->image.CreateThumb(item, cx, cy, mode, quality);
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +162,7 @@ void Upload::CreateThumb(Item & item)
|
||||
void Upload::UploadFile(Item & item, const std::wstring & tmp_filename)
|
||||
{
|
||||
// we should add the file beforehand to get the proper item.id
|
||||
cur->request->status = system->AddFile(item);
|
||||
cur->request->status = system->AddFile(item, 0, false);
|
||||
|
||||
if( cur->request->status == WINIX_ERR_OK )
|
||||
{
|
||||
@@ -136,8 +172,16 @@ void Upload::UploadFile(Item & item, const std::wstring & tmp_filename)
|
||||
{
|
||||
cur->request->status = db->EditFileById(item, item.id);
|
||||
|
||||
if( item.file_type == WINIX_ITEM_FILETYPE_IMAGE && config->create_thumb )
|
||||
CreateThumb(item);
|
||||
plugin.Call(WINIX_FILE_ADDED, &item);
|
||||
|
||||
if( item.file_type == WINIX_ITEM_FILETYPE_IMAGE )
|
||||
{
|
||||
if( config->image_resize )
|
||||
ResizeImage(item);
|
||||
|
||||
if( config->create_thumb )
|
||||
CreateThumb(item);
|
||||
}
|
||||
|
||||
if( is_jquery_upload )
|
||||
cur->request->item_tab.push_back(item);
|
||||
|
Reference in New Issue
Block a user