fixed: winix_subdomain ezc function
didn't print the subdomain added: to rm winix function: bool Rm::RemoveItemByPath(const std::wstring & path, bool check_access) fixed: in Upload winix function when uploading an image we have to get a mount point where the image is placed (parent dir) (it was cur->mount beforehand) git-svn-id: svn://ttmath.org/publicrep/winix/trunk@844 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
b605fb0a77
commit
86d6c96aeb
|
@ -216,8 +216,10 @@ return RemoveFile(item);
|
||||||
|
|
||||||
|
|
||||||
// for other uses (plugins etc)
|
// for other uses (plugins etc)
|
||||||
void Rm::RemoveItemById(long item_id, bool check_access)
|
bool Rm::RemoveItemById(long item_id, bool check_access)
|
||||||
{
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
// selecting files, symlinks and directories
|
// selecting files, symlinks and directories
|
||||||
rm_by_id_iq.SetAll(false, false);
|
rm_by_id_iq.SetAll(false, false);
|
||||||
rm_by_id_iq.sel_parent_id = true;
|
rm_by_id_iq.sel_parent_id = true;
|
||||||
|
@ -233,12 +235,47 @@ void Rm::RemoveItemById(long item_id, bool check_access)
|
||||||
if( db->GetItem(rm_by_id_item, rm_by_id_iq) == WINIX_ERR_OK )
|
if( db->GetItem(rm_by_id_item, rm_by_id_iq) == WINIX_ERR_OK )
|
||||||
{
|
{
|
||||||
if( rm_by_id_item.type == Item::dir )
|
if( rm_by_id_item.type == Item::dir )
|
||||||
|
{
|
||||||
RemoveDirTree(rm_by_id_item, true, check_access);
|
RemoveDirTree(rm_by_id_item, true, check_access);
|
||||||
|
result = true; // RemoveDirTree doesn't return a status
|
||||||
|
}
|
||||||
else
|
else
|
||||||
RemoveFileOrSymlink(rm_by_id_item, check_access);
|
{
|
||||||
|
result = RemoveFileOrSymlink(rm_by_id_item, check_access);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool Rm::RemoveItemByPath(const std::wstring & path, bool check_access)
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
int res = system->FollowAllLinks(path, rm_path_dir_tab, rm_path_item);
|
||||||
|
|
||||||
|
if( res == 0 )
|
||||||
|
{
|
||||||
|
Item * dir = system->dirs.GetDir(rm_path_dir_tab.back()->id);
|
||||||
|
|
||||||
|
if( dir )
|
||||||
|
{
|
||||||
|
RemoveDirTree(*dir, true, check_access);
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if( res == 1 )
|
||||||
|
{
|
||||||
|
result = RemoveFileOrSymlink(rm_path_item, check_access);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool Rm::RemoveDirFiles(long dir_id, bool check_access)
|
bool Rm::RemoveDirFiles(long dir_id, bool check_access)
|
||||||
|
|
|
@ -35,7 +35,13 @@ public:
|
||||||
|
|
||||||
// removing either a directory or a symlink or a file
|
// removing either a directory or a symlink or a file
|
||||||
// if item_id is a directory then the whole subdirectories are removed too
|
// if item_id is a directory then the whole subdirectories are removed too
|
||||||
void RemoveItemById(long item_id, bool check_access = true);
|
bool RemoveItemById(long item_id, bool check_access = true);
|
||||||
|
|
||||||
|
// removing either a directory or a symlink or a file
|
||||||
|
// if path is a directory then the whole subdirectories are removed too
|
||||||
|
// path must begin with a slash (or can be empty then the root directory is removed)
|
||||||
|
bool RemoveItemByPath(const std::wstring & path, bool check_access = true);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -51,6 +57,9 @@ private:
|
||||||
DbItemQuery rm_by_id_iq;
|
DbItemQuery rm_by_id_iq;
|
||||||
Item rm_by_id_item;
|
Item rm_by_id_item;
|
||||||
|
|
||||||
|
std::vector<Item*> rm_path_dir_tab;
|
||||||
|
Item rm_path_item;
|
||||||
|
|
||||||
bool HasAccessToDir(const Item & dir, bool only_content);
|
bool HasAccessToDir(const Item & dir, bool only_content);
|
||||||
void Prepare();
|
void Prepare();
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
|
@ -36,10 +36,6 @@ bool Upload::HasAccess(const Item & item)
|
||||||
if( item.type != Item::dir )
|
if( item.type != Item::dir )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// we must know where to store the file
|
|
||||||
if( !system->mounts.pmount )
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if( config->upload_dir.empty() )
|
if( config->upload_dir.empty() )
|
||||||
{
|
{
|
||||||
log << log1 << "Request: can't use upload function, upload_dir must be set in the config file" << logend;
|
log << log1 << "Request: can't use upload function, upload_dir must be set in the config file" << logend;
|
||||||
|
@ -93,7 +89,7 @@ bool Upload::UploadSaveStaticFile(const Item & item, const std::wstring & tmp_fi
|
||||||
|
|
||||||
void Upload::ResizeImage(Item & item)
|
void Upload::ResizeImage(Item & item)
|
||||||
{
|
{
|
||||||
::Mount & m = *cur->mount;
|
::Mount * m = system->mounts.CalcMount(item.parent_id);
|
||||||
size_t cx = config->image_cx;
|
size_t cx = config->image_cx;
|
||||||
size_t cy = config->image_cy;
|
size_t cy = config->image_cy;
|
||||||
int mode = config->image_mode;
|
int mode = config->image_mode;
|
||||||
|
@ -102,23 +98,23 @@ void Upload::ResizeImage(Item & item)
|
||||||
// reading width and height from the mount point (if exists)
|
// reading width and height from the mount point (if exists)
|
||||||
int index = system->mounts.MountParImageSize();
|
int index = system->mounts.MountParImageSize();
|
||||||
|
|
||||||
if( m.param[index].defined && m.param[index].arg.size() == 2 )
|
if( m && m->param[index].defined && m->param[index].arg.size() == 2 )
|
||||||
{
|
{
|
||||||
cx = Tol(m.param[index].arg[0]);
|
cx = Tol(m->param[index].arg[0]);
|
||||||
cy = Tol(m.param[index].arg[1]);
|
cy = Tol(m->param[index].arg[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reading image mode from the mount point (if exists)
|
// reading image mode from the mount point (if exists)
|
||||||
index = system->mounts.MountParImageMode();
|
index = system->mounts.MountParImageMode();
|
||||||
|
|
||||||
if( m.param[index].defined && m.param[index].arg.size() == 1 )
|
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
|
||||||
mode = Toi(m.param[index].arg[0]);
|
mode = Toi(m->param[index].arg[0]);
|
||||||
|
|
||||||
// reading image quality from the mount point (if exists)
|
// reading image quality from the mount point (if exists)
|
||||||
index = system->mounts.MountParImageQuality();
|
index = system->mounts.MountParImageQuality();
|
||||||
|
|
||||||
if( m.param[index].defined && m.param[index].arg.size() == 1 )
|
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
|
||||||
quality = Toi(m.param[index].arg[0]);
|
quality = Toi(m->param[index].arg[0]);
|
||||||
|
|
||||||
system->image.Resize(item, cx, cy, mode, quality);
|
system->image.Resize(item, cx, cy, mode, quality);
|
||||||
}
|
}
|
||||||
|
@ -127,7 +123,7 @@ void Upload::ResizeImage(Item & item)
|
||||||
|
|
||||||
void Upload::CreateThumb(Item & item)
|
void Upload::CreateThumb(Item & item)
|
||||||
{
|
{
|
||||||
::Mount & m = *cur->mount;
|
::Mount * m = system->mounts.CalcMount(item.parent_id);
|
||||||
size_t cx = config->thumb_cx;
|
size_t cx = config->thumb_cx;
|
||||||
size_t cy = config->thumb_cy;
|
size_t cy = config->thumb_cy;
|
||||||
int mode = config->thumb_mode;
|
int mode = config->thumb_mode;
|
||||||
|
@ -136,23 +132,23 @@ void Upload::CreateThumb(Item & item)
|
||||||
// reading width and height from the mount point (if exists)
|
// reading width and height from the mount point (if exists)
|
||||||
int index = system->mounts.MountParThumbSize();
|
int index = system->mounts.MountParThumbSize();
|
||||||
|
|
||||||
if( m.param[index].defined && m.param[index].arg.size() == 2 )
|
if( m && m->param[index].defined && m->param[index].arg.size() == 2 )
|
||||||
{
|
{
|
||||||
cx = Tol(m.param[index].arg[0]);
|
cx = Tol(m->param[index].arg[0]);
|
||||||
cy = Tol(m.param[index].arg[1]);
|
cy = Tol(m->param[index].arg[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reading thumb mode from the mount point (if exists)
|
// reading thumb mode from the mount point (if exists)
|
||||||
index = system->mounts.MountParThumbMode();
|
index = system->mounts.MountParThumbMode();
|
||||||
|
|
||||||
if( m.param[index].defined && m.param[index].arg.size() == 1 )
|
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
|
||||||
mode = Toi(m.param[index].arg[0]);
|
mode = Toi(m->param[index].arg[0]);
|
||||||
|
|
||||||
// reading image quality from the mount point (if exists)
|
// reading image quality from the mount point (if exists)
|
||||||
index = system->mounts.MountParThumbQuality();
|
index = system->mounts.MountParThumbQuality();
|
||||||
|
|
||||||
if( m.param[index].defined && m.param[index].arg.size() == 1 )
|
if( m && m->param[index].defined && m->param[index].arg.size() == 1 )
|
||||||
quality = Toi(m.param[index].arg[0]);
|
quality = Toi(m->param[index].arg[0]);
|
||||||
|
|
||||||
system->image.CreateThumb(item, cx, cy, mode, quality);
|
system->image.CreateThumb(item, cx, cy, mode, quality);
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,7 +284,7 @@ void winix_postvar_value_is_not(Info & i)
|
||||||
|
|
||||||
void winix_subdomain(Info & i)
|
void winix_subdomain(Info & i)
|
||||||
{
|
{
|
||||||
cur->request->subdomain;
|
i.out << cur->request->subdomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue