forked from extern/egroupware
- htmlarea plugin "UploadImage" works now together with sitemgr.
- In sitmgr ->configure-site you can now specify a directory where images should be uploaded
This commit is contained in:
parent
f5956885c1
commit
1a0f3ab29c
@ -1,87 +1,111 @@
|
|||||||
<?php
|
<?php
|
||||||
/**************************************************************************\
|
/**************************************************************************\
|
||||||
* eGroupWare - UploadImage-plugin for htmlArea *
|
* eGroupWare - UploadImage-plugin for htmlArea *
|
||||||
* http://www.eGroupWare.org *
|
* http://www.eGroupWare.org *
|
||||||
* Written and (c) by Xiang Wei ZHUO <wei@zhuo.org> *
|
* Written and (c) by Xiang Wei ZHUO <wei@zhuo.org> *
|
||||||
* Modified for eGW by and (c) by Pim Snel <pim@lingewoud.nl> *
|
* Modified for eGW by and (c) by Pim Snel <pim@lingewoud.nl> *
|
||||||
* -------------------------------------------- *
|
* -------------------------------------------- *
|
||||||
* This program is free software; you can redistribute it and/or modify it *
|
* This program is free software; you can redistribute it and/or modify it *
|
||||||
* under the terms of the GNU General Public License as published by the *
|
* under the terms of the GNU General Public License as published by the *
|
||||||
* Free Software Foundation; version 2 of the License. *
|
* Free Software Foundation; version 2 of the License. *
|
||||||
\**************************************************************************/
|
\**************************************************************************/
|
||||||
|
|
||||||
/* $id$ */
|
/* $id$ */
|
||||||
|
|
||||||
// FIXME: remove imageMagick shit, we only use gdlib
|
// FIXME: remove imageMagick shit, we only use gdlib
|
||||||
// FIXME: autodetect safe_mode
|
// FIXME: autodetect safe_mode
|
||||||
// FIXME set current app to the calling app
|
// FIXME include header nicer
|
||||||
// FIXME include header nicer
|
|
||||||
|
$phpgw_flags = Array(
|
||||||
$phpgw_flags = Array(
|
'currentapp' => 'home',
|
||||||
'currentapp' => 'jinn',
|
'noheader' => True,
|
||||||
'noheader' => True,
|
'nonavbar' => True,
|
||||||
'nonavbar' => True,
|
'noappheader' => True,
|
||||||
'noappheader' => True,
|
'noappfooter' => True,
|
||||||
'noappfooter' => True,
|
'nofooter' => True
|
||||||
'nofooter' => True
|
);
|
||||||
);
|
|
||||||
|
$GLOBALS['phpgw_info']['flags'] = $phpgw_flags;
|
||||||
$GLOBALS['phpgw_info']['flags'] = $phpgw_flags;
|
|
||||||
|
if(@include('../../../../../../header.inc.php'))
|
||||||
if(@include('../../../../../../header.inc.php'))
|
{
|
||||||
{
|
// I know this is very ugly
|
||||||
// I know this is very ugly
|
}
|
||||||
}
|
else
|
||||||
else
|
{
|
||||||
{
|
@include('../../../../../../../header.inc.php');
|
||||||
@include('../../../../../../../header.inc.php');
|
}
|
||||||
}
|
|
||||||
|
$sessdata = $GLOBALS['phpgw']->session->appsession('UploadImage','phpgwapi');
|
||||||
define('IMAGE_CLASS', 'GD');
|
$phpgw_flags['currentapp'] = $sessdata['app'] ? $sessdata['app'] : 'jinn';
|
||||||
|
|
||||||
//In safe mode, directory creation is not permitted.
|
define('IMAGE_CLASS', 'GD');
|
||||||
$SAFE_MODE = false;
|
|
||||||
|
//In safe mode, directory creation is not permitted.
|
||||||
$sessdata = $GLOBALS['phpgw']->session->appsession('UploadImage','phpgwapi');
|
$SAFE_MODE = false;
|
||||||
|
|
||||||
$BASE_DIR = $sessdata[UploadImageBaseDir];
|
switch ($phpgw_flags['currentapp'])
|
||||||
$BASE_URL = $sessdata[UploadImageBaseURL];
|
{
|
||||||
$MAX_HEIGHT = $sessdata[UploadImageMaxHeight];
|
case 'jinn' :
|
||||||
$MAX_WIDTH = $sessdata[UploadImageMaxWidth];
|
$BASE_DIR = $sessdata[UploadImageBaseDir];
|
||||||
|
$BASE_URL = $sessdata[UploadImageBaseURL];
|
||||||
if(!$MAX_HEIGHT) $MAX_HEIGHT = 10000;
|
$MAX_HEIGHT = $sessdata[UploadImageMaxHeight];
|
||||||
if(!$MAX_WIDTH) $MAX_WIDTH = 10000;
|
$MAX_WIDTH = $sessdata[UploadImageMaxWidth];
|
||||||
// _debug_array($sessdata);
|
// _debug_array($sessdata);
|
||||||
//die();
|
//die();
|
||||||
|
break;
|
||||||
|
case 'sitemgr' :
|
||||||
//After defining which library to use, if it is NetPBM or IM, you need to
|
if(is_writeable($sessdata['upload_dir']))
|
||||||
//specify where the binary for the selected library are. And of course
|
{
|
||||||
//your server and PHP must be able to execute them (i.e. safe mode is OFF).
|
$BASE_DIR = $sessdata['upload_dir'];
|
||||||
//If you have safe mode ON, or don't have the binaries, your choice is
|
$BASE_URL = str_replace($GLOBALS['_SERVER']['DOCUMENT_ROOT'],'',$sessdata['upload_dir']);
|
||||||
//GD only. GD does not require the following definition.
|
}
|
||||||
//define('IMAGE_TRANSFORM_LIB_PATH', '/usr/bin/netpbm/');
|
else
|
||||||
//define('IMAGE_TRANSFORM_LIB_PATH', '"D:\\Program Files\\ImageMagick\\');
|
{
|
||||||
|
echo '<p><b>Error</b></p>';
|
||||||
$BASE_ROOT = '';
|
echo '<p>Upload directory does not exist, or is not writeable by webserver</p>';
|
||||||
$IMG_ROOT = $BASE_ROOT;
|
echo $GLOBALS['egw_info']['user']['apps']['admin'] ?
|
||||||
|
'<a href="'. $GLOBALS['phpgw']->link('/index.php',
|
||||||
if(strrpos($BASE_DIR, '/')!= strlen($BASE_DIR)-1)
|
'menuaction=sitemgr.Common_UI.DisplayPrefs').'">Choose an other directory</a><br>
|
||||||
$BASE_DIR .= '/';
|
or make "'. $sessdata['upload_dir']. '" writeable by webserver' :
|
||||||
|
'Notify your Administrator to correct this Situation';
|
||||||
if(strrpos($BASE_URL, '/')!= strlen($BASE_URL)-1)
|
die();
|
||||||
$BASE_URL .= '/';
|
}
|
||||||
|
default :
|
||||||
//Built in function of dirname is faulty
|
break;
|
||||||
//It assumes that the directory nane can not contain a . (period)
|
}
|
||||||
function dir_name($dir)
|
|
||||||
{
|
if(!$MAX_HEIGHT) $MAX_HEIGHT = 10000;
|
||||||
$lastSlash = intval(strrpos($dir, '/'));
|
if(!$MAX_WIDTH) $MAX_WIDTH = 10000;
|
||||||
if($lastSlash == strlen($dir)-1){
|
|
||||||
return substr($dir, 0, $lastSlash);
|
|
||||||
}
|
//After defining which library to use, if it is NetPBM or IM, you need to
|
||||||
else
|
//specify where the binary for the selected library are. And of course
|
||||||
return dirname($dir);
|
//your server and PHP must be able to execute them (i.e. safe mode is OFF).
|
||||||
}
|
//If you have safe mode ON, or don't have the binaries, your choice is
|
||||||
|
//GD only. GD does not require the following definition.
|
||||||
|
//define('IMAGE_TRANSFORM_LIB_PATH', '/usr/bin/netpbm/');
|
||||||
|
//define('IMAGE_TRANSFORM_LIB_PATH', '"D:\\Program Files\\ImageMagick\\');
|
||||||
|
|
||||||
|
$BASE_ROOT = '';
|
||||||
|
$IMG_ROOT = $BASE_ROOT;
|
||||||
|
|
||||||
|
if(strrpos($BASE_DIR, '/')!= strlen($BASE_DIR)-1)
|
||||||
|
$BASE_DIR .= '/';
|
||||||
|
|
||||||
|
if(strrpos($BASE_URL, '/')!= strlen($BASE_URL)-1)
|
||||||
|
$BASE_URL .= '/';
|
||||||
|
|
||||||
|
//Built in function of dirname is faulty
|
||||||
|
//It assumes that the directory nane can not contain a . (period)
|
||||||
|
function dir_name($dir)
|
||||||
|
{
|
||||||
|
$lastSlash = intval(strrpos($dir, '/'));
|
||||||
|
if($lastSlash == strlen($dir)-1){
|
||||||
|
return substr($dir, 0, $lastSlash);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return dirname($dir);
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user